Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change mountpoint name?

I am working in ubuntu, this is what df -h shows:

Filesystem      Size  Used Avail Use% Mounted on
/dev/vda         30G  1.7G   27G   6% /
none            4.0K     0  4.0K   0% /sys/fs/cgroup
udev             15G   12K   15G   1% /dev
tmpfs           3.0G  372K  3.0G   1% /run
none            5.0M     0  5.0M   0% /run/lock
none             15G     0   15G   0% /run/shm
none            100M     0  100M   0% /run/user
/dev/vdb        197G   60M  187G   1% /mnt

Now I want to change the name of /mnt to /data directory instead. I want all the content to stay where it is, the only thing that has to change is the name of the drive mountpoint.

Here is what I have in /etc/fstab file.

LABEL=c3image-rootfs    /               ext4    errors=remount-ro 0       1
/dev/vdb        /mnt    auto    defaults,nobootwait,comment=cloudconfig 0       2

Could you please explain the commands necessary and the files to edit?

like image 534
user1950349 Avatar asked Oct 18 '16 21:10

user1950349


1 Answers

It goes without saying that you should be careful, and understand what each command does before running it - you might also need to make sure that nothing is using the files while you do this.

Make the new mountpoint

mkdir /data

unmount the current mountpoint

umount /mnt

edit /etc/fstab and change /mnt to /data

/dev/vdb        /data    auto    defaults,nobootwait,comment=cloudconfig 0       2

mount the new location

mount /data

It is not recommended to remove the /mnt directory because in part of Linux standard system tree, but you can remove the old mount point, named for example /old/mnt/path with this command:

rmdir /old/mnt/path

because a mount points is a directory.

like image 186
Daniel Scott Avatar answered Oct 13 '22 03:10

Daniel Scott