LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training 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 05-10-2014, 11:33 AM   #1
linuxmantra
Member
 
Registered: Dec 2013
Posts: 112

Rep: Reputation: Disabled
Why mount -a?


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?
 
Old 05-10-2014, 11:41 AM   #2
btmiller
Senior Member
 
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,284

Rep: Reputation: 371Reputation: 371Reputation: 371Reputation: 371
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.
 
Old 05-10-2014, 12:25 PM   #3
linuxmantra
Member
 
Registered: Dec 2013
Posts: 112

Original Poster
Rep: Reputation: Disabled
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 12:29 PM.
 
Old 05-10-2014, 01:38 PM   #4
btmiller
Senior Member
 
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,284

Rep: Reputation: 371Reputation: 371Reputation: 371Reputation: 371
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?
 
Old 05-11-2014, 06:56 AM   #5
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,713

Rep: Reputation: 1279Reputation: 1279Reputation: 1279Reputation: 1279Reputation: 1279Reputation: 1279Reputation: 1279Reputation: 1279Reputation: 1279
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).

Last edited by jpollard; 05-11-2014 at 07:21 AM.
 
Old 05-11-2014, 11:11 AM   #6
btmiller
Senior Member
 
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,284

Rep: Reputation: 371Reputation: 371Reputation: 371Reputation: 371
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.
 
Old 05-11-2014, 12:58 PM   #7
johny21
LQ Newbie
 
Registered: May 2014
Posts: 4

Rep: Reputation: Disabled
Quote:
Originally Posted by linuxmantra View Post
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.
 
Old 05-11-2014, 04:41 PM   #8
linuxmantra
Member
 
Registered: Dec 2013
Posts: 112

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by johny21 View Post
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

# mount /dev/mapper/vg/lvol /data
that's it.
 
Old 05-12-2014, 11:43 AM   #9
johny21
LQ Newbie
 
Registered: May 2014
Posts: 4

Rep: Reputation: Disabled
Quote:
Originally Posted by linuxmantra View Post
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
 
  


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
manual mount cifs works but srcipt mount cifs has mount error (13): Permission denied CADIT Linux - Newbie 6 11-20-2009 03:48 PM
when i mount my USB Flash Drive A Messenge has come that mount: can't find /dev/sda/h feda82 Red Hat 2 12-24-2005 03:15 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:03 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