Migrating Linux Root Filesystem to New Drive HOWTO  
Here we wish to migrate a Linux root filesystem located in /dev/sda1 to a new partition in a different drive /dev/sdb1. The difficulty here is in copying all files properly and making sure the new drive can be booted on its own.
Copy Files
First boot in a live Linux USB image. After booting into the live image, mount the old drive and new drive as follows:
sudo mount /dev/sda1 /mnt/old
sudo mount /dev/sdb1 /mnt/new
Copy all files from old to new:
sudo cp -a /mnt/old/* /mnt/new
Once this is done, you need to change the UUID of the partition /dev/sdb1 mounted as / in /mnt/new/etc/fstab. You can find the UUID of the partitions using the command
sudo blkid
Change Filesystem Root
Then, you need to mount also sys, proc, run, dev. As user root in bash type the following
for i in /sys /proc /run /dev; do sudo mount --bind "$i" "/mnt/new$i"; done
Then, change the root of the filesystem to the new one:
sudo chroot /mnt/new
Put Grub on MBR
Now, we can run commands just as if we had booted into the new OS. Thus, we can update grub:
sudo update-grub
and install it on the Master Boot Record (MBR) of the new disk (it doesn't hurt to do so anyway):
sudo grub-install /dev/sdb
sudo update-grub
Exit and reboot
sudo reboot
For more information, see this thread here:
https://askubuntu.com/questions/88384/h ... ng-windows
PDF 1✕1 2✕1 2✕2