新しいハードウェアに移行する

提供: ArchWiki
2020年12月4日 (金) 08:29時点におけるKgx (トーク | 投稿記録)による版 (リンクを修正)
ナビゲーションに移動 検索に移動

関連記事

​この記事では、 Arch Linux システムを新しいハードウェアに移動するために必要な手順について説明します。​目標は、ハードウェアに依存しないインストール済みソフトウェアと構成に関して、同じ ArchLinux インストールを実現することです。

警告: 次の手順の中には危険なものもあります。続行する前に、重要なデータをすべて古いシステムにバックアップしておくことをお勧めします。

​インストールの移行には、2つの異なるアプローチがあります:

  1. ​下から上へ :新しいハードウェアに新しい Arch Linux システムをインストールし、インストールしたパッケージと設定ファイルを、例えば ドットファイル で記述されているように復元します。
  2. 上から下へ :古いハードドライブを新しいハードドライブにクローンするか、古いハードドライブを新しいシステムに配置します。​必要に応じて構成ファイルを変更します。

​上から下へのアプローチは、下から上へ のアプローチよりも元のシステムをより正確に再現します。

新しいハードウェアに適応

警告: どちらのアプローチでも、古いものとハードウェアの違いを考慮し、それに応じてインストールされているドライバーと構成を変更する必要があります。

始める前に、新しいハードウェアの側面を調査し、違いのリストを作成します。 一般的な違いは

ハードドライブと SSD

SSD を参照してください

CPU ベンダー

CPU を別のベンダーの CPU(Intel から AMD など)に切り替える場合は、マイクロコード 構成を変更してください。

GPU ベンダー

GPU を別のベンダーのGPUに変更した場合(AMD から NVIDIA など)、グラフィックスドライバーを変更します。

UEFI と MBR のブートコードの起動

UEFI を使用してより新しいメインボードに切り替える場合は、"MBR ブートコード" ブートから UEFI ブートに切り替えることが望ましいか必要な場合があります。 この場合、新しい EFIシステムパーティション が必要です。

古いマシンから新しいマシンへ

古いシステムの場合

ここでは、このアプローチをインストールガイドと区別する、古いシステムから新しいシステムに引き継がれる最小限の構成を定義します。新しいシステムにコピーする /etc の構成ファイルと /home のドットファイル、およびユーザーデータファイルについて考えてみます。新しいシステムから古いシステムにアクセスできない場合は、コピーするすべてのファイルをバックアップしてください。

インストールされているパッケージのリスト

$ pacman -Qqen > pkglist.txt
$ pacman -Qqem > pkglist_aur.txt

リポジトリと AUR から明示的にインストールされたパッケージの素晴らしいリストを提供します。作成する場合は、バックアップに含めてください。

次のスクリプトを使用して、パックマンに知られていない状態でインストールされたバイナリとライブラリの概要を確認することもできます(たとえば、Steam、Desuraを介してインストールするか、独自のインストール方法を使用してインストールします)。

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

pacman キャッシュ

アーキテクチャを変更しない場合(たとえば、x86 から​ ​x86_64 )は、 /var/cache/pacman/pkg/ のバックアップを検討してください。

新しいシステムで

インストールガイド前半

新しいシステムのインストールの基本については、インストールガイド を参照してください。 pacstrap コマンドを除いて、インストールガイドの前半に従ってください。

pacman キャッシュをコピーする

/var/cache/pacman/pkg/ にある pacman キャッシュを古いシステムから新しいシステムに、またはバックアップから新しいシステムにコピーします。

インストールガイド後半

pacstrap コマンドを含むインストールガイドを最後まで続行しますが、再起動しないでください。パッケージのインストール以外に追加の作業を行うため、 pacstrap コマンドをスキップしないでください。

以前にインストールしたソフトウェアをインストールする

pkglist.txt (および pkglist_aur.txt )を編集し、新しいシステムで不要なドライバーを削除します。次に、以前にインストールした他のソフトウェアを

# pacman -S --needed - < pkglist.txt

Top to bottom

There are two options for the Top to Bottom approach, you can either keep the drive where the system is already installed, and modify its contents, or you can copy the system to a new drive. If you keep the drive, and modify it, then place it back into the old system, the modifications will likely prevent the old system from booting.

Clean up the old system

It is also worth to clean up your system before cloning it, as described in System maintenance#Clean the filesystem. Make sure that the old system is still working as expected after the cleanup before moving on.

Copy the system to a new drive

ノート: 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 the system to a new drive, disk cloning and file copying.

Disk cloning

It is required to use a live linux system rather than the old Arch Linux system; for example you could use the Arch Linux USB flash installation media. The partition layout and filesystems of the old system will be reproduced.

File copying

Transport options

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. For an overview see the article System backup.
  • 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 linux system on the new computer, as it is not possible to boot from the new hard drive at this point.

fstab の更新

警告: この手順を実行する前に、古いシステムでこのドライブを使用しないようにしてください。 fstab ファイルを変更すると、古い構成でシステムが起動しなくなる可能性があります。

​Arch Linux インストールイメージを使用している場合は、新しいルートパーティションを /mnt にマウントし、通常のインストールと同様に必要な他のパーティションをマウントします ファイルシステムのマウント を参照してください。)

/mnt/etc/fstab の最後に、#end of old fstab のような任意のコメントを挿入します。 fstab に記載されているように、新しい fstab ファイルを生成し、現在の fstab ファイルに追加します。​一般に、 genfstab によって作成された fstab ファイルは必ず確認してください。​この場合、コメントの前に古い fstab エントリをチェックし、それらが古くなっているか重複しているかを確認してから削除し、古いエントリが残っている場合は残しておきます。​たとえば、ネットワークドライブのマウントエントリを保持できます。​一般に、永続的なブロックデバイスの命名 を使用することをお勧めします。

Reinstall the boot loader

You might need to reinstall and/or reconfigure the boot loader for the following reasons:

  • Different disks, partition layout, or filesystem
  • Adding UEFI boot entries into the new mainboard NVRAM
  • Migration from "MBR boot code" booting to UEFI booting
  • Migration from USB to SATA/NVMe
  • Updating the kernel commandline
    • In case of a different GPU, update the framebuffer mode
    • Update the Microcode initramfs image

If you are using a Arch Linux live environment, then before reinstalling the boot loader, change root into the new system:

# arch-chroot /mnt

Refer to the article on your boot loader for instructions on how to (re)install it.

Regenerate kernel image

It is recommended to regenerate the initramfs image with mkinitcpio, although initially the fallback initramfs image may work.

Reconfigure audio

  • alsamixer volume
    • save settings

Reconfigure network

If the old installation and the migrated installation shall coexist in the same network, set a new hostname with hostnamectl.

Also consider configuration changes that are required after a change in hostname:

  • /etc/hosts
  • other apps using hostname: synergy, nut (network ups tools)
  • grep -Ri 'hostname' /etc (as the root user)should give some hints on the files to be updated

The network interface names may change when using dhcpcd with named network interfaces.

  • $ dmesg | grep 'renamed from eth' might help to find the new interface name
  • remove old: disable dhcpcd@enpXs0.service
  • activate new: enable dhcpcd@enpXs0.service

See also