1

Some of you will laugh, but...

I made a mistake by resizing a virtualbox vdi to 50TB instead of 50GB. Given that there's no way in vbox to shrink it back (even if the new space was untouched), i created a new vdi with the correct size of 50G and mounted them both in a ubuntu vm.

Now i think to dd from the "50TB" source onto the 50GB target, hoping that dd will stop with error when the target ends, because it is obviously smaller.

Am i correct in my assumption, or dd will overwrite my smaller target cyclically (which i don't want)?

1

Short answer:
Just leave your 50 TB VDI as it is, and enjoy it's versatility.

Long answer and explanation:
We can use dd to clone a drive bit by bit until we get an I/O error when the destination drive is full. We can also just copy a certain amount of data by using bs and count options of dd but doing any of these will not give you the desired result.

You almost certainly had your 50TB disk defined as a dynamically growing disk, and you probably made your new 50 GB dynamical too. By using dd on these drives you will actually access them. This means that in case you have unused but non-zero data blocks in your VDI there is a risk that both disks will physically grow up to the size of 50 GB.

To avoid this we should better just copy the files from the huge drive to the smaller drive, and restore the boot sector after that.

But even this may not be needed, as your virtual 50TB hard drive is only virtually of that huge size. It will only then need more physical space than your 50 GB drive after you indeed stored more than 50 GB of data there. Then you may find it even convenient to not have to grow the disk to be able to continue to use it.

| improve this answer | |
  • 1
    I proceeded with dd, everything worked fine. To your concern, vbox didnt expand the vdi with those blocks that contained only zeroes. Couldnt leave as is; 50T was too much for the os there, it was complaining "disk error", now it doesn't. – user245481 Feb 8 '14 at 3:11
  • @user245481 That's interesting indeed - it appears to be one of the many poorly understood features of virtual box ;) However in case you had non-zero blocks in the infile you will also copy them to the outfile. Then it will grow - but of course we could compress it afterwards. Thanks for this valuable information! – Takkat Feb 8 '14 at 8:04
  • well, compression (actually, compactisation) removes the zeroed blocks from the vdi image, but it turns that vbox doesnt write them in the first place. it probably only writes them when you zero a block over a previously non-zero block, and in this case you need compactization. – user245481 Feb 9 '14 at 14:46
0

What system do you have installed? If you have installed linux, you can just TAR all files, and move them on other partition.

More info here: http://tuxilero.blogspot.cz/2014/02/linux-backup-your-linux-installation.html

Back to dd. DD should stop when the target is out of space. But I think it will corrupt its MBR.

Maybe you should download gparted, and resize the partition?

If I were you, I would try to avoid dd for different size partitions...

| improve this answer | |
  • 1
    dd worked like a charm, copying everything, including the partition table (i'm not even sure if it was MBR format, and it doesn't matter, because the old vdi and the new vdi will never meet in the same vm; the old vdi will be trashed). – user245481 Feb 8 '14 at 3:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.