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,115200 n8 Crashkernel = 자동 콘솔 = TTYS0, 115200 LANG = 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 'gnulinux-0-rescue-8bd05758fdfc1903174c9fcaf82 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=tty0 console=ttyS0,115200n8 crashkernel=auto console=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=ttyS0,115200
        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 'gnulinux-0-rescue-8bd05758fdfc1903174c9fcaf82 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 crashkernel=auto console=ttyS0,115200
        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-f-v
$ 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-Zcx8fg '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 'gnulinux-0-rescue-8bd05758fdfc1903174c9fcaf82 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-Zcx8fg 'c81176da-6e61-44f0-afbc-93df72820140
        기타
          검색 --no-floppy --fs-uuid --set=root c81176da-6e61-44f0-afbc-93df72820140
        필리핀 제도
        linux16 /boot/vmlinuz-0-rescue-8bd05758fdfc1903174c9fcaf82b71ca 루트=/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 상태가 됩니다. 어떤 아이디어가 있나요?

관련 정보