编辑 1:只是为了澄清没有数据写入新的扩展区。我知道这一点是因为管理员在执行 lvextend 后立即使用 fdisk 扩展了文件系统,然后他重新启动以使更改生效。重新启动后,新的块设备丢失了。
以下是系统管理员所做的事情。
添加了一个新的块设备,然后他将新的块设备添加到现有的卷组,然后他决定在卷组上执行 lvextend:
vgextend archive1-retain /dev/sdd1
lvextend -l +31 /dev/archive1-retain/data
本质上是用新的物理卷扩展卷组。然后他重新启动,不知何故丢失了新的物理卷成员 (sdd1)。但是逻辑卷已安装,所有数据看起来完好无损。
我确信在意外添加第二个逻辑盘区 (sdd1) 后,实际上没有任何东西将任何数据写入卷组。这是我留下的,请注意第二个逻辑盘区上的未知(丢失)设备,这是可以预料到的:
archive1:~ # lvdisplay -am
/dev/archive1-retain/data: read failed after 0 of 512 at 4400059711488: Input/output error
/dev/archive1-retain/data: read failed after 0 of 512 at 4400059768832: Input/output error
Couldn't find device with uuid W0btGW-Zp3R-yoAC-dkow-PabM-1Vri-3VUQo1.
--- Logical volume ---
LV Name /dev/archive1-retain/data
VG Name archive1-retain
LV UUID fLG6tU-6tla-h49c-KOf2-LIAh-uIFy-wH0XB5
LV Write Access read/write
LV Creation host, time archive1, 2015-06-12 11:50:30 -0700
LV Status available
# open 1
LV Size 4.00 TiB
Current LE 65566
Segments 2
Allocation inherit
Read ahead sectors auto
- currently set to 1024
Block device 253:3
--- Segments ---
Logical extent 0 to 65534:
Type linear
Physical volume /dev/sda
Physical extents 0 to 65534
Logical extent 65535 to 65565:
Type linear
Physical volume unknown device
Physical extents 0 to 30
这是我尝试的方法。回想起来,我不应该使用 --force,但幸运的是,当时卷已安装:
archive1:~ # vgreduce archive1-retain --removemissing
/dev/archive1-retain/data: read failed after 0 of 512 at 4400059711488: Input/output error
/dev/archive1-retain/data: read failed after 0 of 512 at 4400059768832: Input/output error
Couldn't find device with uuid W0btGW-Zp3R-yoAC-dkow-PabM-1Vri-3VUQo1.
WARNING: Partial LV data needs to be repaired or removed.
There are still partial LVs in VG archive1-retain.
To remove them unconditionally use: vgreduce --removemissing --force.
Proceeding to remove empty missing PVs.
archive1:~ # vgreduce archive1-retain --removemissing --force
/dev/archive1-retain/data: read failed after 0 of 512 at 4400059711488: Input/output error
/dev/archive1-retain/data: read failed after 0 of 512 at 4400059768832: Input/output error
Couldn't find device with uuid W0btGW-Zp3R-yoAC-dkow-PabM-1Vri-3VUQo1.
Removing partial LV data.
device-mapper: remove ioctl on failed: Device or resource busy
device-mapper: remove ioctl on failed: Device or resource busy
device-mapper: remove ioctl on failed: Device or resource busy
device-mapper: remove ioctl on failed: Device or resource busy
device-mapper: remove ioctl on failed: Device or resource busy
device-mapper: remove ioctl on failed: Device or resource busy
device-mapper: remove ioctl on failed: Device or resource busy
device-mapper: remove ioctl on failed: Device or resource busy
device-mapper: remove ioctl on failed: Device or resource busy
device-mapper: remove ioctl on failed: Device or resource busy
device-mapper: remove ioctl on failed: Device or resource busy
device-mapper: remove ioctl on failed: Device or resource busy
device-mapper: remove ioctl on failed: Device or resource busy
device-mapper: remove ioctl on failed: Device or resource busy
device-mapper: remove ioctl on failed: Device or resource busy
device-mapper: remove ioctl on failed: Device or resource busy
device-mapper: remove ioctl on failed: Device or resource busy
Unable to deactivate archive1--retain-data (253:3)
Unable to deactivate logical volume "data"
一些附加信息:
archive1:~ # lsblk
NAME MAJ:MIN RM SIZE RO MOUNTPOINT
xvdb 202:16 0 249G 0
└─xvdb1 202:17 0 249G 0 /var/log/retain-tomcat7
xvda 202:0 0 80G 0
├─xvda1 202:1 0 2G 0 [SWAP]
└─xvda2 202:2 0 78G 0 /
sda 8:0 0 4T 0
└─archive1--retain-data (dm-3) 253:3 0 4T 0 /var/opt/beginfinite/retain
sdc 8:32 0 750G 0
└─gwsystem-data (dm-0) 253:0 0 750G 0 /gwsystem
sdb 8:16 0 1T 0
└─archive1--sql-data (dm-1) 253:1 0 1024G 0 /var/lib/mysql
archive1--retain-data-missing_1_0 (dm-2) 253:2 0 2G 0
└─archive1--retain-data (dm-3) 253:3 0 4T 0 /var/opt/beginfinite/retain
逻辑卷已挂载并可用:
archive1:~ # df -h
Filesystem Size Used Avail Use% Mounted on
/dev/xvda2 77G 35G 41G 46% /
udev 19G 120K 19G 1% /dev
tmpfs 19G 0 19G 0% /dev/shm
/dev/xvdb1 246G 62G 172G 27% /var/log/retain-tomcat7
/dev/mapper/gwsystem-data 739G 590G 112G 85% /gwsystem
/dev/mapper/archive1--sql-data 1.0T 330G 695G 33% /var/lib/mysql
/dev/mapper/archive1--retain-data 4.0T 2.9T 1.2T 73% /var/opt/beginfinite/retain
答案1
卸载你的 FS 后,我会这样做:
步骤 1 -vgcfgrestore -l
识别文件是否具有正确的 lvm 元数据(sdd1 扩展名之前的元数据)
第 2 步 -vgcfgrestore -f filename
实际恢复旧的 lvm 元数据