我最近从 Ubuntu 升级到 Linux Mint。我已经覆盖/dev/sda2
了Ubuntu。我之前opt
从virtualization
/dev/sda1创建了两个逻辑卷。我忘记进行lvm分区元数据备份。但看起来当我安装时lvm2
,它设法恢复了这个元数据。
- 我如何将这些逻辑卷安装到
/opt
和/virtualization
? - 另外,如何
lvm2
设法恢复分区元数据?
卷组备份文件
vg1 {
id = "d0LGSW-hGoz-mc9W-nTc0-zjxc-bEgm-p3GrcT"
seqno = 3
format = "lvm2" # informational
status = ["RESIZEABLE", "READ", "WRITE"]
flags = []
extent_size = 8192 # 4 Megabytes
max_lv = 0
max_pv = 0
metadata_copies = 0
physical_volumes {
pv0 {
id = "ZuOjKi-Ya6m-ES2J-jS5P-KwsS-4H51-MUPEL7"
device = "/dev/sda1" # Hint only
status = ["ALLOCATABLE"]
flags = []
dev_size = 101810176 # 48.5469 Gigabytes
pe_start = 384
pe_count = 12427 # 48.543 Gigabytes
}
}
logical_volumes {
opt {
id = "cGkl9d-aCdR-N5Dx-U7kb-sDaG-XVWL-JRpGQS"
status = ["READ", "WRITE", "VISIBLE"]
flags = []
segment_count = 1
segment1 {
start_extent = 0
extent_count = 6400 # 25 Gigabytes
type = "striped"
stripe_count = 1 # linear
stripes = [
"pv0", 0
]
}
}
virtualization {
id = "cHHxE0-hYlf-pg3o-1fTi-ZdkC-GPJv-gYIbOx"
status = ["READ", "WRITE", "VISIBLE"]
flags = []
segment_count = 1
segment1 {
start_extent = 0
extent_count = 5888 # 23 Gigabytes
type = "striped"
stripe_count = 1 # linear
stripes = [
"pv0", 6400
]
}
}
}
}
/etc/fstab
# <file system> <mount point> <type> <options> <dump> <pass>
proc /proc proc nodev,noexec,nosuid 0 0
# / was on /dev/sda2 during installation
UUID=a499863a-0110-4a2f-9624-c128e0124836 / ext4 errors=remount-ro 0 1
# /home was on /dev/sda4 during installation
UUID=0c9bdfe0-0801-4704-b1e1-9719845f3cc3 /home ext4 defaults 0 2
# swap was on /dev/sda5 during installation
UUID=7cecc37b-4256-4c08-a47a-ea4849f768eb none swap sw 0 0
fdisk 列表
Disk /dev/sda: 128.0 GB, 128035676160 bytes
255 heads, 63 sectors/track, 15566 cylinders, total 250069680 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x742feb57
Device Boot Start End Blocks Id System
/dev/sda1 2048 101812223 50905088 83 Linux
/dev/sda2 * 101812224 160405503 29296640 83 Linux
/dev/sda3 199469054 226631679 13581313 5 Extended
/dev/sda4 160405504 199467007 19530752 83 Linux
/dev/sda5 199469056 226631679 13581312 82 Linux swap / Solaris
扫描
pvscan
PV /dev/sda1 VG vg1 lvm2 [48.54 GiB / 556.00 MiB free]
Total: 1 [48.54 GiB] / in use: 1 [48.54 GiB] / in no VG: 0 [0 ]
vgscan
Reading all physical volumes. This may take a while...
Found volume group "vg1" using metadata type lvm2
lvscan
inactive '/dev/vg1/opt' [25.00 GiB] inherit
inactive '/dev/vg1/virtualization' [23.00 GiB] inherit
答案1
LVM 不关心分区元数据。它检查块设备的内容(例如分区)是否有签名,表明该块设备是 LVM 物理卷。如果您没有删除该签名,LVM 会找到它,并且您的新发行版的脚本会自动组装可见卷。
如果您覆盖了物理卷的一部分,即使内部逻辑卷部分损坏,LVM 也可能会找到签名,从而导致部分或全部内容不可读。
逻辑卷未激活(这可能表明它们已损坏)。运行vgchange -ay vg1
以激活卷组(我认为它已经处于活动状态,因此您不需要它)并lvchange -ay vg1/opt vg1/virtualization
激活逻辑卷。然后您可以运行mount /dev/mapper/vg1-opt /opt
并mount /dev/mapper/vg1-virtualization /virtualization
挂载文件系统。
如果要将物理卷标记为已删除,请pvremove
在其上运行以擦除 LVM 签名。