Linux – Two distinct mount points with one device

linuxmount

After being disappointed with Ubuntu's release update feature, I finally decided to have separate mount points for / and /home.

Towards this, I reformatted my HDD giving most of my drive to sda1(meant to be /home) and allocated about 40GB to rootfs (/).
Unfortunately, I would also like to have a /projects which is to be located on sda1.

Currently, sda1 is being mounted as
/dev/sda1 on /home type ext4 (rw)
I've tried looking online for a solution to this problem..however, I'm not sure as to what to look for!

Is it possible to mount the 'home' directory of sda1 as /home and 'projects' directory of sda1 as /projects?

Best Answer

Use a bind mount:

mount /dev/sda1 /home
mount -t none -o bind /home/projects /projects

You can also put these in /etc/fstab:

/dev/sda1       /home      ext4 defaults  1 2
/home/projects  /projects  none bind      0 0

The rbind option is needed to make submounts visible, for example because /projects/apollo is on a separate partition. ro can be used to mount it read-only.

More details are available in the mount(8) man page, in the "Bind mount operation" section.

Related Question