From real hardware to vm but how to get only the actual data and not all the empty space?

compiz

New Member
Dec 29, 2022
20
1
3
Hello again!
I am trying to help a friend who has an old debian 8 server, the hardware server is dying and we want to move it with its data to a vm in proxmox host.
The hard disk of the server was in raid 2TB and we copied it to an external 2tb disk with clonezilla. We tested it, it boots.

Now I connect this hdd to usb3 port in my intel nuc proxmox and run from the host:
$ lsblk | grep sd | grep disk
sdb 8:16 0 1.8T 0 disk
$ dd if=/dev/sdb of=driveImage.img bs=1M status=progress

Now this works but it tries from what I understand to make an img of 1.8TB but the actual data of the server are only 120gb.
Is there any other command to just take partitions and data and not the empty space?

Thanks in advance!
 
It also depends on your target storage. If you would use ZFS, zeroes are not written, so <ou need to fill the filesystem on your source with zeros so that you really do not have anything on the disk. Just because df shows a lot of free space, it does not mean that the space is actually filled with zeroes. Yet as you want to write a flat file (as shown by your dd command), you will need all the space that the vm disk image has.

In the end, @leesteken has a viable option, another would be not use dd, but qemu-img to create a thin file with e.g. qcow2 or just use ZFS.
 
  • Like
Reactions: leesteken
Thanks for the answers, to clarify, this nuc is my own home use and it is ZFS BUT the vm will not stay in my system. I am only trying to rip it and then I will give it back to the owner. Now the owner, I have no idea what he will use in the end as KVM. Maybe not proxmox at all.
I just try to help with the tools I have.

So far I see it is reading 1.3TB out of 1.8TB, my own storage is just 1TB of nvme ZFS storage, I have no idea where it has stored those 1.3TB -if it even did that-. And i use a lot of the 1TB storage for my own vm/lxc.
For now I will wait for it to be done and see what the output would be. As for the source, I am not willing to touch it for resize etc because the main server is nearly dead and this is only copy they have of backup. 1 misclick and I can do harm than do good! So i am just reading the data as they are.
I hoped that there might be another command to just actually read all the data and not the empty space, although I believe it will compress it in the end to make the .img and the end file will be about the 120GB which is the actual data
 
So far I see it is reading 1.3TB out of 1.8TB, my own storage is just 1TB of nvme ZFS storage, I have no idea where it has stored those 1.3TB -if it even did that-. And i use a lot of the 1TB storage for my own vm/lxc.
Maybe compressed and maybe there are actually zeros on the disk, so that ZFS can just ignore the data.

read all the data and not the empty space
The problem is that there is always data and you cannot simple deceide if it's "useful" or just "leftover".

Now to the more nasty stuff (for people not so familiar with Linux):
Another idea is to create an immuable qcow2 image on basis of the disk image, boot KVM/QEMU with a live linux and just rsync the files to a newly created VM. Now you operation on a per-file level, so you only need the space that is used according to df.
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!