Virtual filesystem images: Difference between revisions

From lippmann wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
=kpartx=
=kpartx=
if you have a raw disk image, for example a disk drive for a hypervisor (raw file or vmdk) it may have multiple partitions.
if you have a raw disk image, for example a disk drive for a hypervisor it may have multiple partitions.


to quickly create devices for these you can use kpartx. after they are created you can mount these devices on your filesystem:
to quickly create devices for these you can use kpartx. after they are created you can mount these devices on your filesystem:
Line 6: Line 6:
e.g.:
e.g.:


  [root@rkvm1 select_fun]# kpartx -v -a DataONTAPv-kvm.raw
  [maarten@rkvm1 select_fun] sudo kpartx -v -a DataONTAPv-kvm.raw
  add map loop1p1 (253:3): 0 66464 linear 7:1 64
  add map loop1p1 (253:3): 0 66464 linear 7:1 64
  add map loop1p2 (253:4): 0 8390592 linear 7:1 66528
  add map loop1p2 (253:4): 0 8390592 linear 7:1 66528
Line 17: Line 17:
and these are now visible in /dev/mapper:  
and these are now visible in /dev/mapper:  


  [root@rkvm1 select_fun]# ls -lrt /dev/mapper/ |grep loop
  [maarten@rkvm1 select_fun] ls -lrt /dev/mapper/ |grep loop
  lrwxrwxrwx. 1 root root      7 Jan 29 20:12 loop1p1 -> ../dm-3
  lrwxrwxrwx. 1 root root      7 Jan 29 20:12 loop1p1 -> ../dm-3
  lrwxrwxrwx. 1 root root      7 Jan 29 20:12 loop1p2 -> ../dm-4
  lrwxrwxrwx. 1 root root      7 Jan 29 20:12 loop1p2 -> ../dm-4
Line 25: Line 25:
  lrwxrwxrwx. 1 root root      7 Jan 29 20:12 loop1p6 -> ../dm-8
  lrwxrwxrwx. 1 root root      7 Jan 29 20:12 loop1p6 -> ../dm-8
  lrwxrwxrwx. 1 root root      7 Jan 29 20:12 loop1p7 -> ../dm-9
  lrwxrwxrwx. 1 root root      7 Jan 29 20:12 loop1p7 -> ../dm-9
this does not seem to work well on vmdk images. As a result.
=mount a vmdk=
for a vmdk it seems other tools work better. qemu will do the trick
first create an ndb device
[maarten@rkvm1 select_fun] sudo modprobe nbd
now have it create the devices for the different partions
[maarten@rkvm1 select_fun] sudo  qemu-nbd -r -c /dev/nbd1 DataONTAPv.vmdk
[maarten@rkvm1 select_fun] ls -al /dev/nbd1p*
brw-rw----. 1 root disk 43, 33 Jan 29 20:21 /dev/nbd1p1
brw-rw----. 1 root disk 43, 34 Jan 29 20:21 /dev/nbd1p2
brw-rw----. 1 root disk 43, 35 Jan 29 20:21 /dev/nbd1p3
brw-rw----. 1 root disk 43, 36 Jan 29 20:21 /dev/nbd1p4
brw-rw----. 1 root disk 43, 37 Jan 29 20:21 /dev/nbd1p5
brw-rw----. 1 root disk 43, 38 Jan 29 20:21 /dev/nbd1p6
brw-rw----. 1 root disk 43, 39 Jan 29 20:21 /dev/nbd1p7

Revision as of 04:24, 30 January 2024

kpartx

if you have a raw disk image, for example a disk drive for a hypervisor it may have multiple partitions.

to quickly create devices for these you can use kpartx. after they are created you can mount these devices on your filesystem:

e.g.:

[maarten@rkvm1 select_fun] sudo kpartx -v -a DataONTAPv-kvm.raw
add map loop1p1 (253:3): 0 66464 linear 7:1 64
add map loop1p2 (253:4): 0 8390592 linear 7:1 66528
add map loop1p3 (253:5): 0 42336 linear 7:1 8457120
add map loop1p4 (253:6): 0 2 linear 7:1 8499456
add map loop1p5 (253:7): 0 3146976 linear 7:1 8500464
add map loop1p6 (253:8): 0 4196304 linear 7:1 11648448
add map loop1p7 (253:9): 0 5040 linear 7:1 15845760

and these are now visible in /dev/mapper:

[maarten@rkvm1 select_fun] ls -lrt /dev/mapper/ |grep loop
lrwxrwxrwx. 1 root root       7 Jan 29 20:12 loop1p1 -> ../dm-3
lrwxrwxrwx. 1 root root       7 Jan 29 20:12 loop1p2 -> ../dm-4
lrwxrwxrwx. 1 root root       7 Jan 29 20:12 loop1p3 -> ../dm-5
lrwxrwxrwx. 1 root root       7 Jan 29 20:12 loop1p4 -> ../dm-6
lrwxrwxrwx. 1 root root       7 Jan 29 20:12 loop1p5 -> ../dm-7
lrwxrwxrwx. 1 root root       7 Jan 29 20:12 loop1p6 -> ../dm-8
lrwxrwxrwx. 1 root root       7 Jan 29 20:12 loop1p7 -> ../dm-9

this does not seem to work well on vmdk images. As a result.

mount a vmdk

for a vmdk it seems other tools work better. qemu will do the trick

first create an ndb device

[maarten@rkvm1 select_fun] sudo modprobe nbd

now have it create the devices for the different partions

[maarten@rkvm1 select_fun] sudo  qemu-nbd -r -c /dev/nbd1 DataONTAPv.vmdk
[maarten@rkvm1 select_fun] ls -al /dev/nbd1p*

brw-rw----. 1 root disk 43, 33 Jan 29 20:21 /dev/nbd1p1 brw-rw----. 1 root disk 43, 34 Jan 29 20:21 /dev/nbd1p2 brw-rw----. 1 root disk 43, 35 Jan 29 20:21 /dev/nbd1p3 brw-rw----. 1 root disk 43, 36 Jan 29 20:21 /dev/nbd1p4 brw-rw----. 1 root disk 43, 37 Jan 29 20:21 /dev/nbd1p5 brw-rw----. 1 root disk 43, 38 Jan 29 20:21 /dev/nbd1p6 brw-rw----. 1 root disk 43, 39 Jan 29 20:21 /dev/nbd1p7