![如何从 dd/raw/vmdk 映像挂载 LVM 卷?](https://linux22.com/image/1575236/%E5%A6%82%E4%BD%95%E4%BB%8E%20dd%2Fraw%2Fvmdk%20%E6%98%A0%E5%83%8F%E6%8C%82%E8%BD%BD%20LVM%20%E5%8D%B7%EF%BC%9F.png)
输入:硬盘的 RAW/DD 映像。fdisk -l
显示分区
fdisk -l image.dd
Disk image.dd: 15 GiB, 16106127360 bytes, 31457280 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
Disklabel type: dos
Disk identifier: 0x00093f57
Device Boot Start End Sectors Size Id Type
image-1.dd1 * 2048 499711 497664 243M 83 Linux
image-1.dd2 501758 31455231 30953474 14.8G 5 Extended
image-1.dd5 501760 31455231 30953472 14.8G 8e Linux LVM
尝试使用start-sector*sector size
(如描述在这里;通常用于安装分区)会带来错误
(„mount: /mnt/vmdisk: unknown filesystem type 'LVM2_member'.“
可以找到最充分的解决方案这里使用诸如、、lvm2
等工具;但这些工具vgscan
vgchange
lvs
没有扫描原始文件的选项对于这些卷。
那么如何才能访问Linux LVM
使用的内容mount
或者类似的东西呢?
答案1
安装 kpartx
sudo apt-get install kpartx
dev/mapper
整合使用中的卷
sudo kpartx -a -v image.dd
检查dev/mapper
你的分区
administrator@cdc-ansible:~$ ls -l /dev/mapper/
total 0
lrwxrwxrwx 1 root root 7 Nov 19 12:50 123--yourname--ewu--vg-root -> ../dm-3
lrwxrwxrwx 1 root root 7 Nov 19 12:50 123--yourname--ewu--vg-swap_1 -> ../dm-4
crw------- 1 root root 10, 236 Nov 19 07:59 control
lrwxrwxrwx 1 root root 7 Nov 19 12:50 loop2p1 -> ../dm-0
lrwxrwxrwx 1 root root 7 Nov 19 12:50 loop2p2 -> ../dm-1
lrwxrwxrwx 1 root root 7 Nov 19 12:50 loop2p5 -> ../dm-2
然后sudo lvscan
找到 lv 的名称:
sudo lvscan
ACTIVE '/dev/123--yourname--ewu--vg/root' [12.71 GiB] inherit
ACTIVE '/dev/123--yourname--ewu--vg/swap_1' [<2.00 GiB] inherit
尝试再次挂载:
sudo mount /dev/123--yourname--ewu--vg/root /mnt/rootfs
已挂载的文件系统(tada!):
ll /mnt/rootfs/
total 116
drwxr-xr-x 22 root root 4096 Oct 30 09:37 ./
drwxr-xr-x 5 root root 4096 Nov 19 12:59 ../
drwxr-xr-x 2 root root 4096 Oct 30 09:35 bin/
drwxr-xr-x 2 root root 4096 Sep 28 2015 boot/
drwxr-xr-x 4 root root 4096 Sep 28 2015 dev/
drwxr-xr-x 102 root root 12288 Oct 30 09:37 etc/
drwxr-xr-x 4 root root 4096 Nov 11 2016 home/
drwxr-xr-x 22 root root 4096 Nov 24 2017 lib/
drwxr-xr-x 2 root root 4096 Feb 2 2018 lib64/
drwx------ 2 root root 16384 Sep 28 2015 lost+found/
drwxr-xr-x 4 root root 4096 Sep 28 2015 media/
drwxr-xr-x 2 root root 4096 Nov 24 2017 mnt/
drwxr-xr-x 3 root root 4096 Aug 26 2016 opt/
drwxr-xr-x 2 root root 4096 Apr 10 2014 proc/
drwx------ 7 root root 4096 Oct 9 10:08 root/
drwxr-xr-x 2 root root 4096 Sep 28 2015 run/
drwxr-xr-x 2 root root 12288 Oct 30 09:35 sbin/
drwxr-xr-x 2 root root 4096 Jul 22 2014 srv/
drwxr-xr-x 2 root root 4096 Mar 13 2014 sys/
drwxrwxrwt 8 root root 4096 Oct 30 09:43 tmp/
drwxr-xr-x 10 root root 4096 Sep 28 2015 usr/
drwxr-xr-x 12 root root 4096 Sep 28 2015 var/
lrwxrwxrwx 1 root root 30 Oct 30 09:36 vmlinuz -> boot/vmlinuz-4.4.0-137-generic
顺便说一句,如果你来自其他镜像类型(例如 VMDK、VDI 等),请使用此链接将其转换为 DD。