Migrate HD using Arch Linux Install Media

How to migrate your Arch Linux installation to a new HD using the official install media

#arch, #unix

The first things you need to do are:

  1. Boot Arch Linux Install Media;
  2. Partition New Drive;
  3. And mount old drive, based on another directory like /newmount.

If you don’t know how to do that maybe it is a better ideia not to do this 😐

Mount new drive:

As I said, you need to mount your new HD, I will use /mnt/new to my new HD and /mnt/old to old one.

For example, in my case, my new HD is:

# mount -t ext4 /dev/sdb2 /mnt/new
# mkdir /mnt/new/home
# mount -t ext4 /dev/sdb3 /mnt/new/home

rsync them all!

# rsync --group --owner --perms --recursive --delete --delete-after --links --times /mnt/old/ /mnt/new

This rsync command will preserve owner, group, permissions, and so on.

WARNING: Respect the use or not of ending / in the command above.

If you use cp or any other tool make sure you copy at least owner, groups, permissions, and links.

arch-chroot the new hd

# arch-chroot /mnt/new

Modify configuration files, I only need to update /etc/fstab, but your installation can require to change others.

In my computer I removed this line from /etc/fstab:

/dev/sda2              /               ext4            rw,relatime,data=ordered        0 1

And added these:

UUID=885c880d-2e47-47a4-93be-1dad7b43d655 none                 swap            defaults        0 0
UUID=9fc8c58c-3ad2-434d-8acb-4ebfc1ebb1a6              /               ext4            rw,relatime,data=ordered        0 1
UUID=0760b342-aafa-45ce-a5f8-3320238aaba3      /home   ext4    defaults 0      0

If you are not sure about UUIDs, just run this command:

# ls -l /dev/disk/by-uuid
lrwxrwxrwx 1 root root 10 Jan 16 21:37 0760b342-aafa-45ce-a5f8-3320238aaba3 -> ../../sdb3
lrwxrwxrwx 1 root root 10 Jan 16 21:10 2016-01-01-11-39-46-00 -> ../../sdc1
lrwxrwxrwx 1 root root 10 Jan 16 21:10 53A0-40D0 -> ../../sdc2
lrwxrwxrwx 1 root root 10 Jan 16 21:37 885c880d-2e47-47a4-93be-1dad7b43d655 -> ../../sdb1
lrwxrwxrwx 1 root root 10 Jan 16 21:10 955f4530-97e9-4740-afe9-b8d5fff831d6 -> ../../sda1
lrwxrwxrwx 1 root root 10 Jan 16 21:37 9fc8c58c-3ad2-434d-8acb-4ebfc1ebb1a6 -> ../../sdb2
lrwxrwxrwx 1 root root 10 Jan 16 21:10 eb2013c8-5ec4-4616-9a9c-5655659fc4f4 -> ../../sda2

Rebuild linux image

It may not be required, but it does not take a long time, so let’s do it:

# mkinitcpio -p linux

Install grub

You will need also to install grub in the new HD:

# grub-mkconfig -o /boot/grub/grub.cfg
# grub-install --target=i386-pc --recheck /dev/sdb

Remember: my new hd is right now called /dev/sdb yours can be different.


Exit chroot, umount, and shutdown:

# exit
# umount /mnt/new/home /mnt/new /mnt/old
# shutdown

Remove only your old HD and start your computer :)

Posts in this series