Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have hdd.img file, which I user as HDD for my virtual machine, but it's size is too small, how can I enlarge it?

There is one method, something like:

dd if=/dev/zero ds=10GB count=8 >> hdd.img

but it takes a lot of time :(

share|improve this question
    
The command you wrote will completely overwrite the original content. Is that what you want? –  eppesuig Jan 11 '13 at 11:14
    
Sorry, fixed :) –  atomAltera Jan 11 '13 at 11:31
add comment

1 Answer

up vote 6 down vote accepted

Something like that:

dd if=/dev/zero bs=1 seek=new_filesize count=0 of=your_file

For example this:

dd if=/dev/zero bs=1G seek=1000 count=0 of=test

will enlarge file test to 1000G

share|improve this answer
    
Try it on a test file. It works! All space after old file's content will be filled with "virtual" zeros (sparse file). –  Eddy_Em Jan 11 '13 at 11:51
    
Oh yes, thank you –  atomAltera Jan 11 '13 at 11:52
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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