LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-17-2016, 12:36 AM   #1
jzoudavy
Member
 
Registered: Apr 2012
Distribution: Ubuntu, SUSE, Redhat
Posts: 180

Rep: Reputation: Disabled
is there a way to feed mount commands into /etc/fstab?


EDIT:
I do know to add an entry into fstab by hand. This is just a thought on something that would make our lives a little easier.


Hi all

Just a thought here:
Say I created a new disk on Ubuntu, I fdisk it and mkfs it. and mount it and test it out which is all very nice and dandy. Now I have to go to /etc/fstab and add in an extra line to make it permanent.

Is there no way to somehow commit the mount command to fstab file?

Example:

Code:
mount /dev/sdb1 /home/test/new_disk //this mounts the disk.


mount -?? /dev/sdb1 /home/test/new_disk //this should write to the /etc/fstab file with default option if mount is successfully executed.
Thanks

Last edited by jzoudavy; 04-17-2016 at 12:53 AM.
 
Old 04-17-2016, 12:47 AM   #2
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,254

Rep: Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686
How about you have a look at the data currently in fstab and google how to add an entry.
 
Old 04-17-2016, 12:52 AM   #3
jzoudavy
Member
 
Registered: Apr 2012
Distribution: Ubuntu, SUSE, Redhat
Posts: 180

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by grail View Post
How about you have a look at the data currently in fstab and google how to add an entry.
Actually I do know to add an entry into fstab by hand thank you very much. It was just a thought on something that would make our lives a little easier.

You can do that on networking routers where you edit the settings, it will run, then commit the changes to save the new settings permanently. No need to
Quote:
Originally Posted by grail View Post
have a look at the data currently in fstab and google how to add an entry.
 
Old 04-17-2016, 01:05 AM   #4
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 14,842

Rep: Reputation: 1823Reputation: 1823Reputation: 1823Reputation: 1823Reputation: 1823Reputation: 1823Reputation: 1823Reputation: 1823Reputation: 1823Reputation: 1823Reputation: 1823
So after a couple of months plugging USB drives in and out, what do you reckon fstab would look like ?.
 
Old 04-17-2016, 01:56 AM   #5
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,254

Rep: Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686
So, as with your router example, write a script that monitors all mounting on your system and have it decimate your fstab for you at will.
By the way, the setting you are talking about editing on the router, are the equivalent of editing fstab.
 
Old 04-17-2016, 02:04 AM   #6
AwesomeMachine
Senior Member
 
Registered: Jan 2005
Location: USA and Italy
Distribution: Debian testing/sid; OpenSuSE; Fedora
Posts: 1,835

Rep: Reputation: 260Reputation: 260Reputation: 260
Editing fstab is the linux equivalent of wiping one's nose. You just have to do it sometimes.
 
Old 04-17-2016, 09:36 AM   #7
MadeInGermany
Member
 
Registered: Dec 2011
Posts: 198

Rep: Reputation: 77
The fundamental question is:
does GNU stick to the Unix tradition to have commands for immediate-but-volatile actions, but needs editing of text files for making them permanent?

In Solaris the philosophy has changed (starting with logadm in Solaris 9).
 
Old 04-18-2016, 08:08 AM   #8
Habitual
LQ Addict
 
Registered: Jan 2011
Location: Youngstown, Ohio
Distribution: LM17.1/Xfce4.11.8
Posts: 7,182
Blog Entries: 10

Rep: Reputation: 1980Reputation: 1980Reputation: 1980Reputation: 1980Reputation: 1980Reputation: 1980Reputation: 1980Reputation: 1980Reputation: 1980Reputation: 1980Reputation: 1980
Most modern Ubuntus use udisk, so what version of Ubuntu are you referring to?
 
Old 04-18-2016, 11:15 AM   #9
cepheus11
Member
 
Registered: Nov 2010
Location: Germany
Distribution: Gentoo
Posts: 269

Rep: Reputation: 83
Quote:
Originally Posted by jzoudavy View Post
Is there no way to somehow commit the mount command to fstab file?

Code:
findmnt -lnU --target <mountpoint> -o SOURCE,TARGET,FSTYPE,OPTIONS,FREQ,PASSNO >> /etc/fstab
comes pretty close. You have to change the spaces in the output to tabs (optional), and add FREQ and PASSNO (findmnt does not fill the columns). Check the output before you actually do the redirection to /etc/fstab.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Cannot mount NFS share (Fstab special character at the end of the mount) meki Linux - Newbie 3 01-06-2016 02:22 PM
Cannot mount NFS share (Fstab special character at the end of the mount) meki Linux - Newbie 3 01-01-2016 11:19 AM
fstab problem: mount: can't find dvd in /etc/fstab or /etc/mtab Nikon01 Slackware 5 11-17-2006 07:15 AM
FSTAB: My Win Share Wont Mount @ Boot, but will when I sudo mount -a...please help! TruANTOlogy Ubuntu 8 06-20-2006 09:00 AM


All times are GMT -5. The time now is 02:22 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration