早期系统装在SSD盘上,现由于磁盘IO性能问题需要将SSD盘用作于业务。
而SSD通常容量不是很大,所以需要将操作系统挪走,系统迁移可以参考基于lvm的系统盘在线迁移
需要修改的地方为
- /etc/fstab
- /boot/efi/EFI/centos/grub.cfg
- uefi引导菜单
注:此次操作可能会导致系统无法正常引导,请保证服务器在本地,或者可以idrac远程管理
更新/etc/fstab
通常需要更新的分区有/、/boot、/boot/efi、/home,根据实际迁移情况做调整,
将原有UUID、分区路径替换为新的
[root@master192 efi]# cat /etc/fstab
#
# /etc/fstab
# Created by anaconda on Tue Apr 25 18:45:51 2023
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/centos-root / xfs defaults 0 0
UUID=ad10f048-3565-4497-8983-7d485fb805fb /boot ext4 defaults 0 0
UUID=CFE5-2B23 /boot/efi vfat umask=0077,shortname=winnt 0 0
/dev/mapper/centos-data /hdd xfs defaults 0 0
/dev/mapper/centos-ssd /data xfs defaults 0 0
#/dev/mapper/centos-home /home xfs defaults 0 0
UUID和分区路径可以通过blkid命令获取
[root@master192 efi]# blkid|grep sdb2
/dev/sdb2: UUID="ad10f048-3565-4497-8983-7d485fb805fb" TYPE="ext4" PARTLABEL="boot" PARTUUID="8026a6f7-4dd5-4f1d-8690-423ff30c02d3"
更新grub.cfg
更新grub.cfg中boot分区uuid,将ad10f048-3565-4497-8983-7d485fb805fb做全局替换
新uuid可以通过blkid获取
vi /boot/efi/EFI/centos/grub.cfg
### BEGIN /etc/grub.d/10_linux ###
menuentry 'CentOS Linux (5.4.243-1.el7.elrepo.x86_64) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-5.4.243-1.el7.elrepo.x86_64-advanced-2c04019b-a377-47ec-82c8-0eafb95d6f6a' {
load_video
set gfxpayload=keep
insmod gzio
insmod part_gpt
insmod xfs
set root='hd0,gpt2'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt2 --hint-efi=hd0,gpt2 --hint-baremetal=ahci0,gpt2 ad10f048-3565-4497-8983-7d485fb805fb
else
search --no-floppy --fs-uuid --set=root ad10f048-3565-4497-8983-7d485fb805fb
fi
linuxefi /vmlinuz-5.4.243-1.el7.elrepo.x86_64 root=/dev/mapper/centos-root ro crashkernel=auto spectre_v2=retpoline rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet mgag200.modeset=0
initrdefi /initramfs-5.4.243-1.el7.elrepo.x86_64.img
}
...
这里也可以使用sed工具替换
[root@master193 centos]# sed -i.bak 's/旧盘分区UUID/32ec2dec-ab37-4122-aaa7-a8d7d209cd80/g' /boot/efi/EFI/centos/grub.cfg
更新efi菜单
查看当前引导选项
[root@node192 ~]# efibootmgr -v
BootCurrent: 0000
Timeout: 1 seconds
BootOrder: 0000,0001,0002,0003
Boot0000* CentOS HD(1,GPT,28ba70f2-dcd1-406a-9261-a5eadf0f4b18,0x800,0x64000)/File(\EFI\centos\shimx64.efi)
Boot0001* CD/DVD Rom VenHw(b2ad3248-4f72-4950-a966-cfe5062db83a,02000000)
Boot0002* Hard Disk VenHw(b2ad3248-4f72-4950-a966-cfe5062db83a,01000000)
Boot0003* Network VenHw(b2ad3248-4f72-4950-a966-cfe5062db83a,05000000)
MirroredPercentageAbove4G: 0.00
MirrorMemoryBelow4GB: false
根据Boot0000信息创建基于sdb的引导选项
efibootmgr -c -w -L "CentosSSD" -d /dev/sdb -p 1 -l '\EFI\centos\shimx64.efi'
确认是否添加成功,却保在BootOrder第一位
[root@node192 ~]# efibootmgr -v
BootCurrent: 0000
Timeout: 1 seconds
BootOrder: 0004,0000,0001,0002,0003
Boot0000* CentOS HD(1,GPT,28ba70f2-dcd1-406a-9261-a5eadf0f4b18,0x800,0x64000)/File(\EFI\centos\shimx64.efi)
Boot0001* CD/DVD Rom VenHw(b2ad3248-4f72-4950-a966-cfe5062db83a,02000000)
Boot0002* Hard Disk VenHw(b2ad3248-4f72-4950-a966-cfe5062db83a,01000000)
Boot0003* Network VenHw(b2ad3248-4f72-4950-a966-cfe5062db83a,05000000)
Boot0004* CentosSSD HD(2,GPT,646c7bd1-9963-437f-9039-b2b26bedc858,0x5f800,0xee800)/File(\EFI\centos\shimx64.efi)
MirroredPercentageAbove4G: 0.00
MirrorMemoryBelow4GB: false
注:建议先不要移除旧的系统盘和uefi菜单,防止本次修改无法引导后,还可以用原来的进系统
清理旧系统
在确保可以正常引导后再知心清理工作:
1、移除旧系统盘,或者将对应盘符重新格式化
2、删除uefi菜单:efibootmgr -B Boot0000
参考
https://www.cnblogs.com/pipci/p/8862292.html
标签:修复,centos,efi,--,boot,dev,系统盘,Linux,root From: https://www.cnblogs.com/shn7798/p/17975594/linux-huan-xi-tong-pan-hou-yin-dao-xiu-fu