epretorious

Working with .ova: Converting .vmdk to LV

Sep 8th, 2015
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.18 KB | None | 0 0
  1. [root@xen-home srv]# file CentOS-6.4-i386-minimal-disk1.vmdk
  2. CentOS-6.4-i386-minimal-disk1.vmdk: VMware4 disk image
  3.  
  4. [root@xen-home srv]# qemu-img-xen convert -O raw CentOS-6.4-i386-minimal-disk1.vmdk /var/lib/libvirt/images/CentOS-6.4-i386-minimal-disk1.raw
  5.  
  6. [root@xen-home srv]# file /var/lib/libvirt/images/CentOS-6.4-i386-minimal-disk1.raw
  7. /var/lib/libvirt/images/CentOS-6.4-i386-minimal-disk1.raw:
  8. x86 boot sector; GRand Unified Bootloader, stage1 version 0x3, boot drive 0x80, 1st sector stage2 0x849e8, GRUB version 0.94; \
  9. partition 1: ID=0x83, active, starthead 32, startsector 2048, 1024000 sectors; \
  10. partition 2: ID=0x8e, starthead 221, startsector 1026048, 36722688 sectors, code offset 0x48
  11.  
  12. [root@xen-home srv]# ll /var/lib/libvirt/images/CentOS-6.4-i386-minimal-disk1.raw
  13. -rw-r--r-- 1 root root 19327352832 Sep 8 08:37 /var/lib/libvirt/images/CentOS-6.4-i386-minimal-disk1.raw
  14.  
  15. [root@xen-home srv]# lvcreate -n lv06 -L 20G vg00
  16. Logical volume "lv06" created.
  17.  
  18. [root@xen-home srv]# dd if=/var/lib/libvirt/images/CentOS-6.4-i386-minimal-disk1.raw of=/dev/vg00/lv06
  19. 37748736+0 records in
  20. 37748736+0 records out
  21. 19327352832 bytes (19 GB) copied, 1539.47 s, 12.6 MB/s
  22.  
  23. [root@xen-home srv]# kpartx /dev/vg00/lv06
  24. vg00-lv06p1 : 0 1024000 /dev/vg00/lv06 2048
  25. vg00-lv06p2 : 0 36722688 /dev/vg00/lv06 1026048
  26.  
  27. [root@xen-home srv]# kpartx -a /dev/vg00/lv06
  28.  
  29. [root@xen-home srv]# ll /dev/mapper/*p[0-9]
  30. lrwxrwxrwx 1 root root 8 Sep 8 10:43 /dev/mapper/vg00-lv06p1 -> ../dm-22
  31. lrwxrwxrwx 1 root root 8 Sep 8 10:43 /dev/mapper/vg00-lv06p2 -> ../dm-23
  32.  
  33. #The first partition contains a filesystem:
  34. [root@xen-home srv]# mount /dev/mapper/vg00-lv06p1 /mnt/One/1
  35.  
  36. # The second partition contains a PV (and, therefore, can not be mounted):
  37. [root@xen-home srv]# mount /dev/mapper/vg00-lv06p2 /mnt/One/2
  38. mount: unknown filesystem type 'LVM2_member'
  39.  
  40. [root@xen-home srv]# pvs
  41. PV VG Fmt Attr PSize PFree
  42. /dev/mapper/vg00-lv06p2 VolGroup lvm2 a-- 17.51g 0
  43. /dev/sda2 vg00 lvm2 a-- 931.01g 888.00g
  44. /dev/sdf1 lvm2 --- 512.00m 512.00m
  45. /dev/sdf2 vg00 lvm2 a-- 931.01g 863.00g
  46.  
  47. [root@xen-home srv]# pvdisplay /dev/mapper/vg00-lv06p2
  48. --- Physical volume ---
  49. PV Name /dev/mapper/vg00-lv06p2
  50. VG Name VolGroup
  51. PV Size 17.51 GiB / not usable 3.00 MiB
  52. Allocatable yes (but full)
  53. PE Size 4.00 MiB
  54. Total PE 4482
  55. Free PE 0
  56. Allocated PE 4482
  57. PV UUID St69bd-3F9e-Nf1t-MJyi-ZseV-Xjsf-iZ3iV8
  58.  
  59. [root@xen-home srv]# vgs
  60. VG #PV #LV #SN Attr VSize VFree
  61. VolGroup 1 2 0 wz--n- 17.51g 0
  62. vg00 2 10 0 wz--n- 1.82t 1.71t
  63.  
  64. # Notice that the VolGroup LV's are NOT active:
  65. [root@xen-home srv]# lvs VolGroup
  66. LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
  67. lv_root VolGroup -wi------- 16.51g
  68. lv_swap VolGroup -wi------- 1.00g
  69.  
  70. # After activating the VolGroup LV's, the LV's are visible in the /dev filesystem:
  71.  
  72. [root@xen-home srv]# lvchange -a y VolGroup/lv_root
  73.  
  74. [root@xen-home srv]# lvdisplay VolGroup/lv_root
  75. --- Logical volume ---
  76. LV Path /dev/VolGroup/lv_root
  77. LV Name lv_root
  78. VG Name VolGroup
  79. LV UUID DA53Rd-dRa3-CNRP-Jmb8-S7vl-1uAC-Anlxg0
  80. LV Write Access read/write
  81. LV Creation host, time localhost.localdomain, 2013-03-08 23:56:11 -0800
  82. LV Status available
  83. # open 0
  84. LV Size 16.51 GiB
  85. Current LE 4226
  86. Segments 1
  87. Allocation inherit
  88. Read ahead sectors auto
  89. - currently set to 256
  90. Block device 253:24
  91.  
  92. [root@xen-home srv]# ll /dev/VolGroup/lv_root
  93. lrwxrwxrwx 1 root root 8 Sep 8 11:04 /dev/VolGroup/lv_root -> ../dm-24
  94.  
  95. # related reading
  96. http://wiki.hackzine.org/sysadmin/kvm-import-ova.html
  97. http://forum.proxmox.com/threads/2634-Migration-of-VMware-image-to-KVM-on-LVM-%28raw%29
Advertisement
Add Comment
Please, Sign In to add comment