dd to ignore empty space of raw files

tincboy

Renowned Member
Apr 13, 2010
466
3
83
Sometimes when I can't copy a KVM based VM's raw file ( because of badsectors ) I use the below dd command to copy raw file to new drive and also ignore the bad blocks.
Code:
dd if=/var/lib/vz/images/100/100.raw of=/newdisk/100/100.raw bs=4k conv=noerror,sync
Using the `ls -hs` on original raw file shows a lot less size than the one which is made by dd command,I guess it's because dd will also write zero ( empty spaces of the raw file ) which is unnessary,So anyone familiar with dd and this situation knows how to ask dd not writing zero blocks?
 
Last edited:
I don't know if block size is important in such scenario, but two disks has the same block size.
 
cp can't be used in such scenario because when cp hits the first badsector it will show an I/O error and abort the process of copying the file, while dd will continue and ignores the badblock
 
cp can't be used in such scenario because when cp hits the first badsector it will show an I/O error and abort the process of copying the file, while dd will continue and ignores the badblock

Hi,
has nothing to do with the subject, but if I have an damaged hdd I use ddrescue to copy the data (jump over defective blocks, reduce the bs at trouble and can startet to recover backwards (if the error at the beginning of the disk)).

But this is only for "pc-hdds". On the server this is prevented through an raid-controller - mean, I never need this in the proxmox-environment!
If I need this here, there was something wrong.

Udo
 

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!