Mounting partition(s) by label - Reboot required??
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.
Mounting partition(s) by label - Reboot required??
Hi all,
After googling around I start to come to the fact that there are areas Linux requires reboot, just as Windows regrettably does.
Which it should not have to IMO. Anyways, here are details...
I labeled a newly created ext3 partition like this:
Code:
mkfs -V -t ext3 -v -j -L my-root /dev/sda10
and then immediately (it's all part of an automated script) do:
Code:
mount -v -L my-root /mnt/my-root
Note that /mnt/my-root has been installed earlier, so no problem there. The problem is it says in response to mount request:
Code:
mount: special device /dev/disk/by-label/my-root does not exist
'blkid /dev/sda10' shows that it indeed has the 'my-root' label assigned to it, but 'ls /dev/disk/by-label/*' does not show any file named 'my-root'. Googling revealed that a reboot is required before the label(s) just created are truly available to the system.
Is there any command that can do the same thing reboot would do, effectively bringing the label(s) to immediate availability? I am sure upon rebooting, there is some logic that re-reads labels or something.
Its all a script, this thing of mine, and I don't want to do any logic that will continue from reboot or anything. This smells Windows.....
While not exactly sure, I would guess that a reboot or at least a mounting of the device would be required before the /dev file system would be updated. This is a relatively new "feature" that actually I did not even know about until I read this post.
None the less, there is another solution. You can mount the file system with the device name, which it appears you have since you are creating the file systems. Like so:
Mounting by device name is exactly what I am trying to avoid.
Restarting udev might be a very good idea...
I have another solution though, i did not test it yet, but i observed the following: the files in /dev/disk/by-label are symlinks to device name files (as in /dev/hda1 etc) so i just create symlinks and later when i don't need them i remove them, since /dev is not on disk. I am not sure whether it will work though...
well...when you reboot (if you ever do), i think those symlinks will be gone.
Well, if I reboot after doing creating partitions with labels assigned, symlinks may be gone but will reappear because udev will put them there after enumerating labelled partitions. Thats the point, because after doing "mkfs -t ext3 -L some_label" symlinks ARE supposed to be there, but are not, because a reboot is required (arguably restarting udev may do the trick, which i havent tried yet).
Yes, I did. It is not the most elegant one, but it's quite ok i guess.
What I did was to inspect how the mount by label really works. It turned out it looks for symlinks in /dev/disk/by-label that point to real device nodes in /dev/. So all I had to do after creating partition labels and before reboot, was to create these symlinks, as apparently, they would not appear until next boot. For instance i had a partition labelled "temp". I did ln -s /dev/sda8 /dev/disk/by-label/temp (dont remember exact switches now).
It all worked after these commands.
The only possible problem i see is whether these links I manually created are going to remain there and pollute the /dev filesystem. In case of dev residing in memory, i guess it's not a big deal, but with old fashioned MAKEDEV /dev systems, its on disk, hence my symlinks will stay until removed again. So i do remove them when i no longer need them, since it was a script that needed them, when the script cleans up after itself, it removes these links. Apparently the links that are created by system itself for labelled partitions are of the same sort as those i created manually.
Recap
The key thing you had to do was label the partitions. Then the necessary symlinks would be (re-)created at the next (& all subsequent) reboot(s).
However, you needed the symlinks before rebooting, so you created them "manually"; actually, w/ a script.
Because you were not certain that these symlinks would not cause problems after reboot, you "manually" removed them, again w/ a script.
Unresolved
Was the removal of those symlinks necessary? --
Would they, in fact, have caused problems, or would the system have taken them in stride?
Too early to say now. Have to do more testing to find out. So far no side effects, as long as you remove the manually created links yourself as soon as you no longer require them.
Sorry, did not do that yet. I am stuck with a stupid Windows box. Hope i will finally switch over to Linux permanently. Windows is as addictive as crack, and just as lethal %)
Is there any command that can do the same thing reboot would do, effectively bringing the label(s) to immediate availability? I am sure upon rebooting, there is some logic that re-reads labels or something.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.