Difference between revisions of "Migrate installation to new hardware"

From ArchWiki
Jump to navigation Jump to search
m (Command formatted as command to match the other commands on this page)
 
(6 intermediate revisions by 5 users not shown)
Line 1: Line 1:
[[Category:System administration]]
 
 
[[Category:System recovery]]
 
[[Category:System recovery]]
 
{{out of date|Mentions rc.conf and uses links to wiki articles that don't exist anymore.}}
 
{{out of date|Mentions rc.conf and uses links to wiki articles that don't exist anymore.}}
Line 13: Line 12:
 
=== On the old system ===
 
=== On the old system ===
 
==== What software? ====
 
==== What software? ====
  $ pacman -Qqe | grep -vx "$(pacman -Qqm)" > Packages
+
  $ pacman -Qqen > Packages
  $ pacman -Qqm > Packages.aur
+
  $ pacman -Qqem > Packages.aur
 
gives you a nice list of explicitly installed packages. Don't forget the software ''not'' installed through pacman (also see [[Arch_User_Repository#Why_has_foo_disappeared_from_the_AUR.3F|AUR FAQ]]). You may also use the following script to give you a better overview of the binaries and libraries installed unbeknownst to pacman (e. g. installed via Steam, Desura or using their own install methods):
 
gives you a nice list of explicitly installed packages. Don't forget the software ''not'' installed through pacman (also see [[Arch_User_Repository#Why_has_foo_disappeared_from_the_AUR.3F|AUR FAQ]]). You may also use the following script to give you a better overview of the binaries and libraries installed unbeknownst to pacman (e. g. installed via Steam, Desura or using their own install methods):
  
Line 57: Line 56:
 
*Transfer data over network, for example with [[rsync]]. Data link: old HDD -> old computer -> network -> new computer -> new HDD.
 
*Transfer data over network, for example with [[rsync]]. Data link: old HDD -> old computer -> network -> new computer -> new HDD.
 
For the first two options, consider that you might need adapters to connect the HDDs (PATA->SATA, USB-HDD-Cases, etc.), and choose a connection that is sufficiently fast.
 
For the first two options, consider that you might need adapters to connect the HDDs (PATA->SATA, USB-HDD-Cases, etc.), and choose a connection that is sufficiently fast.
The last two options require you to use a live system on the new computer, as it is not possible to boot from the new harddrive at this point. It is also worth to clean up your system before cloning it. See [[List of applications#Disk usage display]] for useful tools.
+
The last two options require you to use a live system on the new computer, as it is not possible to boot from the new hard drive at this point. It is also worth to clean up your system before cloning it. See [[List of applications#Disk usage display]] for useful tools.
  
 
=== Update fstab ===
 
=== Update fstab ===
 +
{{Warning|Before doing this step please make sure that you do not wish to use this drive in the old system, as removing/altering the [[fstab]] file will likely prevent the system from booting in the old configuration}}
 +
If you are using an Arch Linux Installation Image, mount the new root partition to {{ic|/mnt}}, and any other partitions required like you would in a normal install (see [[Installation guide#Mount the file systems]]). Next remove the old fstab file using the following command {{bc| # rm /mnt/etc/fstab}} and then generate a new one as indicated on [[Installation guide#Fstab]].
 +
{{Note|Make sure to check that no unnecessary partitions are mounted. This can be checked by running {{ic|mount -l}} and checking all the partitions that are mounted under {{ic|/mnt}} (either directly or under a subfolder of {{ic|/mnt}}). If there are any partitions mounted that are unnecessary you can unmount them using {{ic|umount devname}} where {{ic|devname}} is the name of the device you with to unmount (most likely in the from {{ic|/dev/sdxn}} with {{ic|x}} a letter indicating the device and {{ic|n}} a number indicating the specific partition)}}
 +
 +
Alternative methods to alter the fstab file are:
 
*using /dev paths: this should change depending on how the new drives are connected to the mainboard, on the BIOS and on the new partitions scheme
 
*using /dev paths: this should change depending on how the new drives are connected to the mainboard, on the BIOS and on the new partitions scheme
 
*using fs labels: should be safe
 
*using fs labels: should be safe
Line 65: Line 69:
  
 
=== Reconfigure the bootloader ===
 
=== Reconfigure the bootloader ===
*because of:
+
Reasons you might need to reconfige the bootloader:
**new HDD and partitions configuration
+
*new HDD and partitions configuration
**new BIOS configuration
+
*new BIOS configuration
 +
*update framebuffer mode (if new gpu)
 +
*USB to SATA/NVMe migration?
 +
**often UEFI doesn't boot [[EFISTUB]] of a non-removable medium without explicit configuration, use f.e. {{Ic|efibootmgr}}
 +
{{Note|If you are using an Arch Linux Installation Image make sure that you have set changed you root to the new boot partion (preferably using {{ic|arch-chroot}})}}
 +
If you are using [[GRUB]] simply run install procedure as indicated for you setup (BIOS vs UEFI) and then generate the main config as indicated on [[GRUB#Generate the main configuration file]].<br>
 +
Alternatives are:
 
*GRUB allows to edit entries with 'e'
 
*GRUB allows to edit entries with 'e'
 
*use a live system?
 
*use a live system?
*update framebuffer mode (if new gpu)
 
  
 
=== Regenerate kernel image ===
 
=== Regenerate kernel image ===
Line 92: Line 101:
 
*if using [[dhcpcd]] with named network interfaces:
 
*if using [[dhcpcd]] with named network interfaces:
 
** {{Ic|$ dmesg <nowiki>|</nowiki> grep 'renamed from eth'}} might help to find the new interface name
 
** {{Ic|$ dmesg <nowiki>|</nowiki> grep 'renamed from eth'}} might help to find the new interface name
** remove old {{Ic|# systemctl remove dhcpcd@enp''X''s0.service}}
+
** remove old {{Ic|# systemctl disable dhcpcd@enp''X''s0.service}}
 
** activate new {{Ic|# systemctl start dhcpcd@enp''X''s0.service}}
 
** activate new {{Ic|# systemctl start dhcpcd@enp''X''s0.service}}
  

Latest revision as of 21:26, 28 November 2019

Tango-view-refresh-red.pngThis article or section is out of date.Tango-view-refresh-red.png

Reason: Mentions rc.conf and uses links to wiki articles that don't exist anymore. (Discuss in Talk:Migrate installation to new hardware#)

This article discusses the steps required for moving an Arch Linux system to new hardware. The goal is to achieve the same ArchLinux installation, as far as installed software and configuration is concerned.

There are two different approaches to migrating an installation:

  1. Bottom to Top: Install a fresh Arch Linux system on the new hardware, afterwards restore the installed packages and configuration files.
  2. Top to Bottom: Clone the old harddrive to the new harddrive, or place the old harddrive into the new system; modify configuration files where necessary.

Which way you choose depends heavily on how the new system differs from your old and how exact you want to reproduce the system.

Warning: Some of the following instructions can be dangerous: you are advised to backup all of your important data on the old system before continuing.

Bottom to Top

On the old system

What software?

$ pacman -Qqen > Packages
$ pacman -Qqem > Packages.aur

gives you a nice list of explicitly installed packages. Don't forget the software not installed through pacman (also see AUR FAQ). You may also use the following script to give you a better overview of the binaries and libraries installed unbeknownst to pacman (e. g. installed via Steam, Desura or using their own install methods):

find / -regextype posix-extended -regex "/(sys|srv|proc)|.*/\.ccache/.*" -prune -o -type f \
-exec bash -c 'file "{}" | grep -E "(32|64)-bit"' \; | \
awk -F: '{print $1}' | \
while read -r bin; \
do pacman -Qo "$bin" &>/dev/null || echo "$bin"; \
done

Copy to some backup space.

  • You can consider backing up /var/cache/pacman/pkg if you do not change architectures (example: from x86 to x86_64)
  • /etc should be backed up, in order to peek if necessary.

On the new system

Wiki articles

  • Read some Wiki articles concerning new hardware, for examples your new SSD.
  • Stick to the well-written installation guidelines here in this wiki. Since you are experienced, the Installation guide could be enough.
  • Try to configure as much as possible sticking to current wiki articles and forum posts.

Copy from backup space

  • Copy the pacman cache to var/cache/pacman/pkg
  • Don't forget to edit /etc/pacman.d/mirrorlist

Install software

As root, grab a cup of coffee and execute:

# xargs -a Packages pacman -S --noconfirm --needed

Top to Bottom

Merge-arrows-2.pngThis article or section is a candidate for merging with Migrating Between Architectures Without Reinstalling.Merge-arrows-2.png

Notes: please use the second argument of the template to provide more detailed indications. (Discuss in Talk:Migrate installation to new hardware#)

Move the system to the new HDDs

Note: If you are planning to keep the hard drive where the system is already installed, you can skip this section.

There are two fundamental methods for copying data between two disks, cloning an entire disk, and copying single files. For details see Disk cloning. If you want to clone the entire disk, it is required to use a live cd to do so.

At the same time there are many different methods for how to transport the data between the two drives:

  • Connect origin and destination HDDs to the same computer, either the old or the new one. Data link: old HDD -> computer -> new HDD.
  • Make use of temporary storage devices like external HDDs, or cloud backups. Data link: old HDD -> old computer -> storage -> new computer -> new HDD.
  • Transfer data over network, for example with rsync. Data link: old HDD -> old computer -> network -> new computer -> new HDD.

For the first two options, consider that you might need adapters to connect the HDDs (PATA->SATA, USB-HDD-Cases, etc.), and choose a connection that is sufficiently fast. The last two options require you to use a live system on the new computer, as it is not possible to boot from the new hard drive at this point. It is also worth to clean up your system before cloning it. See List of applications#Disk usage display for useful tools.

Update fstab

Warning: Before doing this step please make sure that you do not wish to use this drive in the old system, as removing/altering the fstab file will likely prevent the system from booting in the old configuration

If you are using an Arch Linux Installation Image, mount the new root partition to /mnt, and any other partitions required like you would in a normal install (see Installation guide#Mount the file systems). Next remove the old fstab file using the following command

 # rm /mnt/etc/fstab

and then generate a new one as indicated on Installation guide#Fstab.

Note: Make sure to check that no unnecessary partitions are mounted. This can be checked by running mount -l and checking all the partitions that are mounted under /mnt (either directly or under a subfolder of /mnt). If there are any partitions mounted that are unnecessary you can unmount them using umount devname where devname is the name of the device you with to unmount (most likely in the from /dev/sdxn with x a letter indicating the device and n a number indicating the specific partition)

Alternative methods to alter the fstab file are:

  • using /dev paths: this should change depending on how the new drives are connected to the mainboard, on the BIOS and on the new partitions scheme
  • using fs labels: should be safe
  • using UUIDs

Reconfigure the bootloader

Reasons you might need to reconfige the bootloader:

  • new HDD and partitions configuration
  • new BIOS configuration
  • update framebuffer mode (if new gpu)
  • USB to SATA/NVMe migration?
    • often UEFI doesn't boot EFISTUB of a non-removable medium without explicit configuration, use f.e. efibootmgr
Note: If you are using an Arch Linux Installation Image make sure that you have set changed you root to the new boot partion (preferably using arch-chroot)

If you are using GRUB simply run install procedure as indicated for you setup (BIOS vs UEFI) and then generate the main config as indicated on GRUB#Generate the main configuration file.
Alternatives are:

  • GRUB allows to edit entries with 'e'
  • use a live system?

Regenerate kernel image

  • initially the Fallback image could work
  • regenerate image
    • mkinitcpio -p linux

Update the graphic drivers

  • if changed driver (e.g. from ATI to NVIDIA) can uninstall the old drivers

Reconfigure audio

  • alsamixer volume
    • save settings

Reconfigure network

  • if need to change hostname:
    • hostnamectl
    • /etc/hosts
    • other apps using hostname: synergy, nut (network ups tools)
      • # grep -Ri 'hostname' /etc should give some hints on the files to be updated
  • if using dhcpcd with named network interfaces:
    • $ dmesg | grep 'renamed from eth' might help to find the new interface name
    • remove old # systemctl disable dhcpcd@enpXs0.service
    • activate new # systemctl start dhcpcd@enpXs0.service

See also