Technology Encyclopedia Home >How to change the mount point of a filesystem in Linux?

How to change the mount point of a filesystem in Linux?

To change the mount point of a filesystem in Linux, you need to follow these steps:

  1. Unmount the Filesystem: First, ensure the filesystem is not currently in use. Unmount it using the umount command. For example:

    sudo umount /old/mount/point
    

    If the filesystem is busy, you may need to find and terminate processes using it with lsof or fuser.

  2. Mount to the New Location: Use the mount command to mount the filesystem to the new directory. For example:

    sudo mount /dev/sdX1 /new/mount/point
    

    Replace /dev/sdX1 with the actual device name and /new/mount/point with the desired directory.

  3. Update /etc/fstab (Optional but Recommended): To make the change persistent across reboots, edit the /etc/fstab file. Locate the line for the filesystem and update the mount point. For example:

    /dev/sdX1  /new/mount/point  ext4  defaults  0  2
    

    Use nano or vim to edit the file:

    sudo nano /etc/fstab
    
  4. Verify the Change: Check if the filesystem is mounted at the new location:

    df -h
    

    Or:

    mount | grep /new/mount/point
    

Example Scenario:
If you want to move /home to a new partition (/dev/sdb1), you would:

  1. Unmount /home (if it's a separate partition):
    sudo umount /home
    
  2. Mount /dev/sdb1 to /home:
    sudo mount /dev/sdb1 /home
    
  3. Update /etc/fstab:
    /dev/sdb1  /home  ext4  defaults  0  2
    
  4. Verify:
    df -h | grep /home
    

For cloud-based Linux instances on Tencent Cloud, you can use Cloud Virtual Machine (CVM) to manage filesystems. If you need scalable storage, consider CBS (Cloud Block Storage) for flexible disk management. Use Cloud Monitor to track filesystem performance and health.