Gangmax Blog

How to mount a hard drive to a sub-directory

From here.

There are three ways to achieve this.

  1. Edit your “/etc/fatab”:
1
2
3
4
# I assumed that disk A is not mounted as the root (/) filesystem. If it is, just ignore lines with disk A.
/dev/diskA /var/www/ auto defaults 1 2
/dev/diskB /ver/www/upload auto defaults 1 2
# You can replace "auto" by the filesystem you have on that partition, but the above should work anyway.
  1. Synblic link if disks A and B are mounted elsewhere:
1
2
3
ln -s /path/to/driveA_mountpoint /var/www/
ln -s /path/to/driveB_mountpoint /var/www/upload
# Note: /var/www and directory "upload" on driveA must not exist or this will fail.
  1. Use the bind option of “mount” command:
1
2
mount -o bind /var/www/ /path/to/driveA_mountpoint
mount -o bind /var/www/upload /path/to/driveB_mountpoint

Comments