Linux - NewbieThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
what is mount -a and what it does?
Why we need to do mount -a? Although we make entry in /etc/fstab. do we really need to do mount -a? If we don't do, will it make any effect in our file system?
The "-a" flag to mount just tells it to mount all filesystems listed in /etc/fstab, except for those where the noauto option is set. It's generally used by one of the early init scripts to mount all filesystems in the system. You generally don't need to run it once the system is booted, unless you've created a lot of new filesystems, added them to fstab, and want to mount them all quickly.
So, I'm not exactly sure what you're asking. If you make an entry in /etc/fstab, you won't be able to access that filesystem until and unless it gets mounted somehow.
I created directory
#mkdir /data
# mkdir /data/db
#mkdir /data/log
created logical volume, file system on it and mounted in /data and make entry in /etc/fstab
when I rebooted the system, I found /data/db and /data/log folder is not more inside /data. but when I did mount -a and rebooted the system...folder /data/db and /data/log were still there. so in earlier when i have not done mount -a and after reboot these folder /data/db and /data/log were gone
Last edited by linuxmantra; 05-10-2014 at 11:29 AM.
That's weird. Running "mount -a" does not affect in any way which filesystems are mounted at boot (that's the job of /etc/fstab). Perhaps you had a mistake in the fstab entry the first time around?
It may depend on the distribution. Fedora currently uses systemd - and it has been known to read the fstab, and then do the wrong thing.
One of the problems is that if (for some reason) the logical volume doesn't get initialized in time, systemd will either ignore it, or hang (I think it depends on WHEN it gets ignored. The initrd might ignore it, but if it happens after the real root gets mounted it may hang - but I may have this backwards).
One of the stupid fixes is to rebuild the initrd used by grub2 - it seems that the "normal" way copies an fstab into the initrd. Thus a reboot doesn't even look at the /etc/fstab anymore (an ignore situation).
This has frequently shown up when somebody updates/expands/reduces their swap partition (which changes the UUID), and even though the /etc/fstab file has been updated, the system crashes instead because it can't find the original swap.
As one last thing, "mount -a" was implemented to be used during boot - the SysVinit script would then mount the designated root, then use "mount -a -t <local filesystem type>" which would mount all local filesystems (ie, no mounts requiring special handling like LVM).
This process was modified to allow for more complex startups - first mount the root filesystem, start swap ("swapon -a" to get all defined swap partitions active), start the networks, start LVM (though not necessarily in that order. Starting the networks could include starting fibre channel networks, and/or NFS client services which would give access to more disks, which would then be used in a logical volume), and then using a "mount -a" to mount.
There could even be an extra "mount -a -t <type>" after enabling swap to get system dependent filesystems mounted - when /var, /usr, /usr/local were all on separate partitions and the <type> would identify the class of filesystems to mount.
NFS startup scripts usually included a "mount -a -t NFS" to ensure that the mounts occurred AFTER the network and client services were properly started (another thing systemd doesn't always get right).
Ah -- I forgot about the possibility of systemd weirdness. I've been stuck in the SysVInit world for too long I guess.
I have run into strange problems on RHEL clones about LVM and MD RAID arrays not getting initialized in the correct order, but I haven't seen that in the past few versions. I'd be surprised if that was still an issues these days, but it's always possible.
I created directory
#mkdir /data
# mkdir /data/db
#mkdir /data/log
created logical volume, file system on it and mounted in /data and make entry in /etc/fstab
when I rebooted the system, I found /data/db and /data/log folder is not more inside /data. but when I did mount -a and rebooted the system...folder /data/db and /data/log were still there. so in earlier when i have not done mount -a and after reboot these folder /data/db and /data/log were gone
In general you should mount a device under an empty directory. the /data directory is a gate to a new filesystem, after mount -a. So the directories of the previous filesystem still exist ,but are not accessible. you could use the mount command to see it yourself.Try something like this
ls
mount -t ext3 /dev/mapper/lv0 /data
ls
it is an easy way to make files inaccessible and therefore , hidden from everyone.
In general you should mount a device under an empty directory. the /data directory is a gate to a new filesystem, after mount -a. So the directories of the previous filesystem still exist ,but are not accessible. you could use the mount command to see it yourself.Try something like this
ls
mount -t ext3 /dev/mapper/lv0 /data
ls
it is an easy way to make files inaccessible and therefore , hidden from everyone.
After making logical volume, I will make file system using following command:
#mkfs.ext4 /dev/mapper/vg/lvol
and mounted it at a point
After making logical volume, I will make file system using following command:
#mkfs.ext4 /dev/mapper/vg/lvol
and mounted it at a point
# mount /dev/mapper/vg/lvol /data
that's it.
if you have stuff under /data , the newly mounted file system will hide them .
when you unmount the /dev/mapper/vg/lvol ,the old stuff will be accessible again
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.