{"id":442,"date":"2023-09-10T09:09:32","date_gmt":"2023-09-10T04:09:32","guid":{"rendered":"https:\/\/brainlessideas.com\/?p=442"},"modified":"2023-09-10T09:13:33","modified_gmt":"2023-09-10T04:13:33","slug":"442","status":"publish","type":"post","link":"https:\/\/brainlessideas.com\/index.php\/2023\/09\/10\/442\/","title":{"rendered":""},"content":{"rendered":"<header class=\"entry-header single\">\n<h1><\/h1>\n<h1 class=\"entry-title\"><a href=\"https:\/\/web.archive.org\/web\/20190424111423\/https:\/\/blogs.technet.microsoft.com\/enterprise_admin\/2010\/05\/13\/linux-p2v-with-dd-and-vhdtool-easy-and-cheap\/\">Linux P2V With DD and VHDTool \u2013 EASY and CHEAP!<\/a><\/h1>\n<h1>Reprint from <img loading=\"lazy\" decoding=\"async\" class=\"avatar avatar-22 photo\" src=\"https:\/\/web.archive.org\/web\/20190424111423im_\/https:\/\/secure.gravatar.com\/avatar\/59a51dbb6d9d5a7be02e649c0e8c698d?s=22&amp;d=mm&amp;r=g\" srcset=\"https:\/\/web.archive.org\/web\/20190424111423im_\/https:\/\/secure.gravatar.com\/avatar\/59a51dbb6d9d5a7be02e649c0e8c698d?s=44&amp;d=mm&amp;r=g 2x\" alt=\"avatar of johnkelbley\" width=\"22\" height=\"22\" \/><span class=\"byline\"><span class=\"author vcard\"><a class=\"url fn n profile-usercard-hover\" href=\"https:\/\/web.archive.org\/web\/20190424111423\/https:\/\/blogs.technet.microsoft.com\/enterprise_admin\/author\/johnkelbley\/\" data-profile-userid=\"\">JohnKelbley<\/a> <\/span><\/span><span class=\"posted-on posted-on-margin\"><time class=\"entry-date published updated\" datetime=\"2010-05-13T13:19:15+00:00\">May 13, 2010<\/time><\/span><\/h1>\n<hr \/>\n<\/header>\n<div class=\"entry-content single\">\n<p>So I\u2019ve been busy the last two week getting ready for TechEd (WAHOO!) where I\u2019m co-presenting two sessions this year.\u00a0 One of the sessions is all about Linux on Hyper-V.<\/p>\n<p>To get ready, I\u2019ve been working though lots of the common operational tasks including (as you know P2V) migrations.<\/p>\n<p>I mentioned to my buddy Alexander Lash (my partner in crime at TechEd 2008 where we presented a\u00a0<a href=\"https:\/\/web.archive.org\/web\/20190424111423\/http:\/\/blogs.technet.com\/tnspot\/archive\/2008\/07\/07\/technet-spotlight-on-demand-video-alexander-lash-john-kelbley-windows-server-2008-hyper-v-scripting-and-programmatic-management-for-fun-and-profit-vbs-and-powershell.aspx\" target=\"_blank\" rel=\"noopener\">great session on Hyper-V Scripting<\/a>) all the challenges of Linux P2V migrations, and he mentioned an easy way to do it using DD and VHDTool.<\/p>\n<ul>\n<li><a href=\"https:\/\/web.archive.org\/web\/20190424111423\/http:\/\/en.wikipedia.org\/wiki\/Dd_(Unix)\" target=\"_blank\" rel=\"noopener\">DD<\/a>\u00a0is common UNIX \/ Linux command that is commonly used for capturing disk images to a file.<\/li>\n<li><a href=\"https:\/\/web.archive.org\/web\/20190424111423\/http:\/\/code.msdn.microsoft.com\/vhdtool\" target=\"_blank\" rel=\"noopener\">VHDToo<\/a>l is a Windows tool for manipulating VHDs (including the nearly instantaneous creation of HUGE VHDS!).<\/li>\n<\/ul>\n<p>What I didn\u2019t know was that\u00a0<strong>VHDTool can quickly alter a binary disk image file<\/strong>\u00a0(like those created by DD)\u00a0<strong>and turn it into a VHD for Hyper-V!<\/strong><\/p>\n<p>I put DD \/ VHDTool to the test a couple of different ways this week, and wanted to share some results with you.\u00a0 Note that using DD and VHDTool ARE NOT SUPPORTED by Microsoft (but they seem to work pretty well, and the price is right!).<\/p>\n<h3>DD on Windows<a href=\"https:\/\/web.archive.org\/web\/20190424111423\/https:\/\/msdnshared.blob.core.windows.net\/media\/TNBlogsFS\/BlogFileStorage\/blogs_technet\/enterprise_admin\/WindowsLiveWriter\/LinuxP2VWithDD_CC4F\/image_2.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" title=\"image\" src=\".\/Linux P2V With DD and VHDTool \u2013 EASY and CHEAP! \u2013 John Kelbley's real life enterprise interop and administration_files\/image_thumb.png\" alt=\"image\" width=\"244\" height=\"148\" align=\"right\" border=\"0\" \/><\/a><\/h3>\n<p>My first run through was to take an existing Linux hard drive out of a system (using of course, Hanna Montanna Linux) and plugging it into one of my Hyper-V servers.<\/p>\n<p>I ran a\u00a0<a href=\"https:\/\/web.archive.org\/web\/20190424111423\/http:\/\/www.chrysocome.net\/dd\" target=\"_blank\" rel=\"noopener\">Windows version of DD<\/a>\u00a0against the disk and created a binary image file of the system.<\/p>\n<p><a href=\"https:\/\/web.archive.org\/web\/20190424111423\/https:\/\/msdnshared.blob.core.windows.net\/media\/TNBlogsFS\/BlogFileStorage\/blogs_technet\/enterprise_admin\/WindowsLiveWriter\/LinuxP2VWithDD_CC4F\/image_4.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" title=\"image\" src=\".\/Linux P2V With DD and VHDTool \u2013 EASY and CHEAP! \u2013 John Kelbley's real life enterprise interop and administration_files\/image_thumb_1.png\" alt=\"image\" width=\"244\" height=\"236\" align=\"left\" border=\"0\" \/><\/a><\/p>\n<p>One trick with the Windows version if DD is finding the right disk.\u00a0 It has a nice option to list all the drives on a system (see picture).<\/p>\n<p>Getting the drive ID right is important (slashes and all), or the process wont work.<\/p>\n<p>The actual command line I used to \u201csuck the brain\u201d out of the Linux system was pretty simple:<\/p>\n<p><span style=\"font-family: Courier New;\">dd if=\\\\?\\Device\\Harddisk1\\DR2 of=C:\\Hanna.img bs=1M &#8211;progress<\/span><\/p>\n<p>It took quite some time to copy the entire disk (empty space and all) to a new 80ish GB file, but once it was done creating the image, it took just a minute to get the VM up and running.<\/p>\n<p>I moved the image file to a better location and ran VHDtool to \u201cconvert\u201d the image:<\/p>\n<p><span style=\"font-family: Courier New;\">\u00a0VHDTool \/convert c:\\Hanna.img<a href=\"https:\/\/web.archive.org\/web\/20190424111423\/https:\/\/msdnshared.blob.core.windows.net\/media\/TNBlogsFS\/BlogFileStorage\/blogs_technet\/enterprise_admin\/WindowsLiveWriter\/LinuxP2VWithDD_CC4F\/image_6.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" title=\"image\" src=\".\/Linux P2V With DD and VHDTool \u2013 EASY and CHEAP! \u2013 John Kelbley's real life enterprise interop and administration_files\/image_thumb_2.png\" alt=\"image\" width=\"244\" height=\"71\" align=\"right\" border=\"0\" \/><\/a><\/span><\/p>\n<p>I also renamed it to a .VHD (Hyper-V only likes to define VMs using storage files named .VHD) and then defined my VM (using the converted image file).<\/p>\n<p>The VM started right up, noticing the changes to hardware (no longer having a sound card, for instance), and worked like a champ for me.<\/p>\n<h3>DD on Linux<a href=\"https:\/\/web.archive.org\/web\/20190424111423\/https:\/\/msdnshared.blob.core.windows.net\/media\/TNBlogsFS\/BlogFileStorage\/blogs_technet\/enterprise_admin\/WindowsLiveWriter\/LinuxP2VWithDD_CC4F\/image_8.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" title=\"image\" src=\".\/Linux P2V With DD and VHDTool \u2013 EASY and CHEAP! \u2013 John Kelbley's real life enterprise interop and administration_files\/image_thumb_3.png\" alt=\"image\" width=\"244\" height=\"154\" align=\"right\" border=\"0\" \/><\/a>\u00a0Direct to NTFS<\/h3>\n<p>I tried capturing an image of the same Linux system using DD on Linux.\u00a0 I Ran DD on the Linux system, and wrote the binary image file to an attached (NTFS formatted) USB drive.<\/p>\n<p>When DD was done, I plugged the USB drive into my Hyper-V host, copied over the file, ran VHDTool, and again success!<\/p>\n<p>NOTE that most commercial Linux distribution\u00a0<strong>DO NOT support reading \/ writing NTFS<\/strong>\u00a0formatted disks, making this type of image capture (direct to USB) impractical.<br \/>\n<a href=\"https:\/\/web.archive.org\/web\/20190424111423\/https:\/\/msdnshared.blob.core.windows.net\/media\/TNBlogsFS\/BlogFileStorage\/blogs_technet\/enterprise_admin\/WindowsLiveWriter\/LinuxP2VWithDD_CC4F\/image_10.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" title=\"image\" src=\".\/Linux P2V With DD and VHDTool \u2013 EASY and CHEAP! \u2013 John Kelbley's real life enterprise interop and administration_files\/image_thumb_4.png\" alt=\"image\" width=\"244\" height=\"112\" align=\"right\" border=\"0\" \/><\/a>Still, it was pretty awesome that it worked.<\/p>\n<h3>DD on Linux Over the Network<\/h3>\n<p>As I mentioned, not being able to access a common file system (like NTFS) on a USB drive from common, commercial Linux distributions is a blocker for the last process I showed.\u00a0 Yes I could have tried all sorts of other file systems, but I figured I should skip all the disk swapping that I had been doing and just use the network instead.<\/p>\n<p><a href=\"https:\/\/web.archive.org\/web\/20190424111423\/https:\/\/msdnshared.blob.core.windows.net\/media\/TNBlogsFS\/BlogFileStorage\/blogs_technet\/enterprise_admin\/WindowsLiveWriter\/LinuxP2VWithDD_CC4F\/image_16.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" title=\"image\" src=\".\/Linux P2V With DD and VHDTool \u2013 EASY and CHEAP! \u2013 John Kelbley's real life enterprise interop and administration_files\/image_thumb_7.png\" alt=\"image\" width=\"244\" height=\"96\" align=\"left\" border=\"0\" \/><\/a>I got some more help from \u201cMr. Z\u201d (mentioned in my earlier \u201c<a href=\"https:\/\/web.archive.org\/web\/20190424111423\/http:\/\/blogs.technet.com\/enterprise_admin\/archive\/2010\/04\/26\/hyper-v-linux-p2v-the-hard-way.aspx\" target=\"_blank\" rel=\"noopener\">Linux P2V The Hard Way<\/a>\u201d\u00a0 post).\u00a0 He rattled off the command line over the phone to mount a remote CIFS share so I could dump the output of DD directly on my Hyper-V host \u2013 saving a step.<\/p>\n<p>On the Linux system I mounted my share:<\/p>\n<p><span style=\"font-family: Courier New;\">mount \u2013t cifs \u2013o username=administrator \/\/192.168.0.10\/D$ \/mnt<\/span><\/p>\n<p>Then I ran DD:<a href=\"https:\/\/web.archive.org\/web\/20190424111423\/https:\/\/msdnshared.blob.core.windows.net\/media\/TNBlogsFS\/BlogFileStorage\/blogs_technet\/enterprise_admin\/WindowsLiveWriter\/LinuxP2VWithDD_CC4F\/image_18.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" title=\"image\" src=\".\/Linux P2V With DD and VHDTool \u2013 EASY and CHEAP! \u2013 John Kelbley's real life enterprise interop and administration_files\/image_thumb_8.png\" alt=\"image\" width=\"244\" height=\"86\" align=\"right\" border=\"0\" \/><\/a><\/p>\n<p><span style=\"font-family: Courier New;\">dd if=\/dev\/sda of=\/mnt\/rhel54.img<\/span><\/p>\n<p>Once it was done, I ran VHDTool and renamed the .IMG file to .VHD, defined the VM and was all set again to start my VM.<\/p>\n<p>I was of course using SELinux and now (because I did this nutty P2V) was have all sorts of consistency \u201copportunities\u201d\u00a0 in my VM.\u00a0 I had to repair my file system, reconfigure the X Server, add the Linux Integration Services (ISs \u2013 actually cheated and added them to physical server first!),\u00a0 but after that and a reboot the VM was online.<\/p>\n<h3>The Fine Print<\/h3>\n<p>Here are a few thoughts on the process, after the fact.<br \/>\nFirstly, this process\u00a0<strong>HAS ZERO SUPPORT FROM ANYONE<\/strong>!\u00a0 The process will vary somewhat based on your installation and distribution (security options, file systems, other).<\/p>\n<h5>DD \u2013 Size Matters<\/h5>\n<p>The biggest drawback to this process is the\u00a0<strong>HUGE<\/strong>\u00a0files that DD creates that must be consumed by VHDTool.\u00a0 Using PlateSpin, Tar, or another file-based process skips all the blank space on the disk.\u00a0 Still, the process is pretty simple and works reliably for me.<\/p>\n<h5>VHDTool \u2013 Size Matters in Different Way<\/h5>\n<p>VHDTool can sometimes \u201cwrap\u201d your binary image with information that Linux may not 100% understand.\u00a0 For instance, I ran it against a 320GB image I captured.\u00a0 Everything seemed to go well, and the VM booted, but the file system wouldn\u2019t mount.\u00a0 Apparently \u201cthe disk\u201d (VHD) was reporting a size of 127GB, while the file system was 300+GB (300 pounds of data in a 127 pound bag?), and the operating system took exception to this.<\/p>\n<p>The process worked for me (above) in each case because the source disk (binary image) was smaller than 127GB.\u00a0 I\u2019ll touch base with the developer folks and see if they know anything about that.<\/p>\n<p>Let\u00a0 me know what you think of this post, as well as your thoughts for additional posts.<\/p>\n<p>-John<\/p>\n<\/div>\n<p><!--more--><\/p>\n<p><!--more--><\/p>\n<p><!--more--><\/p>\n<footer class=\"entry-footer single\">\n<div class=\"tags\">Tags\u00a0<a href=\"https:\/\/web.archive.org\/web\/20190424111423\/https:\/\/blogs.technet.microsoft.com\/enterprise_admin\/tag\/backup-and-recovery\/\" rel=\"tag\">Backup and Recovery<\/a>\u00a0<a href=\"https:\/\/web.archive.org\/web\/20190424111423\/https:\/\/blogs.technet.microsoft.com\/enterprise_admin\/tag\/free\/\" rel=\"tag\">FREE<\/a>\u00a0<a href=\"https:\/\/web.archive.org\/web\/20190424111423\/https:\/\/blogs.technet.microsoft.com\/enterprise_admin\/tag\/hyper-v\/\" rel=\"tag\">Hyper-V<\/a>\u00a0<a href=\"https:\/\/web.archive.org\/web\/20190424111423\/https:\/\/blogs.technet.microsoft.com\/enterprise_admin\/tag\/linux\/\" rel=\"tag\">Linux<\/a>\u00a0<a href=\"https:\/\/web.archive.org\/web\/20190424111423\/https:\/\/blogs.technet.microsoft.com\/enterprise_admin\/tag\/p2v\/\" rel=\"tag\">P2V<\/a><\/div>\n<\/footer>\n","protected":false},"excerpt":{"rendered":"<p> Linux P2V With DD and VHDTool \u2013 EASY and CHEAP! Reprint from JohnKelbley May 13, 2010 <\/p>\n<p>So I\u2019ve been busy the last two week getting ready for TechEd (WAHOO!) where I\u2019m co-presenting two sessions this year. One of the sessions is all about Linux on Hyper-V.<\/p>\n<p>To get ready, I\u2019ve been working though lots [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-442","post","type-post","status-publish","format-standard","hentry","category-uncategorized","odd"],"_links":{"self":[{"href":"https:\/\/brainlessideas.com\/index.php\/wp-json\/wp\/v2\/posts\/442","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/brainlessideas.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/brainlessideas.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/brainlessideas.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/brainlessideas.com\/index.php\/wp-json\/wp\/v2\/comments?post=442"}],"version-history":[{"count":4,"href":"https:\/\/brainlessideas.com\/index.php\/wp-json\/wp\/v2\/posts\/442\/revisions"}],"predecessor-version":[{"id":447,"href":"https:\/\/brainlessideas.com\/index.php\/wp-json\/wp\/v2\/posts\/442\/revisions\/447"}],"wp:attachment":[{"href":"https:\/\/brainlessideas.com\/index.php\/wp-json\/wp\/v2\/media?parent=442"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/brainlessideas.com\/index.php\/wp-json\/wp\/v2\/categories?post=442"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/brainlessideas.com\/index.php\/wp-json\/wp\/v2\/tags?post=442"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}