After searching a bit I could not find a simple and good howto to do that.
The following method should work for any Linux distribution (Ubuntu, Debian, Manjaro, Archlinux, Fedora…). Source and target systems must be on the same processor architecture (though transfer from 32bit to 64bit should work).
What you need:
- 2 live USB keys (or cds)
- To speed up data transfer: good quality ethernet cables (one cable between the 2 computers is OK), or a usb key/drive with a BIG ext4 partition. You can try over wifi, but it may be slow.
1. Boot source and target machines on live USB/CD
2. Partition your target hard drive
Use a tool like gparted to partition the target hard drive, with the same partitions as your source system (slash, swap, home…).
I recommend you to assign LABELs to your partitions: for the fstab, it’s easier than UUIDs.
3. Mount all partitions on both machines
On both systems, open a root terminal. Then, for each data partition (you can ignore swap):
mkdir /mnt/slash mount /dev/sdaX /mnt/slash
If you have a home partition:
mkdir /mnt/home mount /dev/sdaY /mnt/home
4. Transfer the data (network or usb)
This part may be tricky. Choose the method you prefer.
- Setup the network. Test the connectivity with ping command.
The easier is to plug the PCs on a DHCP network (like your ISP box) so that you get automatic IP addresses. If you linked the 2 pcs with a single cable, you’ll have to setup the IPs with NetworkManager (static ips, or adhoc network).
- On source system, as root, create a simple
uid = root gid = root use chroot = no [all] path = /
- Then start the rsync daemon server:
- On target PC, for each partition:
rsync -avHX SOURCE_IP::all/mnt/slash/ /mnt/slash/
Don’t forget ‘/’ at the end of paths.
-awill preserve many file attributes like owner and permissions,
-Hwill preserve hardlinks if any,
-Xwill preserve extended attributes like setuid. You may also add
-Aif you are using acls. What is good with rsync is that you can stop and restart the transfer whenever you want.
Prepare a USB drive with a BIG ext4 partition.
- Mount the USB partition on source system (
mount /dev/sdbX /mnt/usb)
- For each partition:
rsync -avHX /mnt/slash/ /mnt/usb/slash/
- umount, unplug and remount the USB disk on the target system.
- For each partition:
rsync -avHX /mnt/usb/slash/ /mnt/slash/
5. Change fstab on target system
As root, edit
For each partition (including swap), replace the first field with the new UUID or LABEL (it’s straightforward with LABELs):
2 ways to get the UUIDs / LABELs:
ls -l /dev/disk/by-uuid/ blkid /dev/sdaX
6. Reinstall Grub
We will use a chroot (changed root environment) to be able to call the grub install inside the migrated system.
First, bind mount some system directories needed by grub, then chroot:
mount --bind /proc /mnt/slash/proc mount --bind /sys /mnt/slash/sys mount --bind /dev /mnt/slash/dev mount --bind /run /mnt/slash/run chroot /mnt/slash
Then install grub in the Master Boot Record of your hard drive, and update grub config file (with the new uuids…):
grub-install /dev/sda update-grub
7. Reboot target machine
That’s it! Your system should be working on the new computer now.
Feel free to comment if you encounter problems.