block-001-list-attach-use-detach 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #!/bin/sh
  2. tmpf=`mktemp`
  3. ## === List
  4. echo 'qvm-block -l'
  5. qvm-block -l > $tmpf
  6. cat <<'END' | diff -u - $tmpf
  7. sys-net:sda STORAGE_DEVICE () 0 B
  8. dom0:sdb1 Cruzer () 3 GiB
  9. dom0:sdb Cruzer () 3 GiB
  10. END
  11. ## === Attach
  12. echo 'qvm-block -a'
  13. qvm-block -a work dom0:sdb | diff -u /dev/null -
  14. ## === List again
  15. echo 'qvm-block -l'
  16. qvm-block -l > $tmpf
  17. cat <<'END' | diff -u - $tmpf
  18. sys-net:sda STORAGE_DEVICE () 0 B
  19. dom0:sdb1 Cruzer () 3 GiB
  20. dom0:sdb Cruzer () 3 GiB (attached to 'work' as 'xvdi')
  21. END
  22. ## === Use
  23. echo 'qvm-run work fdisk'
  24. qvm-run -qp work 'su - root -c "fdisk -l /dev/xvdi"' > $tmpf
  25. cat <<'END' | diff -u - $tmpf
  26. Disk /dev/xvdi: 4022 MB, 4022337024 bytes
  27. 124 heads, 62 sectors/track, 1021 cylinders, total 7856127 sectors
  28. Units = sectors of 1 * 512 = 512 bytes
  29. Sector size (logical/physical): 512 bytes / 512 bytes
  30. I/O size (minimum/optimal): 512 bytes / 512 bytes
  31. Disk identifier: 0x3963a77b
  32. Device Boot Start End Blocks Id System
  33. /dev/xvdi1 * 62 7849447 3924693 c W95 FAT32 (LBA)
  34. END
  35. ## === Detach
  36. echo 'qvm-block -d'
  37. qvm-block -d work dom0:sdb1 | diff -u /dev/null -
  38. rm $tmpf