简体   繁体   中英

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?

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.

A little alternative would be renaming /mnt to /data after umount. Also it would be better to change the label for it. eg for xfs file type:

xfs_admin -L "data" /dev/vdb

Following things to make sure before changing the mount point.

  1. Is there any change in username and group of the mount. if yes make sure service account user and group are created.
  2. The mount name folder should exists in the /home/ directory, if not do create an empty folder with the same name you wanted the mount to be.
  3. Verify the /home/ mount folder user:group are correct.
  4. Now use umount command to unmount the mount you wanted.
  5. use mount command to mount the file system you wanted to rename.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM