LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   how to configure /etc/fstab with auto but do not mount it after boot up (http://www.linuxquestions.org/questions/linux-newbie-8/how-to-configure-etc-fstab-with-auto-but-do-not-mount-it-after-boot-up-4175412632/)

masuch 06-21-2012 04:49 AM

how to configure /etc/fstab with auto but do not mount it after boot up
 
Hi,

I would like to have in /etc/fstab configuration that:

1. after bootup I do not want to mount it.
2. but when I do mount -a in terminal - do mount all stuff with auto switch

is it possible or does exist some workaround how to do it?


please help,
thank you for any idea/hint,
kind regards,
M.


Example:
I have:

LABEL=rlraid0ocz /media/raid0ocz ext4 rw,suid,dev,exec,auto,nouser,async,acl,user_xattr,nobootwait,errors=remount-ro,noatime,discard 0 0
LABEL=rlraid0ext41 /media/raid0ext41 ext4 rw,suid,dev,exec,auto,nouser,async,acl,user_xattr,nobootwait,errors=remount-ro 0 0
LABEL=rlraid0btrfs1 /media/raid0btrfs1 btrfs rw,suid,dev,exec,auto,nouser,async,nobootwait 0 0
LABEL=rlraid0jfs1 /media/raid0jfs1 jfs rw,suid,dev,exec,auto,nouser,async,nobootwait,errors=remount-ro 0 0
LABEL=rlraid0reiserfs1 /media/raid0reiserfs1 reiserfs rw,suid,dev,exec,auto,nouser,async,acl,user_xattr,nobootwait 0 0
LABEL=rlraid0xfs1 /media/raid0xfs1 xfs rw,suid,dev,exec,auto,nouser,async,nobootwait 0 0

-- they are mounting after reboot what I do not want. --
-- but properly mount by '$ mount -a' ... I need it.

pixellany 06-21-2012 05:32 AM

From the man page for fstab:
Quote:

Basic file system independent options are:
.
.
noauto do not mount when "mount -a" is given (e.g., at boot time)

the implication is that the init scripts issue the command "mount -a" (you can check this)

If you don't mind a kludge, you could set an entry to "noauto", and then add a line to an init script that changes the fstab entry after "mount -a" has been issued.

VDP76 06-21-2012 07:20 AM

hi,

as pixellany pointed out, the command mount -a is issued at boot and noauto does not work with that, so I guess you have to find a way around it.

I would give noauto and users options to the drive you want to not be mounted at boot and the you can just do (as non-root user)
Code:

mount /media/raid0xxxx
(with proper name instead of xxxx)
If you want to do this on more than one drive you can create a script like
Code:

#!/bin/bash
mount /media/raid0xxxx1
mount /media/raid0xxxx2

Would that fit your needs?


p.s.: please, when you write code, config files, etc.. in your posts use the [CODE] tags so it is more readable.

masuch 06-21-2012 01:50 PM

thanks you all for help.

Even if I am using script to start it manually I am curious which init script contains "mount -a" - where is it located ?
I would like to learn how the boot process works more precisely.

regards,
M.

ohlookpie 06-21-2012 03:07 PM

Couldn't you also do this with the automounter? Then, if you cd to the mount point for the filesystem, it will mount it automatically. What's the difference between using the noauto option in /etc/fstab vs. using the automounter? Just different methods of getting the volume mounted?

VDP76 06-21-2012 07:19 PM

Quote:

Originally Posted by masuch (Post 4708750)
thanks you all for help.
Even if I am using script to start it manually I am curious which init script contains "mount -a" - where is it located ?
I would like to learn how the boot process works more precisely.
regards,
M.

I am glad my post was helpfull.. ;)
I have found this, check it out for some more info about the boot process (today I have learned something too.. :)). The command mount -a is issued by S35mountall.sh -> ../init.d/mountall.sh.

Quote:

Originally Posted by ohlookpie (Post 4708797)
Couldn't you also do this with the automounter? Then, if you cd to the mount point for the filesystem, it will mount it automatically. What's the difference between using the noauto option in /etc/fstab vs. using the automounter? Just different methods of getting the volume mounted?

Yes, eventually they are just different ways to get the job done...
Cheers
M.

chrism01 06-21-2012 07:43 PM

Actually, if you red this page and the links therein, you'll find that autofs can mount drives on demand (eg when cd'ing into the dir), so long as its properly configured.

VDP76 06-22-2012 03:58 AM

Quote:

Originally Posted by chrism01 (Post 4708923)
Actually, if you red this page and the links therein, you'll find that autofs can mount drives on demand (eg when cd'ing into the dir), so long as its properly configured.

+1 to my continuous Linux learning, thanks for the precisation! :)

ohlookpie 06-22-2012 04:16 AM

Tested on my CentOS 6.2 box:

1. mkdir /test
2. vi /etc/auto.master and add this line:
Quote:

/test /etc/auto.test
3. vi /etc/auto.test and add this line:
Quote:

foo -fstype=ext4 :/dev/sda2
4. cd to /test/foo and it automatically mounts device /dev/sda2 (and ls /test/foo would have the same results).
5. cd out and it automatically unmounts the device after 10 minutes or so

I just need to figure out how to make it so that I can cd to /test and have it mount. I tried a * instead of foo, didn't work. I tried a / instead of foo, didn't work. I imagine there's a way though. Side note: You could edit auto.misc and add "foo -fstype=ext4 :/dev/sda2" and then you'd just cd to /misc/foo and get the same results. If you did this, you would not have to edit auto.master, since auto.misc is already in auto.master.


All times are GMT -5. The time now is 06:24 PM.