Advertisement
peetaur

qemu-nbd and nbd-client for qcow2 differential disk

Jun 18th, 2014
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.79 KB | None | 0 0
  1. Experiment: Same with a read only LV:
  2.     # make new rw LV
  3.     lvcreate -n testqemudiff -L 10G testvg
  4.    
  5.     # put some sample files there
  6.     mkfs.ext4 -m 0 /dev/testvg/testqemudiff
  7.     mount /dev/testvg/testqemudiff /mnt/test
  8.     cp ~/archive/software/openSUSE/openSUSE-12.2-KDE-LiveCD-x86_64.iso /mnt/test
  9.     umount /mnt/test
  10.    
  11.     # make it ro
  12.     lvchange -p r testvg/testqemudiff
  13.  
  14.     # verify it is read only
  15.     dd if=/dev/zero of=/dev/testvg/testqemudiff bs=1 count=1
  16.         dd: failed to open ‘/dev/testvg/testqemudiff’: Read-only file system
  17.  
  18.     qemu-img create -b /dev/testvg/testqemudiff -f qcow2 testqemudiff.qcow2
  19.         Formatting 'testqemudiff.qcow2', fmt=qcow2 size=10737418240 backing_file='/dev/testvg/testqemudiff' encryption=off cluster_size=65536 lazy_refcounts=off
  20.    
  21.     # try using the differential disk
  22.    
  23.     # start the nbd server (wrong way to do it for qcow2 ... this exports it raw)
  24.         modprobe nbd
  25.         zypper install nbd
  26.         cp /etc/nbd-server/config{.example,}
  27.         vim /etc/nbd-server/config
  28.             [generic]
  29.                 # comment out the user and group
  30.                 # or create the user and group, and make sure the user can access the exported files
  31.                
  32.                 listenaddr = 127.0.0.1
  33.             [export1]
  34.                 exportname = /home/peter/tmp/qemu-base-disk/testqemudiff.qcow2
  35.         /etc/init.d/nbd-server start
  36.        
  37.         # start the nbd client
  38.         nbd-client localhost -N export1 /dev/nbd0
  39.  
  40.         # doesn't work ... this doesn't translate the qcow2 file into a raw
  41.  
  42.     # start using qemu-nbd (the right way to use qcow2)
  43.     qemu-nbd -b 127.0.0.1 testqemudiff.qcow2
  44.         (let it chill or nohup / bg it / whatever)
  45.     nbd-client localhost 10809 /dev/nbd0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement