Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

i want to have 2 partitions. one is called system. the other is private.

in the private partition i've got some folders i want to mount into system as system folders.

folders in private: - www - home

mount points in system: - /var/www - /home

is this possible? cause it seems that you can only specify a whole partition to use for a mount point and not a folder in a partition or am i wrong?

i run ubuntu server.

cheers

share|improve this question
add comment

2 Answers 2

up vote 2 down vote accepted

On Linux, you can do this with bind mounts.

These commands:

mount --bind /private/www /var/www
mount --bind /private/home /home

Will do what you want. The fstab version of them is:

/private/www   /var/www  none  bind
/private/home  /home     none  bind
share|improve this answer
    
...the unspoken assumption being that you've previously mounted the private partition to /private ...right? –  quack quixote Apr 7 '10 at 18:21
    
so i dont have to do this during installation? but what happens to the files in /var/www if i mount /private/www there instead? so goes with /home. cause maybe someone already created some users in /home. –  ajsie Apr 7 '10 at 18:22
    
The files are still there, just hidden by the filesystem that is mounted on top. If you need access to them, consider adding links in, for example, /home to the directories in /private/home –  KeithB Apr 7 '10 at 20:15
    
Yes same caveats of normal mounting still apply, the src has to exist (you can't mount /dev/md0 to / if you don't have /dev/md0), contents of the dst directory will be hidden. Did I answer you question? –  kbyrd Apr 7 '10 at 20:54
add comment

You need to mount the whole volume somewhere so that you can get access to the contents. Once you have done that you can do a bind mount to mount part of it somewhere else as well. See the mount(8) man page for details.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.