community.riocities.com
  • Home
  • Categories
  • Tags
  • Archives

KVM mount guest disk on host

Contents

  • Setup
  • Clean-up

Howto mount a guest LVM disk on host

Note: guest is called bup in the example

Setup¶

  1. Snapshot the guests running LVM volume (guests virtual disk)

    $ sudo lvcreate --size 100m --snapshot --name snap-bup /dev/vg_raid1/bup
    Logical volume "snap-bup" created
    
  2. Setup a loop device for the virtual disk snapshot

    $ sudo losetup -f /dev/vg_raid1/snap-bup
    /dev/loop0: [0005]:49084 (/dev/mapper/vg_raid1-snap--bup)
    
  3. Create device maps from the loop back device

    $ sudo kpartx -av /dev/loop0
    add map loop0p1 (251:16): 0 3817472 linear /dev/loop0 2048
    add map loop0p2 (251:17): 0 272386 linear /dev/loop0 3821566
    add map loop0p5 (251:18): 0 272384 251:17 2
    
  4. mount

Now you can mount a partition the the snapshot of the guest disk, example mounting partition one.

    $ sudo mount /dev/mapper/loop0p1 /mnt/ -o ro

Clean-up¶

  1. Un-mount all mounted partitions

    $ sudo umount /mnt
    ...
    
  2. Delete partition mappings

    $ sudo kpartx -dv /dev/loop0
    del devmap : loop0p5
    del devmap : loop0p2
    del devmap : loop0p1
    
  3. Detach loop device

    $ sudo losetup -d /dev/loop0
    
  4. Remove LVM snapshot

    $ sudo lvremove /dev/vg_raid1/snap-bup
    Do you really want to remove active logical volume snap-bup? [y/n]: y
    Logical volume "snap-bup" successfully removed
    

  • « Android games
  • Re part live system md+lvm »

Published

Aug 4, 2013

Author

henrik

Category

HOWTOs

Tags

  • KVM 4
  • LVM 4

Social

  • atom feed
  • rss feed
  • ipv6 ready
  • Powered by Pelican. Theme: Elegant by Talha Mansoor