1. 问题场景:
分区失败,重启了虚拟机,导致系统进入 dracut 页面。开机显示
直接回车,等待重启失败的页面
自动进入了 dracut 模式(救援)。
2. 临时解决进入系统
查了一下:如果出现 “dracut” 提示、进入 dracut 模式或者 dracut emergency shell
,这可能表示系统无法正常引导或加载根文件系统。
在shell命令行执行以下:
dracut:/# lvm vgscan
dracut:/# lvm vgchange -ay
dracut:/# exit
这种方式可以临时解决,进入系统(远程SSH 也是正常的)。但是重启之后依然会进入dracut模式。
3. 重新操作分区扩容
由于是分区操作可能没有操作完成就重启了服务器,导致分区异常,启动失败了,那现在可正常进入服务器了,就重新检查下分区。
从磁盘占用情况可以看到,root 目录还是 50G的大小,这是之前创建虚拟机默认的大小。
中可以看到,磁盘总的容量已经扩容到500G了,原来是 200G;
看下当前磁盘分区情况:fdisk -l
接着使用 fdisk 修改磁盘分区:fdisk /dev/sda
上面截图就是新增分区的操作:
# 创建分区命令
fdisk /dev/sda
再输入p
新增分区输入:n
回车(默认为主分区primary)
分区号、起始扇区、结束扇区都默认(回车)
设置分区格式 直接输入:t
分区号默认(回车)
Hex 代码为 8e (8e代表Linux LVM分区类型)
w (写入分区表)
等待分区完成
这里虽然提示设备或资源忙,忽略这个错误,继续执行 命令:partprobe
然后参考:VMWare ESXI 给虚拟机硬盘扩容记录(CentOS7) 进行分区合并。
配置分区成功后,在合并分区时:vgdisplay -v
没有显示新增的分区 sda3
[root@aikg ~]# lvm
lvm> pvcreate /dev/sda3
WARNING: ext4 signature detected on /dev/sda3 at offset 1080. Wipe it? [y/n]: yWiping ext4 signature on /dev/sda3.Physical volume "/dev/sda3" successfully created.
lvm> vgdisplay -v--- Volume group ---VG Name centosSystem ID Format lvm2Metadata Areas 1Metadata Sequence No 4VG Access read/writeVG Status resizableMAX LV 0Cur LV 3Open LV 3Max PV 0Cur PV 1Act PV 1VG Size <199.00 GiBPE Size 4.00 MiBTotal PE 50943Alloc PE / Size 50942 / 198.99 GiBFree PE / Size 1 / 4.00 MiBVG UUID 7EFuUv-WWlG-kFEM-XDWJ-niAh-iP8A-VxFGya--- Logical volume ---LV Path /dev/centos/swapLV Name swapVG Name centosLV UUID wpAfVQ-XL8j-UExO-D6dL-eud3-fLiR-sLejTpLV Write Access read/writeLV Creation host, time data-source1, 2021-03-24 14:20:04 +0800LV Status available# open 2LV Size <7.88 GiBCurrent LE 2016Segments 1Allocation inheritRead ahead sectors auto- currently set to 8192Block device 253:0--- Logical volume ---LV Path /dev/centos/homeLV Name homeVG Name centosLV UUID KeIjj6-JOO1-aAb1-7eG8-egkk-XCGu-u6FcKwLV Write Access read/writeLV Creation host, time data-source1, 2021-03-24 14:20:04 +0800LV Status available# open 1LV Size <141.12 GiBCurrent LE 36126Segments 1Allocation inheritRead ahead sectors auto- currently set to 8192Block device 253:1--- Logical volume ---LV Path /dev/centos/rootLV Name rootVG Name centosLV UUID 0038QM-K8CI-KKFz-0mdD-HyS4-S34U-xFjHL0LV Write Access read/writeLV Creation host, time data-source1, 2021-03-24 14:20:05 +0800LV Status available# open 1LV Size 50.00 GiBCurrent LE 12800Segments 1Allocation inheritRead ahead sectors auto- currently set to 8192Block device 253:2--- Physical volumes ---PV Name /dev/sda2 PV UUID wwBC0l-n45J-WPZg-frd7-8q5b-ELYx-ONQNtgPV Status allocatableTotal PE / Free PE 50943 / 1lvm>
lvm> vgdisplay -v--- Volume group ---VG Name centosSystem ID Format lvm2Metadata Areas 1Metadata Sequence No 4VG Access read/writeVG Status resizableMAX LV 0Cur LV 3Open LV 3Max PV 0Cur PV 1Act PV 1VG Size <199.00 GiBPE Size 4.00 MiBTotal PE 50943Alloc PE / Size 50942 / 198.99 GiBFree PE / Size 1 / 4.00 MiBVG UUID 7EFuUv-WWlG-kFEM-XDWJ-niAh-iP8A-VxFGya--- Logical volume ---LV Path /dev/centos/swapLV Name swapVG Name centosLV UUID wpAfVQ-XL8j-UExO-D6dL-eud3-fLiR-sLejTpLV Write Access read/writeLV Creation host, time data-source1, 2021-03-24 14:20:04 +0800LV Status available# open 2LV Size <7.88 GiBCurrent LE 2016Segments 1Allocation inheritRead ahead sectors auto- currently set to 8192Block device 253:0--- Logical volume ---LV Path /dev/centos/homeLV Name homeVG Name centosLV UUID KeIjj6-JOO1-aAb1-7eG8-egkk-XCGu-u6FcKwLV Write Access read/writeLV Creation host, time data-source1, 2021-03-24 14:20:04 +0800LV Status available# open 1LV Size <141.12 GiBCurrent LE 36126Segments 1Allocation inheritRead ahead sectors auto- currently set to 8192Block device 253:1--- Logical volume ---LV Path /dev/centos/rootLV Name rootVG Name centosLV UUID 0038QM-K8CI-KKFz-0mdD-HyS4-S34U-xFjHL0LV Write Access read/writeLV Creation host, time data-source1, 2021-03-24 14:20:05 +0800LV Status available# open 1LV Size 50.00 GiBCurrent LE 12800Segments 1Allocation inheritRead ahead sectors auto- currently set to 8192Block device 253:2--- Physical volumes ---PV Name /dev/sda2 PV UUID wwBC0l-n45J-WPZg-frd7-8q5b-ELYx-ONQNtgPV Status allocatableTotal PE / Free PE 50943 / 1lvm> pvcreate /dev/sda3Physical volume "/dev/sda3" successfully created.
lvm>
lvm> vgextend centos /dev/sda3Volume group "centos" successfully extended
lvm>
lvm> vgdisplay -v --- Volume group ---VG Name centosSystem ID Format lvm2Metadata Areas 2Metadata Sequence No 5VG Access read/writeVG Status resizableMAX LV 0Cur LV 3Open LV 3Max PV 0Cur PV 2Act PV 2VG Size 498.99 GiBPE Size 4.00 MiBTotal PE 127742Alloc PE / Size 50942 / 198.99 GiBFree PE / Size 76800 / 300.00 GiBVG UUID 7EFuUv-WWlG-kFEM-XDWJ-niAh-iP8A-VxFGya--- Logical volume ---LV Path /dev/centos/swapLV Name swapVG Name centosLV UUID wpAfVQ-XL8j-UExO-D6dL-eud3-fLiR-sLejTpLV Write Access read/writeLV Creation host, time data-source1, 2021-03-24 14:20:04 +0800LV Status available# open 2LV Size <7.88 GiBCurrent LE 2016Segments 1Allocation inheritRead ahead sectors auto- currently set to 8192Block device 253:0--- Logical volume ---LV Path /dev/centos/homeLV Name homeVG Name centosLV UUID KeIjj6-JOO1-aAb1-7eG8-egkk-XCGu-u6FcKwLV Write Access read/writeLV Creation host, time data-source1, 2021-03-24 14:20:04 +0800LV Status available# open 1LV Size <141.12 GiBCurrent LE 36126Segments 1Allocation inheritRead ahead sectors auto- currently set to 8192Block device 253:1--- Logical volume ---LV Path /dev/centos/rootLV Name rootVG Name centosLV UUID 0038QM-K8CI-KKFz-0mdD-HyS4-S34U-xFjHL0LV Write Access read/writeLV Creation host, time data-source1, 2021-03-24 14:20:05 +0800LV Status available# open 1LV Size 50.00 GiBCurrent LE 12800Segments 1Allocation inheritRead ahead sectors auto- currently set to 8192Block device 253:2--- Physical volumes ---PV Name /dev/sda2 PV UUID wwBC0l-n45J-WPZg-frd7-8q5b-ELYx-ONQNtgPV Status allocatableTotal PE / Free PE 50943 / 1PV Name /dev/sda3 PV UUID Vb7c4n-aqeD-Kwr5-gkN6-0Zoa-QZVW-gvlmfoPV Status allocatableTotal PE / Free PE 76799 / 76799lvm>
然后再次操作,新建 pv 后,才显示 sda3 这个物理卷;接着操作扩容根目录:
正常扩容完毕。
接着重启下服务器,发现可以正常启动了。