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]: y
Wiping ext4 signature on /dev/sda3.
Physical volume "/dev/sda3" successfully created.
lvm> vgdisplay -v
--- Volume group ---
VG Name centos
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 4
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 3
Open LV 3
Max PV 0
Cur PV 1
Act PV 1
VG Size <199.00 GiB
PE Size 4.00 MiB
Total PE 50943
Alloc PE / Size 50942 / 198.99 GiB
Free PE / Size 1 / 4.00 MiB
VG UUID 7EFuUv-WWlG-kFEM-XDWJ-niAh-iP8A-VxFGya
--- Logical volume ---
LV Path /dev/centos/swap
LV Name swap
VG Name centos
LV UUID wpAfVQ-XL8j-UExO-D6dL-eud3-fLiR-sLejTp
LV Write Access read/write
LV Creation host, time data-source1, 2021-03-24 14:20:04 +0800
LV Status available
# open 2
LV Size <7.88 GiB
Current LE 2016
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:0
--- Logical volume ---
LV Path /dev/centos/home
LV Name home
VG Name centos
LV UUID KeIjj6-JOO1-aAb1-7eG8-egkk-XCGu-u6FcKw
LV Write Access read/write
LV Creation host, time data-source1, 2021-03-24 14:20:04 +0800
LV Status available
# open 1
LV Size <141.12 GiB
Current LE 36126
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:1
--- Logical volume ---
LV Path /dev/centos/root
LV Name root
VG Name centos
LV UUID 0038QM-K8CI-KKFz-0mdD-HyS4-S34U-xFjHL0
LV Write Access read/write
LV Creation host, time data-source1, 2021-03-24 14:20:05 +0800
LV Status available
# open 1
LV Size 50.00 GiB
Current LE 12800
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:2
--- Physical volumes ---
PV Name /dev/sda2
PV UUID wwBC0l-n45J-WPZg-frd7-8q5b-ELYx-ONQNtg
PV Status allocatable
Total PE / Free PE 50943 / 1
lvm>
lvm> vgdisplay -v
--- Volume group ---
VG Name centos
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 4
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 3
Open LV 3
Max PV 0
Cur PV 1
Act PV 1
VG Size <199.00 GiB
PE Size 4.00 MiB
Total PE 50943
Alloc PE / Size 50942 / 198.99 GiB
Free PE / Size 1 / 4.00 MiB
VG UUID 7EFuUv-WWlG-kFEM-XDWJ-niAh-iP8A-VxFGya
--- Logical volume ---
LV Path /dev/centos/swap
LV Name swap
VG Name centos
LV UUID wpAfVQ-XL8j-UExO-D6dL-eud3-fLiR-sLejTp
LV Write Access read/write
LV Creation host, time data-source1, 2021-03-24 14:20:04 +0800
LV Status available
# open 2
LV Size <7.88 GiB
Current LE 2016
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:0
--- Logical volume ---
LV Path /dev/centos/home
LV Name home
VG Name centos
LV UUID KeIjj6-JOO1-aAb1-7eG8-egkk-XCGu-u6FcKw
LV Write Access read/write
LV Creation host, time data-source1, 2021-03-24 14:20:04 +0800
LV Status available
# open 1
LV Size <141.12 GiB
Current LE 36126
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:1
--- Logical volume ---
LV Path /dev/centos/root
LV Name root
VG Name centos
LV UUID 0038QM-K8CI-KKFz-0mdD-HyS4-S34U-xFjHL0
LV Write Access read/write
LV Creation host, time data-source1, 2021-03-24 14:20:05 +0800
LV Status available
# open 1
LV Size 50.00 GiB
Current LE 12800
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:2
--- Physical volumes ---
PV Name /dev/sda2
PV UUID wwBC0l-n45J-WPZg-frd7-8q5b-ELYx-ONQNtg
PV Status allocatable
Total PE / Free PE 50943 / 1
lvm> pvcreate /dev/sda3
Physical volume "/dev/sda3" successfully created.
lvm>
lvm> vgextend centos /dev/sda3
Volume group "centos" successfully extended
lvm>
lvm> vgdisplay -v
--- Volume group ---
VG Name centos
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 5
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 3
Open LV 3
Max PV 0
Cur PV 2
Act PV 2
VG Size 498.99 GiB
PE Size 4.00 MiB
Total PE 127742
Alloc PE / Size 50942 / 198.99 GiB
Free PE / Size 76800 / 300.00 GiB
VG UUID 7EFuUv-WWlG-kFEM-XDWJ-niAh-iP8A-VxFGya
--- Logical volume ---
LV Path /dev/centos/swap
LV Name swap
VG Name centos
LV UUID wpAfVQ-XL8j-UExO-D6dL-eud3-fLiR-sLejTp
LV Write Access read/write
LV Creation host, time data-source1, 2021-03-24 14:20:04 +0800
LV Status available
# open 2
LV Size <7.88 GiB
Current LE 2016
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:0
--- Logical volume ---
LV Path /dev/centos/home
LV Name home
VG Name centos
LV UUID KeIjj6-JOO1-aAb1-7eG8-egkk-XCGu-u6FcKw
LV Write Access read/write
LV Creation host, time data-source1, 2021-03-24 14:20:04 +0800
LV Status available
# open 1
LV Size <141.12 GiB
Current LE 36126
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:1
--- Logical volume ---
LV Path /dev/centos/root
LV Name root
VG Name centos
LV UUID 0038QM-K8CI-KKFz-0mdD-HyS4-S34U-xFjHL0
LV Write Access read/write
LV Creation host, time data-source1, 2021-03-24 14:20:05 +0800
LV Status available
# open 1
LV Size 50.00 GiB
Current LE 12800
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:2
--- Physical volumes ---
PV Name /dev/sda2
PV UUID wwBC0l-n45J-WPZg-frd7-8q5b-ELYx-ONQNtg
PV Status allocatable
Total PE / Free PE 50943 / 1
PV Name /dev/sda3
PV UUID Vb7c4n-aqeD-Kwr5-gkN6-0Zoa-QZVW-gvlmfo
PV Status allocatable
Total PE / Free PE 76799 / 76799
lvm>
然后再次操作,新建 pv 后,才显示 sda3 这个物理卷;接着操作扩容根目录:
正常扩容完毕。文章来源:https://www.toymoban.com/news/detail-745839.html
接着重启下服务器,发现可以正常启动了。文章来源地址https://www.toymoban.com/news/detail-745839.html
到了这里,关于Centos 7分区失败,进入 dracut 页面,恢复操作的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!