How to mount a subdirectory at boot time
I have a partition, sda8, that gets mounted as /share1 at boot time by it's entry in /etc/fstab. What I NEED is to actually have:
/share1/this_dir mounted as /this_dir and /share1/that_dir mounted as /that_dir I tried using fstab, couldn't make it work - I guess it just mounts partitions, not subdirs. After booting, I can issue the command: mount --bind /share1/this_dir this_dir This works great, but I don't want to do this EVERY time I reboot. I tried putting this in /etc/skel/.profile doesn't work? Any ideas? Thanks in advance, Terry. |
Yes, you can only mount partitions (devices) that way.
To access the subdirs I would mount it then create symlinks into the mounted subdirs. Then you would access this_dir and that_dir by the symlinks. When sda8 was not mounted the symlinks would remain but simply be dead ends, but would be valid again when the device is mounted. |
After rebooting, via /etc/fstab, /dev/sda8 gets mounted as /share1.
If I issue the following command: ln -s /share1/this_dir this_dir then try ls -l, I get: lrwxrwxrwx 1 root root 13 Jul 7 00:36 this_dir -> /share1/this_dir/ ok, hang on... I got to smart for myself. When I do a normal ls, I get all my files! Question for you astrogeek, when I issue the ln -s /share/this_dir this_dir command, the symlink exists over multiple boots, right? <-- of course it does. --> Cheers, Terry. |
How about this in /etc/fstab
Code:
/dev/sda8 /share1 ext4 defaults 0 0 |
Another possible way would be adding the command
mount --bind /share1/this_dir this_dir to the local initscript like /etc/rc.d/rc.local /etc/init.d/local /etc/local.d/local.start or whichever file this is on your distribution. |
All times are GMT -5. The time now is 11:53 PM. |