Linux中LVM磁盘更换操作不当导致的错误及修复过程记录
今天备份服务器(8.77)在替换磁盘时,新磁盘的加入和应用路径更改都很正常,但在将原磁盘从vg中删除时,由于操作失误,导致vg无法认出,以下是问题过程和解决方法:
在执行pvremove -ff /dev/sdg命令后,vg出现异常,无论vgdisplay、lvdisplay还是pvdisplay,都出现如下提示
[root@backupserver data]# vgdisplay
Couldn't find device with uuid 'q2aKwA-0pim-QRr3-4DjN-gZg9-RNk1-eHKMvZ'. Couldn't find all physical volumes for volume group stuvg.
Couldn't find device with uuid 'q2aKwA-0pim-QRr3-4DjN-gZg9-RNk1-eHKMvZ'. Couldn't find all physical volumes for volume group stuvg.
Couldn't find device with uuid 'q2aKwA-0pim-QRr3-4DjN-gZg9-RNk1-eHKMvZ'. Couldn't find all physical volumes for volume group stuvg.
Couldn't find device with uuid 'q2aKwA-0pim-QRr3-4DjN-gZg9-RNk1-eHKMvZ'. Couldn't find all physical volumes for volume group stuvg.
Couldn't find device with uuid 'q2aKwA-0pim-QRr3-4DjN-gZg9-RNk1-eHKMvZ'. Couldn't find all physical volumes for volume group stuvg.
Couldn't find device with uuid 'q2aKwA-0pim-QRr3-4DjN-gZg9-RNk1-eHKMvZ'. Couldn't find all physical volumes for volume group stuvg.
Couldn't find device with uuid 'q2aKwA-0pim-QRr3-4DjN-gZg9-RNk1-eHKMvZ'. Couldn't find all physical volumes for volume group stuvg.
Couldn't find device with uuid 'q2aKwA-0pim-QRr3-4DjN-gZg9-RNk1-eHKMvZ'. Couldn't find all physical volumes for volume group stuvg. Volume group \
说明这个pv的信息还存在vg中,但这是pv没有了,vg信息不完整,仔细分析lvm的工作原理,又在网上查找资料后,操作如下:
[root@backupserver archive]# vgdisplay --partial -vvv #查看vg中的详细信息 如果此信息中其他pv和lv的信息完整,则继续操作
Partial mode. Incomplete volume groups will be activated read-only. Processing: vgdisplay --partial -vvv O_DIRECT will be used
Setting global/locking_type to 1 File-based locking selected.
Setting global/locking_dir to /var/lock/lvm Finding all volume groups
/dev/ramdisk: Not using O_DIRECT Opened /dev/ramdisk RO
/dev/ramdisk: block size is 1024 bytes /dev/ramdisk: No label detected Closed /dev/ramdisk
Opened /dev/root RO O_DIRECT /dev/root: block size is 4096 bytes /dev/root: No label detected
Closed /dev/root
/dev/ram: Not using O_DIRECT …… ……
PV Name unknown device
PV UUID q2aKwA-0pim-QRr3-4DjN-gZg9-RNk1-eHKMvZ PV Status allocatable Total PE / Free PE 524287 / 524287
…… ……
可以看到,被删除的磁盘pvname变成了 unknown device
#cd /etc/lvm/backup #进入lvm的配置目录,查看当前vg配置信息是否正确(删除pv后的)
[root@backupserver backup]# file stuvg stuvg: ASCII text
[root@backupserver backup]# more stuvg
# Generated by LVM2 version 2.02.37-RHEL4 (2008-06-06): Mon Jul 4 09:14:14 2011
contents = \version = 1
description = \
creation_host = \ # Linux backupserver 2.6.9-78.ELlargesmp #1 SMP Wed Jul 9 16:03:59 EDT 2008 x86_64
creation_time = 1309742054 # Mon Jul 4 09:14:14 2011
stuvg {
id = \ seqno = 27
status = [\
extent_size = 8192 # 4 Megabytes max_lv = 0 max_pv = 0
physical_volumes {
pv0 {
id = \ device = \ # Hint only
status = [\
dev_size = 4294967296 # 2 Terabytes pe_start = 384
pe_count = 524287 # 2 Terabytes }
pv1 {
id = \ device = \ # Hint only
status = [\
dev_size = 4294967296 # 2 Terabytes }
pv2 {
}
pv3 {
}
pv4 {
} }
pe_start = 384
pe_count = 524287 # 2 Terabytes id = \device = \ # Hint only status = [\
dev_size = 2147518464 # 1.00002 Terabytes pe_start = 384
pe_count = 262148 # 1.00002 Terabytes id = \device = \ # Hint only status = [\
dev_size = 4294967296 # 2 Terabytes pe_start = 384
pe_count = 524287 # 2 Terabytes id = \device = \ # Hint only status = [\
dev_size = 8589934592 # 4 Terabytes pe_start = 384
pe_count = 1048575 # 4 Terabytes logical_volumes {
lv0 {
id = \ status = [\ segment_count = 1
segment1 {
start_extent = 0
extent_count = 256000 # 1000 Gigabytes
type = \
stripe_count = 1 # linear
stripes = [
\ ] } }
lv1 {
id = \ status = [\ segment_count = 1
segment1 {
start_extent = 0
extent_count = 256000 # 1000 Gigabytes
type = \
stripe_count = 1 # linear
stripes = [
\ ] } }
lv2 {
id = \ status = [\ segment_count = 1
segment1 {
start_extent = 0
extent_count = 256256 # 1001 Gigabytes
type = \
stripe_count = 1 # linear
stripes = [
\ ] } }
lv3 {
id = \ status = [\ segment_count = 1
segment1 {
start_extent = 0
extent_count = 256000 # 1000 Gigabytes
type = \
stripe_count = 1 # linear
stripes = [
\ ] } }
lv4 {
id = \ status = [\ segment_count = 1
segment1 {
start_extent = 0
extent_count = 67500 # 263.672 Gigabytes
type = \
stripe_count = 1 # linear
stripes = [
\