再インストールせずにアーキテクチャを移行

提供: ArchWiki
2015年2月17日 (火) 17:34時点におけるKusakata (トーク | 投稿記録)による版 (ページの作成:「Category:Arch の入手とインストール en:Migrate installation to new hardware fr:Migration 64 bits zh-CN:Migrating Between Architectures Without Rein...」)
(差分) ← 古い版 | 最新版 (差分) | 新しい版 → (差分)
ナビゲーションに移動 検索に移動

このページではインストール済みの環境を i686 (32ビット) と x86_64 (64ビット) アーキテクチャで行き来する2つの方法を解説しています。どちらの方法でもシステム全体の再インストールは行いません。片方はライブ CD を使い、もう片方はシステムの中から移行を実行します。

警告: Unless explicitly stated, all these methods are untested and may irreparably damage your system. Continue at your own risk.

準備

64ビットアーキテクチャの確認

x86_64 を使っていて i686 をインストールしたいという場合は問題ないのでこのステップはスキップしてかまいません。

64ビットのソフトウェアを動かすには64ビット対応の CPU を使用する必要があります。最近のほとんどの CPU は64ビットソフトウェアの実行に対応しています。次のコマンドを使って CPU を確認できます:

grep --color '\<lm\>' /proc/cpuinfo

x86_64 をサポートしている CPU の場合、lm フラグ (“long mode”) が返ってきます。lahf_lm は別のフラグであり64ビット対応とは関係ないので注意してください。

ディスク容量

移行を行うと /var/cache/pacman/pkg のサイズが約2倍になるので、十分な容量を確保してください。ただし、pacman -Sc を最近実行していて、インストールしているパッケージしかキャッシュに存在しない場合です。それぞれのパッケージの i686 バージョンと x86_64 バージョンが重複するのでディスク容量が増えます。

ディスクに十分な容量がない場合は、gparted を使って適切なパーティションをリサイズするか、他のパーティションに /var/cache/pacman をマウントしてください。

システムが新しいアーキテクチャで完全に動作するようになるまでは、古いアーキテクチャのパッケージをキャッシュから削除するのは止めてください。急いでパッケージを削除してしまうと、変更を元に戻せなくなってしまいます。

電源

移行には大変時間がかかります。バッテリー不足で移行中に電源が切れてしまう可能性もあります。インストールしているパッケージの量やインターネット接続の速度にもよりますが、最低でも1時間は見積もっておいてください (実際に移行を始める前にパッケージをあらかじめダウンロードしておくことは可能です)。安定した電源に接続してください。できればフェイルオーバーやバッテリーのバックアップがあると良いでしょう。

フォールバックパッケージ

移行が途中で失敗したときに、役に立つパッケージがあります。ただし、メインのパッケージの移行を行う前にインストールする必要があります。詳しくは下の #トラブルシューティング を見てください。

一つは busybox であり、変更を戻すのに使うことができます。静的リンクされるのでライブラリには全く依存しません。32ビット (i686) バージョンをインストールしてください。

もう一つは Multilib x86_64 リポジトリの lib32-glibc です。32ビットから移行するときだけ役に立ちます。64ビットから移行する場合はこのパッケージは必要ありません。このパッケージを使って /lib/ld-linux.so.2 を呼び出すことで32ビットのプログラムを実行することが可能です。

方法 1: Arch LiveCD を使う

  1. 64ビットの Arch ISO LiveCD をダウンロードして書き込み、起動してください
  2. Configure your network on the LiveCD, then pacman to use your new architecture repos
  3. Mount your existing installation to /mnt directory. For example: mount /dev/sda1 /mnt
  4. Use the following script to update the local pacman database, get a list of all your installed packages and then reinstall them.
  5. You should probably run the script twice, because many packages fail to run their post-install scripts first time. This is due to sed, grep, perl, etc. being of the wrong architecture.
  6. You might also need to update the initrd, chroot into /mnt and run mkinitcpio -p linux.
#!/bin/bash

MOUNTED_INSTALL='/mnt'
TEMP_FILE='/tmp/packages.list'

pacman --root $MOUNTED_INSTALL -Sy
pacman --root $MOUNTED_INSTALL --cachedir $MOUNTED_INSTALL/var/cache/pacman/pkg --noconfirm -Sg base base-devel
pacman --root $MOUNTED_INSTALL -Qq > $TEMP_FILE
for PKG in $(cat $TEMP_FILE) ; do
   pacman --root $MOUNTED_INSTALL --cachedir $MOUNTED_INSTALL/var/cache/pacman/pkg --noconfirm -S $PKG
done

exit 0

After rebooting to your new 64-bit system, run this command to find out what 32-bit binaries you still have and reinstall them:

find /usr/bin -type f -exec bash -c 'file {} | grep 32-bit' \;

方法 2: 既存のシステムから

先に進む前にシステムが完全にアップデートされていることを確認してください:

# pacman -Syu

パッケージの準備

古いパッケージをキャッシュ

ノート: If you have any packages installed from the AUR or third-party repositories without new architecture availability, pacman will let you know it cannot find a suitable replacement. Make a list of these packages so you may re-install them after the update process and then remove them using pacman -Rsn package_name.

インストールしているパッケージをキャッシュに保存していない場合は、フォールバック用にダウンロードしてください (前のアーキテクチャ)。

# pacman -Qqn | pacman -Sw -

もしくは pacman パッケージの bacman を使ってキャッシュを生成してください。

busybox のインストール

32ビットから64ビットに移行する場合は、ここで32ビットの busybox をインストールします。

# pacman -S busybox

Pacman のアーキテクチャを変更

/etc/pacman.conf ファイルを編集して Architectureauto から移行先のアーキテクチャに変更してください。以下の sed コマンドを使うことができます:

x86_64 の場合:

# sed -i  '/^Architecture =/s/auto/x86_64/' /etc/pacman.conf

i686 の場合:

# sed -i  '/^Architecture =/s/auto/i686/' /etc/pacman.conf

Make sure the server lists in /etc/pacman.conf and /etc/pacman.d/mirrorlist use $arch instead of explicitly specifying i686 or x86_64. Now force Pacman to synchronize with the new repositories:

# pacman -Syy                     # force sync new architecture repositories

新しいパッケージのダウンロード

現在インストールしているパッケージの新しいアーキテクチャのバージョンを全てダウンロード:

# pacman -Sw $(pacman -Qqn|sed '/^lib32-/ d')  # download new package versions

32ビットに移行する場合は、Pacman が32ビットアーキテクチャに設定されている今ここでフォールバック用の32ビットの busybox をインストールしてください。

警告: Don't install the lib32-glibc package now. After a ldconfig, when you install linux, the generated image will have libraries like librt.so in '/usr/lib32, where binaries during boot won't search, resulting in a boot failure.

パッケージのインストール

カーネルのインストール (64ビット)

Upgrading the kernel to 64 bits (x86_64) is safe and straightforward: 32 bit and 64 bit applications run equally well under a 64-bit kernel. For migration away from 64 bits, leave the 64-bit kernel installed and running for now and skip this step.

Install the linux package.

# pacman -S linux

lib32-glibc のインストール

Install the lib32-glibc fallback. You will need to add the multilib repository in /etc/pacman.conf if you have not done so already.

# pacman -S lib32-glibc
ノート: If this fails due to an existing file from a differently named package, use pacman's --force option.

再起動

Verify that you are running the x86_64 architecture:

$ uname -m
x86_64

コンソール端末に切り替え

Switch to a text-mode virtual console (e.g. Ctrl+Alt+F1) for the rest of the process, if possible. If you receive an error trying to use the 1st console, use the 2nd one (Ctrl-Alt+F2) instead. Pseudo-terminals like SSH should work, but direct access is recommended as a precaution. There will be several packages removed and replaced during the update process that may cause X11 desktops to become unstable and leave your system in an unbootable state.

Pacman のインストール

警告: Once you start updating pacman and its dependencies it must not be interrupted! Pacman and all of its dependencies must be installed at the same time in a single command line.
警告: Immediately following this command only Busybox, Bash and Pacman will be executable until the other packages are migrated below. If you're using sudo, you should obtain root previlige prior to next command

pactree を使って Pacman と依存パッケージをインストールしてください:

# pactree -l pacman | pacman -S -

Errors may be printed but they will not cause a problem as long as Pacman works.

警告: You must not reboot your system until the following commands have been completed. If you failed to do so, you should continue installing by chrooting from another linux environment(e.g. from live install medium)

残りのパッケージのインストール

新しいアーキテクチャ用にダウンロードしておいたパッケージを全てインストールしてください (お酒を取りに行ってサンドイッチを作りましょう、このコマンドは時間がかかります):

# pacman -Qqn | pacman -S -

If some packages didn't install correctly, you should now be able to reinstall them successfully; if you're lazy, you can just re-run the last command to reinstall everything.

For migration away from 64 bits, you may want to skip installing a 32-bit kernel in the commands above, since the old 64-bit kernel will still run 32-bit programs.

After this step the migration in either direction should be complete and it should be safe to reboot the computer.

However, if you have any AUR packages on your system, you must reinstall all of them. A list of those can be obtained by executing:

$ pacman -Qqm

仕上げ

You are now free to remove busybox and lib32-glibc.

Makepkg コンパイラフラグ

During the upgrade the new version of /etc/makepkg.conf may be stored as /etc/makepkg.conf.pacnew. If so, you will have to replace the old version or modify it in order to compile anything with makepkg in the future.

# mv /etc/makepkg.conf /etc/makepkg.conf.backup && mv /etc/makepkg.conf.pacnew /etc/makepkg.conf

It might also be a good idea to just get a list of "new" additions to /etc. You can get a list with the following command:

# find /etc/ -type f -name \*.pac\*

トラブルシューティング

During the upgrade, when glibc is replaced by the new architecture version, old architecture versions of many programs will not run. If problems occur, you can solve them with busybox and lib32-glibc.

Busybox

In Arch, Busybox is statically linked; it can run without any libraries. There are many commands available to you. For example, to extract an i686 version of Pacman from a cached package:

# busybox tar xf /var/cache/pacman/pkg/pacman-3.3.2-1-i686.pkg.tar.gz -C <some folder>

Lib32-glibc

Example run 32 bit /bin/ls:

# /lib/ld-linux.so.2 /bin/ls

32ビットから64ビットに移行後 KDE が起動しない

KDE will crash when starting after switching from 32bit to 64bit. The cause are some leftover cached files from the 32 bit KDE packages in /var/tmp To fix this remove all kdecache folders in with

# rm -rf /var/tmp/kdecache-*

Mutt issues with cache enabled

If, after completion, you find that mutt hangs on opening mail folders, try renaming the cache directory. If this works, the renamed one can be deleted as mutt will have recreated a new one.

参照