Zexin Li

Please keep honest, open, patient, happy and visionary.

0%

Migrate user from /home to new disk

Synopsis

Sometimes we need to migrate user from /home to new disk, e.g., when the boot disk is full. This post is a note for this process.

Prerequisite checklist

Check if the new disk is mounted correctly by df -h. If not, mount it by sudo mount ${DEVICE_NAME} ${MOUNT_POINT}.

Move user home directory

1
2
sudo mv /home/${USER_NAME} ${MOUNT_POINT}
sudo ln -s ${MOUNT_POINT}/${USER_NAME} /home/${USER_NAME}

(Important) Make sure the permission is correct for the new home directory

The permission of the new home directory should be 755 and the permission of .ssh and authorized_keys should be 700 and 600 respectively. Otherwise, ssh login will fail.

1
2
3
sudo chmod 755 ${MOUNT_POINT}/${USER_NAME}
sudo chmod 700 ${MOUNT_POINT}/${USER_NAME}/.ssh
sudo chmod 600 ${MOUNT_POINT}/${USER_NAME}/.ssh/authorized_keys

Welcome to my other publishing channels