Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Possible Duplicate:
Drive reporting incorrect free space

Recently I've been trying to clone my hd using dd tool. Everything was ok, as cloning ntfs partitions but when it comes to ext4 - dd does a strange thing. Eg. Having 12GB partition with 4GB of free space, when im trying to clone it on the new 25GB partition it does clone it, but the data that previously was 12GB, now are 21GB with 4GB(the same amount of free space still as it was on the old partition). It happens everytime im cloning my home and root partitions (ext4). I was also trying to lower the size of the new partition, to the size of the old one, but then dd ends with error saying that there's not enough of space, which should be enough...

Anyone? What's going on?

share|improve this question

marked as duplicate by Eliah Kagan, Marco Ceppi Aug 13 '12 at 17:53

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

This older question asks the same thing, though the answers are different. So we should probably close this as a duplicate of that question, and then ask a moderator to merge the answer(s) from here into that master question. – Eliah Kagan Aug 9 '12 at 23:37

I assume you are doing something like:

sudo dd if=/dev/sda98 of=/dev/sda99

where /dev/sda98 has a size of 12GB and /dev/sda99 is 25GB in size.

Obviously these names are wrong, but you get the idea.

What you have done is to move not just the data but the entire file system, including all of its metadata describing what's free and what's used, to the new partition. It has lot's of free space but that free space hasn't been incorporated into the file system on /dev/sda99 so its hidden at the end of the partition and completely unusable.

The solution is to resize the file system located in the partition:

sudo resize2fs /dev/sda99

it works on EXT2, EXT3, and EXT4 file systems.

I'd encourage you to make a backup first, but I assume you still have the data in the original partition.

This will tell the file system to expand into all available space on the partition, incorporating the new space into the file systems's metadata so files can be stored in it.

You can't copy a bigger partition to a smaller partition with dd unless you tell it to only copy so much with the count parameter. dd does a bit for bit copy of everything in the source partition to the target partition, in this case it tries to copy all of the hidden/invisible space to the smaller partition along with the original contents. It has no idea or care about what it is copying--it needn't be a valid file system at all.

share|improve this answer
You're genious! Thank You very much, it works now :D – Piotr Kołątaj Aug 10 '12 at 10:47

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