Copy your Linux System to a New Harddrive

Note: This article assumes your new harddrive is mounted to /media/temp/ and that it is attached to /dev/sda. Make sure you change the commands below to reflect your system before running them.

First mount your new drive. Mount your partitions as they will be on your finished system to /media/temp/.

Then use rsync to copy the file to your new harddrive

rsync -aAXv --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found"} /* /media/temp/

Update your /etc/fstab file. You can use blkid /dev/sda1 to get the partition UUIDs.

Chroot into your new file system.

mount -t proc proc /media/temp/proc
mount --bind /dev /media/temp/dev
mount --bind /sys /media/temp/sys
chroot /media/temp /bin/bash

Install GRUB

grub-install --target=i386-pc --recheck --debug /dev/sda
grub-mkconfig -o /boot/grub/grub.cfg
Written on March 21, 2015