Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have used gparted to reduce the partition size of a 4.01GB CF card down to 3.5GB in order to allow me to clone it using DD, the remaining amount at the end of this disk is free space and the resize was successful.

Problem is, when I use dd to save to an image file, the image that is created is still 4.01GB and has not shrunk.

I have checked several times, and the partition has definitely been shrunk !

What am I doing wrong ??

share|improve this question

1 Answer 1

You are probably copying the entire device (i.e. /dev/sdX) instead of just copying the partition (i.e. /dev/sdX1). Which is not entirely wrong, if you want to preserve the partition table, but it also is copying the empty disk area behind your partition.

A space-saving approach would

  1. just copy the partition (e.g. by using the dd if=/dev/sdX1 notation)
  2. store the partition table data either in binary (dd if=/dev/sda bs=512 count=1 of=sdX.partitiontable) or in a more handy human-readable format like the one offered by sfdisk (sfdisk -d /dev/sdX > sdX.sfdisk) which can be re-imported easily (sfdisk /dev/sdX < sdX.sfdisk)

You also might consider using a tool like ntfsclone which only would copy the file system data actually marked as "used" and omit all unused blocks.

share|improve this answer

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.