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'm trying to reduce the size of a backup drive image. Original disk had these partitions:

Model: ST916082 1A (scsi)
Disk /dev/sde: 160GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start   End     Size    Type      File system  Flags
 1      32.3kB  65.7GB  65.7GB  primary   ntfs         boot
 2      65.7GB  160GB   94.4GB  extended               lba
 5      65.7GB  160GB   94.4GB  logical   ntfs

Image was created from the logical partition using the command

> sudo ddrescue /dev/sde5 datapartition logfile

Press Ctrl-C to interrupt
Initial status (read from logfile)
rescued:         0 B,  errsize:       0 B,  errors:       0
Current status
rescued:    94368 MB,  errsize:       0 B,  current rate:   23068 kB/s
   ipos:    94368 MB,   errors:       0,    average rate:   28839 kB/s
   opos:    94368 MB,     time from last successful read:       0 s

ntfsresize -i -f datapartition says:

ntfsresize v2012.1.15AR.5 (libntfs-3g)
Device name        : datapartition
NTFS volume version: 3.1
Cluster size       : 4096 bytes
Current volume size: 26999992832 bytes (27000 MB)
Current device size: 94368605184 bytes (94369 MB)
Checking filesystem consistency ...
100.00 percent completed
Accounting clusters ...
Space in use       : 26107 MB (96.7%)
Collecting resizing constraints ...
You might resize at 26106810368 bytes or 26107 MB (freeing 893 MB).
Please make a test run using both the -n and -s options before real resizing!

So it looks like I already resized the filesystem to fit the data, but did not resize the device? (This was 2 years ago, I forget.) And I need to resize the device using fdisk, right? But fdisk doesn't recognize the partition:

> fdisk -lu datapartition 

Disk datapartition: 94.4 GB, 94368605184 bytes
255 heads, 63 sectors/track, 11472 cylinders, total 184313682 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x69205244

This doesn't look like a partition table
Probably you selected the wrong device.

        Device Boot      Start         End      Blocks   Id  System
datapartition1   ?   218129509  1920119918   850995205   72  Unknown
datapartition2   ?   729050177  1273024900   271987362   74  Unknown
datapartition3   ?   168653938   168653938           0   65  Novell Netware 386
datapartition4      2692939776  2692991410       25817+   0  Empty

Partition table entries are not in disk order

nor does cfdisk:

> cfdisk datapartition 

FATAL ERROR: Bad primary partition 1: Partition begins after end-of-disk
                      Press any key to exit cfdisk

I can mount the partition and copy files off of it, though. How do I resize the device?

share|improve this question

2 Answers 2

up vote 2 down vote accepted

If it's just the dump of the partition, there's no partition table. The partition is the file, you just need to shrink the file:

truncate -s 27000832000 datapartition

(27000832000 is 26999992832 rounded up to the next MiB just to be on the safe side, would you like for instance to compress it to a qcow2 format or any other mountable compressed format)

share|improve this answer
Ah, ok, that makes sense. Before I actually do it, though, can you provide a reference or a little more reassurance that there's no useful information in the part of the file I'm truncating? –  endolith Apr 10 '13 at 14:01
@endolith, if in doubt, you can always do a losetup -r --sizelimit=27000832000 /dev/loop0 datapartition and check that that loop0 is OK (set the sizelimit to 26900832000, and you'll see you can't mount it). –  Stéphane Chazelas Apr 10 '13 at 14:26
Confirmed that sudo mount -o loop /dev/loop0 does not work with losetup 26900832000 but does work with 27000832000. Also found a note to myself that the partition originally only had 25 GB of data on it, so I truncated it and it still mounts correctly. Yay free space! –  endolith Apr 10 '13 at 15:40

You might want to give gparted a look. We usually use this live distro when we want to resize partitions of varying types.

sample screenshots of gparted

                              ss of gparted #1

                              ss of gparted #2

Take a look at this tutorial for further details.

share|improve this answer
But here, there's no partition table to adjust. –  Stéphane Chazelas Apr 10 '13 at 6:51

Your Answer


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.