Advertisement
mightyroot

ESXi recover VMs

Oct 12th, 2011
418
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 10.65 KB | None | 0 0
  1. 0. attach HDD to linux machine, and mount VMFS
  2. - vmfs-fuse
  3. - vmfs-tools
  4.  
  5. 1. recover VM system files:
  6. - Host-000001-delta.vmdk    /1st snapshot file/
  7. - Host-000004-delta.vmdk    /2nd snapshot file/  
  8. - Host-flat.vmdk            /VM's filesystem file/
  9.  
  10. 2. generate descriptor file for Host-flat.vmdk:
  11. # cd /vmfs/volumes/4b60b1fa-810d9754-167f-78e7d1f52133/Host  /where my VM was stored/
  12. # ls -la
  13. -rw-r--r--    1 root     root         4865806336 Oct 12 21:17 Host-000001-delta.vmdk
  14. -rw-r--r--    1 root     root        19445207040 Oct 12 21:51 Host-000004-delta.vmdk
  15. -rw-r--r--    1 root     root       214748364800 Oct 12 21:00 Host-flat.vmdk
  16.  
  17. # vmkfstools -c 214748364800 -a lsisata -d thin Host-tmp.vmdk
  18. ## where -c = 214748364800 size of Host-flat.vmdk in bits
  19. ## -a = type of VM's disk
  20. ## Host-tmp.vmdk - name of new vmdk file
  21.  
  22. # cp Host-tmp.vmdk Host.vmdk
  23. # vi Host.vmdk
  24. ------------# Disk DescriptorFile--------------------
  25. version=1
  26. encoding="UTF-8"
  27. CID=e4037185        <----------remember HOST.CID
  28. parentCID=ffffffff
  29. isNativeSnapshot="no"
  30. createType="vmfs"
  31.  
  32. # Extent description
  33. RW 419430400 VMFS "Host-tmp-flat.vmdk" <----------REMOVE
  34. RW 419430400 VMFS "Host-flat.vmdk" <----------ADD
  35.  
  36. # The Disk Data Base
  37. #DDB
  38.  
  39. ddb.adapterType = "lsilogic"
  40. ddb.thinProvisioned = "1"
  41. ddb.geometry.sectors = "63"
  42. ddb.geometry.heads = "255"
  43. ddb.geometry.cylinders = "26108"
  44. ddb.uuid = "60 00 C2 95 ee da b9 c4-36 67 dd 85 15 bb c6 0f"
  45. ddb.longContentID = "498a171b9bf5aab9d46bbe99e4037185"
  46. ddb.virtualHWVersion = "8"
  47. ---------------------EOF----------------------------------
  48.  
  49. # rm -r Host-tmp*         / remove temp files /
  50.  
  51. 3. create NEW VM {named: WWW} ...... add disk -> path to datastore_old/Host -> Host.vmdk
  52. 4. Power_on WWW, boot, make snapshot, shutdown
  53. 5. Edit new VM Snapshot's descriptor file - Host-000002.vmdk in cur dir:
  54. # ls -la
  55. Host-000001-delta.vmdk
  56. Host-000002-delta.vmdk
  57. Host-000002.vmdk
  58. Host-000004-delta.vmdk
  59. Host-flat.vmdk
  60. Host.vmdk
  61.  
  62. # cp Host-000002.vmdk Host-000001.vmdk
  63.  
  64. # vi Host-000001.vmdk
  65. --------------------# Disk DescriptorFile---------------------------
  66. version=1
  67. encoding="UTF-8"
  68. CID=9746bb38              <-------- remember HOST-000001.CID
  69. parentCID=e4037185        <------- HOST.CID
  70. isNativeSnapshot="no"
  71. createType="vmfsSparse"
  72. parentFileNameHint="Host.vmdk"
  73.  
  74. # Extent description
  75. RW 419430400 VMFSSPARSE "Host-000002-delta.vmdk" <----------REMOVE
  76. RW 419430400 VMFSSPARSE "Host-000001-delta.vmdk" <----------ADD
  77.  
  78. # The Disk Data Base
  79. #DDB
  80. ddb.longContentID = "b8f451b3b0c94e8c4848eeef9746bb38"
  81. --------------------------EOF-----------------------------------------
  82.  
  83. 6. Edit VM's conf files {WWW.vmx}:
  84. # cd /vmfs/volumes/4b60b1fa-810d9754-167f-78e7d1f52133/WWW
  85. # vi WWW.vmx
  86. .encoding = "UTF-8"
  87. config.version = "8"
  88. virtualHW.version = "7"
  89. pciBridge0.present = "TRUE"
  90. pciBridge4.present = "TRUE"
  91. pciBridge4.virtualDev = "pcieRootPort"
  92. pciBridge4.functions = "8"
  93. pciBridge5.present = "TRUE"
  94. pciBridge5.virtualDev = "pcieRootPort"
  95. pciBridge5.functions = "8"
  96. pciBridge6.present = "TRUE"
  97. pciBridge6.virtualDev = "pcieRootPort"
  98. pciBridge6.functions = "8"
  99. pciBridge7.present = "TRUE"
  100. pciBridge7.virtualDev = "pcieRootPort"
  101. pciBridge7.functions = "8"
  102. vmci0.present = "TRUE"
  103. nvram = "WWW.nvram"
  104. virtualHW.productCompatibility = "hosted"
  105. powerType.powerOff = "soft"
  106. powerType.powerOn = "hard"
  107. powerType.suspend = "hard"
  108. powerType.reset = "soft"
  109. displayName = "WWW"
  110. extendedConfigFile = "WWW.vmxf"
  111. floppy0.present = "TRUE"
  112. scsi0.present = "TRUE"
  113. scsi0.sharedBus = "none"
  114. scsi0.virtualDev = "lsilogic"
  115. memsize = "1024"
  116. scsi0:0.present = "TRUE"
  117.  
  118. scsi0:0.fileName = "/vmfs/volumes/4b60b1fa-810d9754-167f-78e7d1f52133/Host/Host-000002.vmdk" <--------REMOVE
  119. scsi0:0.fileName = "/vmfs/volumes/4b60b1fa-810d9754-167f-78e7d1f52133/Host/Host-000001.vmdk" <---------ADD
  120.  
  121. scsi0:0.deviceType = "scsi-hardDisk"
  122. ide1:0.present = "TRUE"
  123. ide1:0.clientDevice = "TRUE"
  124. ide1:0.deviceType = "cdrom-raw"
  125. ide1:0.startConnected = "FALSE"
  126. floppy0.startConnected = "FALSE"
  127. floppy0.fileName = ""
  128. floppy0.clientDevice = "TRUE"
  129. ethernet0.present = "TRUE"
  130. ethernet0.virtualDev = "e1000"
  131. ethernet0.networkName = "VM Network"
  132. ethernet0.addressType = "generated"
  133. guestOS = "debian5-64"
  134. uuid.location = "56 4d c2 28 8d cf d4 06-0b c5 28 82 f7 80 61 b8"
  135. uuid.bios = "56 4d c2 28 8d cf d4 06-0b c5 28 82 f7 80 61 b8"
  136. vc.uuid = "52 e5 e7 cc c7 f9 6a d7-ef 2d 69 fb 87 a0 db 99"
  137. ethernet0.generatedAddress = "00:0c:29:80:61:b8"
  138. vmci0.id = "-142581320"
  139. cleanShutdown = "FALSE"
  140. replay.supported = "FALSE"
  141. sched.swap.derivedName = "/vmfs/volumes/4b60b1fa-810d9754-167f-78e7d1f52133/WWW/WWW-cfeb4548.vswp"
  142. replay.filename = ""
  143. scsi0:0.redo = ""
  144. pciBridge0.pciSlotNumber = "17"
  145. pciBridge4.pciSlotNumber = "21"
  146. pciBridge5.pciSlotNumber = "22"
  147. pciBridge6.pciSlotNumber = "23"
  148. pciBridge7.pciSlotNumber = "24"
  149. scsi0.pciSlotNumber = "16"
  150. ethernet0.pciSlotNumber = "32"
  151. vmci0.pciSlotNumber = "33"
  152. ethernet0.generatedAddressOffset = "0"
  153. hostCPUID.0 = "0000000b756e65476c65746e49656e69"
  154. hostCPUID.1 = "000106e5001008000098e3fdbfebfbff"
  155. hostCPUID.80000001 = "00000000000000000000000128100800"
  156. guestCPUID.0 = "0000000b756e65476c65746e49656e69"
  157. guestCPUID.1 = "000106e500010800809822010febfbff"
  158. guestCPUID.80000001 = "00000000000000000000000128100800"
  159. userCPUID.0 = "0000000b756e65476c65746e49656e69"
  160. userCPUID.1 = "000106e500100800009822010febfbff"
  161. userCPUID.80000001 = "00000000000000000000000128100800"
  162. evcCompatibilityMode = "FALSE"
  163. vmotion.checkpointFBSize = "4194304"
  164. tools.remindInstall = "TRUE"
  165. -----------------------EOF--------------------------
  166.  
  167. 7. Run VM, it's  seems to boot first snapshot file old VM {Host}, make second snapshot, shutdown
  168. 8. like p.5. Edit new VM Snapshot's descriptor file - Host-000003.vmdk in cur dir:
  169. # ls -la
  170. Host-000001-delta.vmdk
  171. Host-000001.vmdk
  172. Host-000002-delta.vmdk
  173. Host-000002.vmdk
  174. Host-000003-delta.vmdk
  175. Host-000003.vmdk
  176. Host-000004-delta.vmdk
  177. Host-flat.vmdk
  178. Host.vmdk
  179.  
  180. # cp Host-000003.vmdk Host-000004.vmdk
  181.  
  182. # vi Host-000004.vmdk
  183. --------------------# Disk DescriptorFile---------------------------
  184. version=1
  185. encoding="UTF-8"
  186. CID=b722bb23              <--------HOST-000004.CID
  187. parentCID=9746bb38        <------- HOST-000001.CID
  188. isNativeSnapshot="no"
  189. createType="vmfsSparse"
  190. parentFileNameHint="Host.vmdk"
  191.  
  192. # Extent description
  193. RW 419430400 VMFSSPARSE "Host-000003-delta.vmdk" <----------REMOVE
  194. RW 419430400 VMFSSPARSE "Host-000004-delta.vmdk" <----------ADD
  195.  
  196. # The Disk Data Base
  197. #DDB
  198. ddb.longContentID = "b8f451b3b0c94e8c4848eeef9746bb38"
  199. --------------------------EOF-----------------------------------------
  200.  
  201. 9. Edit VM's conf files {WWW.vmx}:
  202. # cd /vmfs/volumes/4b60b1fa-810d9754-167f-78e7d1f52133/WWW
  203. # vi WWW.vmx
  204. ------------WWW.vmx--------------------------------
  205. .encoding = "UTF-8"
  206. config.version = "8"
  207. virtualHW.version = "7"
  208. pciBridge0.present = "TRUE"
  209. pciBridge4.present = "TRUE"
  210. pciBridge4.virtualDev = "pcieRootPort"
  211. pciBridge4.functions = "8"
  212. pciBridge5.present = "TRUE"
  213. pciBridge5.virtualDev = "pcieRootPort"
  214. pciBridge5.functions = "8"
  215. pciBridge6.present = "TRUE"
  216. pciBridge6.virtualDev = "pcieRootPort"
  217. pciBridge6.functions = "8"
  218. pciBridge7.present = "TRUE"
  219. pciBridge7.virtualDev = "pcieRootPort"
  220. pciBridge7.functions = "8"
  221. vmci0.present = "TRUE"
  222. nvram = "WWW.nvram"
  223. virtualHW.productCompatibility = "hosted"
  224. powerType.powerOff = "soft"
  225. powerType.powerOn = "hard"
  226. powerType.suspend = "hard"
  227. powerType.reset = "soft"
  228. displayName = "WWW"
  229. extendedConfigFile = "WWW.vmxf"
  230. floppy0.present = "TRUE"
  231. scsi0.present = "TRUE"
  232. scsi0.sharedBus = "none"
  233. scsi0.virtualDev = "lsilogic"
  234. memsize = "1024"
  235. scsi0:0.present = "TRUE"
  236.  
  237. scsi0:0.fileName = "/vmfs/volumes/4b60b1fa-810d9754-167f-78e7d1f52133/Host/Host-000003.vmdk" <--------REMOVE
  238. scsi0:0.fileName = "/vmfs/volumes/4b60b1fa-810d9754-167f-78e7d1f52133/Host/Host-000004.vmdk" <---------ADD
  239.  
  240. scsi0:0.deviceType = "scsi-hardDisk"
  241. ide1:0.present = "TRUE"
  242. ide1:0.clientDevice = "TRUE"
  243. ide1:0.deviceType = "cdrom-raw"
  244. ide1:0.startConnected = "FALSE"
  245. floppy0.startConnected = "FALSE"
  246. floppy0.fileName = ""
  247. floppy0.clientDevice = "TRUE"
  248. ethernet0.present = "TRUE"
  249. ethernet0.virtualDev = "e1000"
  250. ethernet0.networkName = "VM Network"
  251. ethernet0.addressType = "generated"
  252. guestOS = "debian5-64"
  253. uuid.location = "56 4d c2 28 8d cf d4 06-0b c5 28 82 f7 80 61 b8"
  254. uuid.bios = "56 4d c2 28 8d cf d4 06-0b c5 28 82 f7 80 61 b8"
  255. vc.uuid = "52 e5 e7 cc c7 f9 6a d7-ef 2d 69 fb 87 a0 db 99"
  256. ethernet0.generatedAddress = "00:0c:29:80:61:b8"
  257. vmci0.id = "-142581320"
  258. cleanShutdown = "FALSE"
  259. replay.supported = "FALSE"
  260. sched.swap.derivedName = "/vmfs/volumes/4b60b1fa-810d9754-167f-78e7d1f52133/WWW/WWW-cfeb4548.vswp"
  261. replay.filename = ""
  262. scsi0:0.redo = ""
  263. pciBridge0.pciSlotNumber = "17"
  264. pciBridge4.pciSlotNumber = "21"
  265. pciBridge5.pciSlotNumber = "22"
  266. pciBridge6.pciSlotNumber = "23"
  267. pciBridge7.pciSlotNumber = "24"
  268. scsi0.pciSlotNumber = "16"
  269. ethernet0.pciSlotNumber = "32"
  270. vmci0.pciSlotNumber = "33"
  271. ethernet0.generatedAddressOffset = "0"
  272. hostCPUID.0 = "0000000b756e65476c65746e49656e69"
  273. hostCPUID.1 = "000106e5001008000098e3fdbfebfbff"
  274. hostCPUID.80000001 = "00000000000000000000000128100800"
  275. guestCPUID.0 = "0000000b756e65476c65746e49656e69"
  276. guestCPUID.1 = "000106e500010800809822010febfbff"
  277. guestCPUID.80000001 = "00000000000000000000000128100800"
  278. userCPUID.0 = "0000000b756e65476c65746e49656e69"
  279. userCPUID.1 = "000106e500100800009822010febfbff"
  280. userCPUID.80000001 = "00000000000000000000000128100800"
  281. evcCompatibilityMode = "FALSE"
  282. vmotion.checkpointFBSize = "4194304"
  283. tools.remindInstall = "TRUE"
  284. -----------------------EOF--------------------------
  285.  
  286. #vi WWW.vmsd
  287. --------------WWW.vmsd---------------------------------
  288. .encoding = "UTF-8"
  289. snapshot.lastUID = "15"
  290. snapshot.current = "15"
  291. snapshot0.uid = "1"
  292. snapshot0.filename = "WWW-Snapshot1.vmsn"
  293. snapshot0.displayName = "1"
  294. snapshot0.description = "1"
  295. snapshot0.createTimeHigh = "306976"
  296. snapshot0.createTimeLow = "1352099533"
  297. snapshot0.numDisks = "1"
  298.  
  299. snapshot0.disk0.fileName = "/vmfs/volumes/4b60b1fa-810d9754-167f-78e7d1f52133/Host/Host.vmdk" <---- CHECK PATH
  300.  
  301. snapshot0.disk0.node = "scsi0:0"
  302. snapshot1.uid = "15"
  303. snapshot1.filename = "WWW-Snapshot2.vmsn"
  304. snapshot1.parent = "1"
  305. snapshot1.displayName = "2nd"
  306. snapshot1.description = "2nd"
  307. snapshot1.createTimeHigh = "306976"
  308. snapshot1.createTimeLow = "-1954189279"
  309. snapshot1.numDisks = "1"
  310.  
  311. snapshot1.disk0.fileName = "/vmfs/volumes/4b60b1fa-810d9754-167f-78e7d1f52133/Host/Host-000001.vmdk" <---- CHECK PATH to first snapshot file
  312.  
  313.  
  314. snapshot1.disk0.node = "scsi0:0"
  315. snapshot.numSnapshots = "2"
  316. ---------------------_EOF--------------------------------
  317.  
  318. 10. Run VM.
  319. It all ok, delete temp files: Host-000002* , Host-000003*
  320.  
  321.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement