LinuxQuestions.org
Visit Jeremy's Blog.
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 07-07-2013, 01:14 AM   #1
linux.penguin67
LQ Newbie
 
Registered: Jun 2013
Location: Northern Illinois
Distribution: OpenSuSE, Fedora, plan9
Posts: 9

Rep: Reputation: Disabled
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.
 
Old 07-07-2013, 01:23 AM   #2
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=14, FreeBSD_10{.0|.1|.2}
Posts: 4,029
Blog Entries: 1

Rep: Reputation: 2114Reputation: 2114Reputation: 2114Reputation: 2114Reputation: 2114Reputation: 2114Reputation: 2114Reputation: 2114Reputation: 2114Reputation: 2114Reputation: 2114
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.
 
Old 07-07-2013, 01:41 AM   #3
linux.penguin67
LQ Newbie
 
Registered: Jun 2013
Location: Northern Illinois
Distribution: OpenSuSE, Fedora, plan9
Posts: 9

Original Poster
Rep: Reputation: Disabled
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.

Last edited by linux.penguin67; 07-07-2013 at 02:28 AM.
 
Old 07-07-2013, 03:42 AM   #4
mddnix
Member
 
Registered: Mar 2013
Distribution: Redhat, Ubuntu
Posts: 516

Rep: Reputation: 139Reputation: 139
How about this in /etc/fstab

Code:
/dev/sda8		/share1		ext4	defaults	0 0
/share1/this_dir	/share1		none	bind		0 0
where 'this_dir' is one of directory in '/dev/sda8'. Also note that when you do this, other than 'this_dir', all other sibling directories of 'this_dir' in /dev/sda8 are not accessible.
 
Old 07-07-2013, 07:03 AM   #5
cyberpatrol
Member
 
Registered: Dec 2012
Posts: 75

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


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
mount ftp on boot time anj Linux - Server 7 06-03-2009 09:47 AM
mount issues at boot time poblano Red Hat 5 02-27-2008 09:20 AM
Mount.cifs Mounting a subdirectory of a windows share MonctonJohn Linux - Networking 4 09-28-2007 06:15 AM
mount subdirectory from another Linux server kiwi8 Linux - Newbie 6 07-18-2004 07:33 PM
how to get a new subdirectory with date and time ? cccc Programming 1 02-25-2004 06:10 PM


All times are GMT -5. The time now is 05:12 PM.

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