Ubuntu – Cannot mount second drive at “/”

filesystemmount

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 /

Best Answer

  • 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 still no official union-mount solution in Linux (2014-04-22); 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.

    Update: the overlayfs file-system has been promoted to standard kernel for version 3.18. So now there is an official union-type solution for linux; userspace utility to simplify its use will surely follow. For now, documentation is in the kernel tree at Documentation/filesystems/overlayfs.txt.

  • Related Question