Make a Virtualbox VM with 60GB VirtualDrive from dd image of 1TB physical machine that has only 42GB used.

Member_2_241474
Member_2_241474 used Ask the Experts™
on
Need to make a VM out of a CentOS 6 asterisk box with 3 500GB SATA drives in RAID 5.  This gives me a 1TB drive that has 42GB used.
After some googling, it looked easy to use "dd conv=sparse" but that produced a 1TB disk image.  I loaded the dive on /dev/loop0 and tired to use gparted to shrink it, but gparted said it need gpart to see inside and gparted was nowhere to be found.  (The disk image in on a Centos7 machines.)

I have used TestDisk on the image with a few different parameters but it always comes up with results that don't match fdisk -l on the original machine.  (I have attached the output.)

I was going to try Clonezilla next, but I thought I would ask some expert advise before wasting more time.

So, what is the best way to get a 1TB RAID 5 image with multiple partitions into a VirtualBox VM with only the 42G of data? (I would make a 60GB virtual drive anyway.) fisk-output.txt
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
nociSoftware Engineer
Distinguished Expert 2018

Commented:
dd conv=sparse    will skip all blocks that are filled with NUL/0/...   never the less the file size will show 1TB.  The actual storage used will show  around 42GB ish (probably more) less free space on  the disk it is copied to,,,,

I expect it to be bigger due to alle the file system infra structure needed to describe the empty space and preserved space for directories and storage bitmaps. as well as some blocks with non 0 values.
Which tells the user of the file some data.

If you want to shrink the "disk" then you need to make a copy from the machine itself.  using a tool like tar to copy the data to a new virtual disk (can be iscsi .. , FC... ) and copy the files preserving all acl's, owner info & protection.

Author

Commented:
Thank you.  I cannot zero the blocks on the physical machine as it is in production and such operations are not allowed.  Is there a way to do it on the dd image and then shrink it?  The target virtual host only has a 1 TB drive.  So I have to get from the 1TB dd image to a 42GB image that VirtualBox will load.  IFAIK tar will not produce a bootable image.  Is there a way to do that?
BTW: Gparted on the NAS ( CentOS7 where the dd image is) can load the disk image in /dev/loop0 but it sees no partitions on the LVM on the RAID drive.
nociSoftware Engineer
Distinguished Expert 2018

Commented:
You need to zero the UNUSED space.. So alloc ALL data on the 1TB disk (100% full) and the write all the data in there with zero's.
Then migrate the data to the smaller disk with conv=sparse.
Did you copy the RAW raid device? or the root file system...  Also was the device dismouted while taking the data dump?
Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

Author

Commented:
No, the disk that was dumped was live at the time.  Does that break dd?
TestDisk cannot find the proper partitions. I can shut the system down tonight long enough to image the disk, either with dd or clonezilla.  I must do this tonight however, it is the only window.  Which do you think I should use?
Software Engineer
Distinguished Expert 2018
Commented:
No it doesn't break dd  it just isn't a consistent backup as the blocks you already copied might have changed and refer to blocks you didn't yet copy.
(dd copies the root directory and some blocks,   some tool creates a new file in the root directory, dd then copies the block holding the new file's data, .. )
After dd finishes: the root directory has no reference to the file the has been created while dd is running.

Clonezilla will be faster. (as it only copies used data (if it knowns the filesystem).

Author

Commented:
Clonezilla worked by cloning the original, but also made a 1TB image that I stored on my NAS, then created VM, booted with Clonezilla and restored the 1TB image to a 120GB disk.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial