# /etc/fstab: static file system information. # # Use 'blkid' to print the universally unique identifier for a # device; this may be used with UUID= as a more robust way to name devices # that works even if disks are added and removed. See fstab(5). # # systemd generates mount units based on this file, see systemd.mount(5). # Please run 'systemctl daemon-reload' after making changes here. # # <file system> <mount point> <type> <options> <dump> <pass> # / was on /dev/vda1 during installation UUID=1038e8c5-a0e6-4031-aab4-c664d0bcf637 / ext4 errors=remount-ro 0 1 # swap was on /dev/vda5 during installation UUID=63b700c5-f855-4754-a9ac-ce29e520ecf4 none swap sw 0 0 /dev/sr0 /media/cdrom0 udf,iso9660 user,noauto 0 0
替换/etc/fstab中的根目录挂载项的UUID为上方逻辑卷的UUID,更改完成后如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
# /etc/fstab: static file system information. # # Use 'blkid' to print the universally unique identifier for a # device; this may be used with UUID= as a more robust way to name devices # that works even if disks are added and removed. See fstab(5). # # systemd generates mount units based on this file, see systemd.mount(5). # Please run 'systemctl daemon-reload' after making changes here. # # <file system> <mount point> <type> <options> <dump> <pass> # / was on /dev/vda1 during installation UUID=65808f9c-feec-4b53-a238-68afc9675bf2 / ext4 errors=remount-ro 0 1 # swap was on /dev/vda5 during installation UUID=63b700c5-f855-4754-a9ac-ce29e520ecf4 none swap sw 0 0 /dev/sr0 /media/cdrom0 udf,iso9660 user,noauto 0 0
root@xxx:~# mount --types proc /proc /mnt/proc root@xxx:~# mount --rbind /sys /mnt/sys root@xxx:~# mount --make-rslave /mnt/sys root@xxx:~# mount --rbind /dev /mnt/dev root@xxx:~# mount --make-rslave /mnt/dev root@xxx:~# mount --rbind /run /mnt/run root@xxx:~# mount --bind /etc/resolv.conf /mnt/etc/resolv.conf
8.chroot到新的根目录并更新grub和initramfs
1 2 3 4 5 6 7 8 9 10 11 12 13 14
root@xxx:~# chroot /mnt root@xxx:/# grub-install /dev/vda Installing for i386-pc platform. Installation finished. No error reported. root@xxx:/# update-grub Generating grub configuration file ... Found linux image: /boot/vmlinuz-6.1.0-18-amd64 Found initrd image: /boot/initrd.img-6.1.0-18-amd64 Warning: os-prober will not be executed to detect other bootable partitions. Systems on them will not be added to the GRUB boot configuration. Check GRUB_DISABLE_OS_PROBER documentation entry. done root@xxx:/# update-initramfs -u -k all update-initramfs: Generating /boot/initrd.img-6.1.0-18-amd64