Centos 7 - 標準ルートパーティションをLVMに移行する

Centos 7 - 標準ルートパーティションをLVMに移行する

標準ルートパーティション(xfsファイルシステムを持つCentos 7)をLVMパーティションに移行しようとしています。残念ながら、すべての試みは失敗し、再起動後にシステムが起動しません(grub2に問題があると思われます)。以下は、実行されたステップとコマンドのリストです。

  1. 新しいディスクを接続し、元のルートパーティションと同じファイルシステムとサイズで新しいLVMパーティションを作成します。

  2. 新しいディレクトリにマウント

    mount /dev/mapper/vg-root /mnt/nroot

  3. xfsdumpを使用したパーティションダンプ

    xfsdump -0uf /mnt/nroot.dump /dev/vda1

  4. パーティションを一時ディレクトリに復元する

    xfsrestore -f /mnt/nroot.dump /mnt/nroot

  5. ルートパーティションの再マウント

    umount /mnt/nroot

    mount /dev/mapper/vg-root /

    mount -o rw,remount /

  6. fstab /etc/fstabを編集し、古いUUIDを新しいルートUUIDに変更します。

  7. grub.cfgファイルを再構築してください。

    grub2-mkconfig -o /boot/grub2/grub.cfg(UUIDとマウントポイントが変更されました)

  8. 再起動

古いディスクからルートパーティションをマウントした後、オペレーティングシステムはgrubエラーのため起動しません。

助けを求め、エラーが発生する可能性があります。

ベストアンサー1

  1. たぶん最初からやり直すかもしれないので、私のOS Centos 7.3の状態は次のとおりです。

df -Thコマンド実行結果

ファイルシステムタイプ使用サイズ使用可能使用%マウント
/dev/vda1 xfs 30G 942M 30G 4% /
devtmpfs devtmpfs 901M 0 901M 0% /dev
tmpfs tmpfs 920M 0 920M 0% /dev/shm
tmpfs tmpfs 920M 17M 904M 2%/実行
tmpfs tmpfs 920M 0 920M 0% /sys/fs/cgroup
tmpfs tmpfs 184M 0 184M 0% /実行/ユーザー/1000

そしてgrub.cnfファイル

[...]
メニュー項目 'CentOS Linux(3.10.0-514.16.1.el7.x86_64) 7(コア)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10 。 0-514.16.1.el7.x86_64-advanced-29342a0b-e20f-4676-9ecf-dfdf02ef6683'{
        ビデオロード
        gfxpayload=予約済みに設定
        インスモードサポート
        insmod部分_msdos
        xfsのインストール
        ルート設定='hd0,msdos1'
        if [ x $ feature_platform_search_hint = xy ];
          検索 --no-floppy --fs-uuid --set=root --hint='hd0,msdos1' 29342a0b-e20f-4676-9ecf-dfdf02ef6683
        その他
          検索 --no-floppy --fs-uuid --set=root 29342a0b-e20f-4676-9ecf-dfdf02ef6683
        フィリピン諸島
        Linux16 /Boot/vmlinuz-3.10.0-514.16.1.el7.x86_64 root = UUID = 29342A0B-E20F-4676-9ECF-DFDF02EF6683 役割 = TTY0 CONSOLE = TTYS0,1150 NG = EN_アメリカ.UTF-8
        initrd16 /boot/initramfs-3.10.0-514.16.1.el7.x86_64.img
}
メニュー項目 'CentOS Linux(0-rescue-8bd05758fdfc1903174c9fcaf82b71ca) 7(コア)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux9 fcaf82 b71ca -アドバンス - 29342a0b-e20f-4676-9ecf-dfdf02ef6683'{
        ビデオロード
        インスモードサポート
        insmod部分_msdos
        xfsのインストール
        ルート設定='hd0,msdos1'
        if [ x $ feature_platform_search_hint = xy ];
          検索 --no-floppy --fs-uuid --set=root --hint='hd0,msdos1' 29342a0b-e20f-4676-9ecf-dfdf02ef6683
        その他
          検索 --no-floppy --fs-uuid --set=root 29342a0b-e20f-4676-9ecf-dfdf02ef6683
        フィリピン諸島
        linux16 /boot/vmlinuz-0-rescue-8bd05758fdfc1903174c9fcaf82b71ca root=UUID=29342a0b-e20f-4676-9ecf-dfdf02ef6683 ro console=t0 sole=ttyS0,1 1520 0
        initrd16 /boot/initramfs-0-rescue-8bd05758fdfc1903174c9fcaf82b71ca.img
}

[...]
  1. 次の手順では、/boot パーティションを /dev/vda1 から別のパーティションに移行しました (次のように)。https://docs.hytrust.com/DataControl/Admin_Guide-4.0/Content/Books/Admin-Guide/Linux-Root-Swap-Drive-Encryption/Creating-Boot-Partition-RHEL-CentOS-7.htm)
ファイルシステムタイプ使用サイズ使用可能使用%マウント
/dev/vda1 xfs 30G 1.1G 29G 4% /
devtmpfs devtmpfs 901M 0 901M 0% /dev
tmpfs tmpfs 920M 0 920M 0% /dev/shm
tmpfs tmpfs 920M 17M 904M 2%/実行
tmpfs tmpfs 920M 0 920M 0% /sys/fs/cgroup
/dev/vdc1 xfs 1020M 144M 877M 15% /boot
tmpfs tmpfs 184M 0 184M 0% /実行/ユーザー/1000

うまくいきます。 /boot/grub2 の grub.cnf は次のようになります。

[...]
メニュー項目 'CentOS Linux(3.10.0-514.16.1.el7.x86_64) 7(コア)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10 。 0-514.16.1.el7.x86_64-advanced-29342a0b-e20f-4676-9ecf-dfdf02ef6683'{
        ビデオロード
        gfxpayload=予約済みに設定
        インスモードサポート
        insmod部分_msdos
        xfsのインストール
        if [ x $ feature_platform_search_hint = xy ];
          検索 --no-floppy --fs-uuid --set=root b526cf02-6566-4a91-8027-13b3800d177f
        その他
          検索 --no-floppy --fs-uuid --set=root b526cf02-6566-4a91-8027-13b3800d177f
        フィリピン諸島
        linux16 /vmlinuz-3.10.0-514.16.1.el7.x86_64 root=UUID=29342a0b-e20f-4676-9ecf-dfdf02ef6683 ro console=tty0 crashkernel=auto console=tty
        initrd16 /initramfs-3.10.0-514.16.1.el7.x86_64.img
}
メニュー項目 'CentOS Linux(0-rescue-8bd05758fdfc1903174c9fcaf82b71ca) 7(コア)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux9 fcaf82 b71ca -アドバンス - 29342a0b-e20f-4676-9ecf-dfdf02ef6683'{
        ビデオロード
        インスモードサポート
        insmod部分_msdos
        xfsのインストール
        if [ x $ feature_platform_search_hint = xy ];
          検索 --no-floppy --fs-uuid --set=root b526cf02-6566-4a91-8027-13b3800d177f
        その他
          検索 --no-floppy --fs-uuid --set=root b526cf02-6566-4a91-8027-13b3800d177f
        フィリピン諸島
        linux16 /vmlinuz-0-rescue-8bd05758fdfc1903174c9fcaf82b71ca root=UUID=29342a0b-e20f-4676-9ecf-dfdf02ef6683 ro console=tty0 crash
        initrd16 /initramfs-0-rescue-8bd05758fdfc1903174c9fcaf82b71ca.img
}
if [ "x$default" = 'CentOS Linux(3.10.0-514.16.1.el7.x86_64) 7(コア)' ]; then default = 'CentOS Linux用の高度なオプション> CentOS Linux(3.10.0-514.16。1.el7.x86_64)7(コア) ';フィラデルフィア。
[...]
  1. 最後に、以前に貼り付けたすべてのコマンドを使用してLVMルートディレクトリを作成して移行しました。

追加コマンド

$マウント/dev/mapper/vg00-root/
$マウント-o rw、再インストール/
$ cp /boot/initramfs-$(uname -r).img /boot/initramfs-$(uname -r).img.$(date+%m-%d-%H%M%S).bak
$dracut-fv
$grub2-mkconfig -o /boot/grub2/grub.cfg

したがって、df -hT コマンドは以下を表示します。

ファイルシステムタイプ使用サイズ使用可能使用%マウント
/dev/mapper/vg00-root xfs 30G 2.1G 28G 7% /
devtmpfs devtmpfs 901M 0 901M 0% /dev
tmpfs tmpfs 920M 0 920M 0% /dev/shm
tmpfs tmpfs 920M 17M 904M 2%/実行
tmpfs tmpfs 920M 0 920M 0% /sys/fs/cgroup
/dev/vdc1 xfs 1020M 179M 842M 18% /boot
tmpfs tmpfs 184M 0 184M 0% /実行/ユーザー/1000

grub.cnfファイルの指示を次のように変更します。

メニュー項目 'CentOS Linux(3.10.0-514.16.1.el7.x86_64) 7(コア)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10 。 0-514.16.1.el7.x86_64-advanced-c81176da-6e61-44f0-afbc-93df72820140'{
        ビデオロード
        gfxpayload=予約済みに設定
        インスモードサポート
        LVMのインストール
        xfsのインストール
        ルート設定 = 'lvmid/T33gzF-WKVs-rUjx-Pieh-rZIU-pna5-JXF6bF/f0wezp-3C1o-03mr-CfaC-ZlAY-LyKH-Zcx8fg'
        if [ x $ feature_platform_search_hint = xy ];
          検索 --no-floppy --fs-uuid --set=root --hint='lvmid/T33gzF-WKVs-rUjx-Pieh-rZIU-pna5-JXF6bF/f0wezp-3C1o-03mr-CfaC-ZlAY-LyKH-Zcx 'c81176da-6e61-44f0-afbc-93df72820140
        その他
          検索 --no-floppy --fs-uuid --set=root c81176da-6e61-44f0-afbc-93df72820140
        フィリピン諸島
        linux16 /boot/vmlinuz-3.10.0-514.16.1.el7.x86_64 root=/dev/mapper/vg00-root ro console=tty0 crashkernel=auto console=ttyS0,115200
        initrd16 /boot/initramfs-3.10.0-514.16.1.el7.x86_64.img
}
メニュー項目 'CentOS Linux(0-rescue-8bd05758fdfc1903174c9fcaf82b71ca) 7(コア)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux9 fcaf82 b71ca -アドバンス - c81176da-6e61-44f0-afbc-93df72820140'{
        ビデオロード
        インスモードサポート
        LVMのインストール
        xfsのインストール
        ルート設定 = 'lvmid/T33gzF-WKVs-rUjx-Pieh-rZIU-pna5-JXF6bF/f0wezp-3C1o-03mr-CfaC-ZlAY-LyKH-Zcx8fg'
        if [ x $ feature_platform_search_hint = xy ];
          検索 --no-floppy --fs-uuid --set=root --hint='lvmid/T33gzF-WKVs-rUjx-Pieh-rZIU-pna5-JXF6bF/f0wezp-3C1o-03mr-CfaC-ZlAY-LyKH-Zcx 'c81176da-6e61-44f0-afbc-93df72820140
        その他
          検索 --no-floppy --fs-uuid --set=root c81176da-6e61-44f0-afbc-93df72820140
        フィリピン諸島
        linux16 /boot/vmlinuz-0-rescue-8bd05758fdfc1903174c9fcaf82b71ca root=/dev/mapper/vg00-root ro コンソール=tty0 crashkernel=自動コンソール=ttyS0,115200
        initrd16 /boot/initramfs-0-rescue-8bd05758fdfc1903174c9fcaf82b71ca.img
}
if [ "x$default" = 'CentOS Linux(3.10.0-514.16.1.el7.x86_64) 7(コア)' ]

ただし、サーバーシステムを再起動すると、以前の/rootパーティションで起動してRO状態になります。どんなアイデアがありますか?

おすすめ記事