Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have a second drive that I want to be mounted at the root. The drive contains the following folders:

/home
/shared

I want those two folders to be accessible at "/". I can mount the drive at /media/disk1 but that does not solve my problem.

I tried the following command but it doesn't work:

mount /dev/sdb1 /

I have no errors but the folders do not appear on /

share|improve this question
    
You can only have one partition mounted to a certain point (/ here). You would have to create separate partitions for /home and /shared. Or you could just link /home and /shared to their locations in /media/disk1 –  Nattgew Apr 22 at 17:43
    
@Nattgew: Actually you can! see en.wikipedia.org/wiki/UnionFS –  njzk2 Apr 22 at 20:11

2 Answers 2

up vote 12 down vote accepted

What you seems you want is a "union" mount, which can't be done in Ubuntu (at least not with default tools; follow the above link you are adventurous). In general there is no official union-mount solution in Linux; there are out-of-tree filesystems like AUFS and work-more-or-less-in-progress on UnionMount. Valerie Aurora has a (slightly outdate) page about it.

What you can easily do is mounting the disk at, for example, /mnt/disk1 and then symlink the directories where you want them:

ln -s /mnt/disk1/home /home
ln -s /mnt/disk1/shared /shared 

(again, you should not have an existing /home or /shared folder, confusion and/or errors would appear otherwise).

Another way to do these kind of things is a "bind mount". It's very similar to symlinking directories, but can cross "chroot" boundaries. You can find more info in this page and in this other one.

share|improve this answer
    
Thank you, that's what I'll do ! –  CoachNono Apr 22 at 17:50
1  
I will, I had to wait for the delay ! –  CoachNono Apr 22 at 17:58
1  
Well, something like a merge mount can be and is being done in Linux. –  Ruslan Apr 22 at 19:56
    
Of course it can be done! unionfs for the win! (typically used in cases where you want a drive to be mounted readonly (fragile SSD with limited amount of write cycles, CDs...), but with possibility to write stuff (in ram with tmpfs, discarded when the drive is unmounted) during the session.) –  njzk2 Apr 22 at 20:09
1  
Indeed, I'd love to see an updated answer to this question. –  ændrük Apr 22 at 22:26

You have to create the folders there, for example if you want the A drive there or a folder there, type:

 mkdir -p ~/    

where ~/ is the directory after /, so / is the directory the file is being created in!

You can make any directory with this -- just instead of ~/, type the directory you want the file to be created in. For example, for a file being made in /usr/abc/, type mkdir -p ~/usr/abc/. Hope this helps!

share|improve this answer

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.