-2

I have already installed ubuntu in one of my server and it looks like below

udev            7.2G     0  7.2G   0% /dev
tmpfs           1.5G   41M  1.4G   3% /run
/dev/vda1        99G  4.6G   89G   5% /
tmpfs           7.2G  4.0K  7.2G   1% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           7.2G     0  7.2G   0% /sys/fs/cgroup
/dev/vdb1       443G   71M  421G   1% /home
tmpfs           1.5G     0  1.5G   0% /run/user/1001

Here i want to create a new mount point called "/app" from the storage of "/home"

How can i do this in ubuntu server?

Mayuran
  • 669
  • 2
  • 8
  • 39

1 Answers1

2

There are 3 ways to do this. And I'm guessing here because it's hard to understand what exactly you want.

  1. Just create a symbolic link
  2. Take use of the "bind" feature
  3. Make a disk image file and mount that

Senario 1.

We have /home mounted with all our disk storage, and now we want /app to just use the same directory as /home. Well just create a symbolic link.

ln -s /app /home

Now When you go into /app you will be in /home. Just know that symlink is treated like a file not directory. In case you need to monitor it from a script etc.

Senario 2.

You require it to be mounted, then we can use the "bind" feature of mount. You create a bind mount like this.

mkdir /app
mount --bind /home /app

Now /app is the same as /home on a disk level/ mount level. Also remember that if you want it to be more permanently as mounting it at boot time you need to add it to /etc/fstab

/home /app none defaults,bind 0 0

Senario 3.

Let's say you have all the storage space available at /home, and you need /app to be a separate mount point with it own storage. You could use the bind function to etc. mount /home/app to /app. This makes most sense. But you could also create a disk image file to hold your partition. This last method is not recommended but included to cover most options.

dd if=/dev/zero of=/home/app-disk.img bs=1M count=10
mkfs.ext4 /home/app-disk.img
mkdir /app
mount -o loop /home/app-disk.img /app

This will mount you disk image as /app and the "image" is contained on your main storage device.

Hope this helps, I recommend scenario/option 1 and 2.

PS.

Also you could look into shrinking your /home partition to free up partition table space and create a new separate for /app. But I don't recommend this for someone who don't know much about disk tables. This could potentially lead to loss of data.

davidbl
  • 175
  • 6