1. Problem scenario:
The partition failed and the virtual machine was restarted, causing the system to enter the dracut page. The boot screen shows that
you can press Enter directly and wait for the restart failed page
to automatically enter dracut mode (rescue).
2. Temporary solution to enter the system
Checked it out: If the "dracut" prompt appears, enters dracut mode, or otherwise dracut emergency shell
, this may mean that the system cannot boot properly or load the root file system.
Execute the following on the shell command line:
dracut:/# lvm vgscan
dracut:/# lvm vgchange -ay
dracut:/# exit
This method can be a temporary solution to enter the system (remote SSH is also normal). But after restarting, it will still enter dracut mode.
3. Re-operate the partition expansion
Since the partition operation may be restarted before the operation is completed, resulting in partition exception and startup failure, now that you can enter the server normally, recheck the partition.
As you can see from the disk usage, the root directory is still 50G in size, which is the default size of the previously created virtual machine.
As can be seen in the figure, the total disk capacity has been expanded to 500G, which was originally 200G;
Take a look at the current disk partition situation: fdisk -l
Then use fdisk to modify the disk partition: fdisk /dev/sda
The screenshot above is the operation of adding a new partition:
# 创建分区命令
fdisk /dev/sda
再输入p
新增分区输入:n
回车(默认为主分区primary)
分区号、起始扇区、结束扇区都默认(回车)
设置分区格式 直接输入:t
分区号默认(回车)
Hex 代码为 8e (8e代表Linux LVM分区类型)
w (写入分区表)
等待分区完成
Although it prompts that the device or resource is busy, ignore this error and continue executing the command:partprobe
Then refer to: VMWare ESXI partition merging record for virtual machine hard disk expansion (CentOS7).
After configuring partitions successfully, when merging partitions: vgdisplay -v
the newly added partitions are not displayed.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>
Then operate again. After creating a new pv, the physical volume sda3 is displayed; then expand the root directory:
normal expansion is completed.
Then restart the server and find that it can start normally.