Skip to content

Instantly share code, notes, and snippets.

@nqxcode
Created December 22, 2020 22:29
Show Gist options
  • Save nqxcode/f8fd7e182da58fb2f015250aecc7bcf9 to your computer and use it in GitHub Desktop.
Save nqxcode/f8fd7e182da58fb2f015250aecc7bcf9 to your computer and use it in GitHub Desktop.
Migration of linux system to another disk

Migration of linux system to another disk.

Case for disk with MBR.

1. Copy source disk partitions / and /home to another disk.

# mkdir /mnt/sdb1
# mount /dev/sdb1 /mnt/sdb1
# cd /
# find ./ -xdev -print0 | cpio -pa0V  /mnt/sdb1

# mkdir /mnt/sdb2
# mount /dev/sdb2 /mnt/sdb2
# cd /home
# find ./ -xdev -print0 | cpio -pa0V  /mnt/sdb2

2. Install grub

# for i in /sys /proc /run /dev; do sudo mount --bind "$i" "/mnt/sdb1$i"; done
# sudo chroot /mnt/sdb1
# update-grub
# grub-install /dev/nvme1n1
# update-grub
# exit
# reboot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment