Tell me more ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have a partitioned virtual machine disk image created by vmware.

What I want to do is resize that by 10GB.

The file size is showing as 64424509440. Or 60GB.

So I ran this:

dd if=/dev/zero of=./win7.img seek=146800640 count=0

It ran without errors and I can verify the new size is in fact 75161927680 bytes or 70GB.

This is where it gets a little odd.

I started the guest domain in xen which is a Windows 7 enterprise machine.

What I was expecting to see in diskmgmt.msc is 2 partitions. 1 system partition at the start of around 100MB and near 60GB partition (which is C drive) followed by around 10GB of free space.

Actually what I saw was a 70GB partition!?!

That confused me... so I decided to run the Check Disk which when you set it on the C drive it asks you to reboot so it'll run on boot. So I did that and during the boot it ran the checks. It got all the way through stage 3 and didn't show any errors at all.

Looked at the partitions in disk manager and now C drive has shrunk back to 60GB and there is no free space.

What gives?

Ok, I thought I'd try mounting it under Dom0 and examining it with fdisk.

This is what I get when mounted

sudo xl block-attach 0 tap:aio:/home/xen/vms/otoy_v1202-xen.img xvda w
sudo fdisk -l /dev/xvda

Disk /dev/xvda: 64.4 GB, 64424509440 bytes
255 heads, 63 sectors/track, 7832 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x582dfc96

    Device Boot      Start         End      Blocks   Id  System
/dev/xvda1   *           1          13      102400    7  HPFS/NTFS
Partition 1 does not end on cylinder boundary.
/dev/xvda2              13        7833    62810112    7  HPFS/NTFS

Note the cylinder boundary comment.

When I run

sudo cfdisk /dev/xvda

I get:

FATAL ERROR: Bad primary partition 1: Partition ends in the final partial cylinder                       
                                                  Press any key to exit cfdisk

So I guess this is a bigger problem than first thought.

How can I fix this?

EDIT: Oops, the cylinder boundary thing is not a problem at all since disks have used LBA etc. So that threw me for a moment... still the problem exists...

Now this output looks a little different.

sudo sfdisk -uS -l /dev/xvda

Disk /dev/xvda: 7832 cylinders, 255 heads, 63 sectors/track
Units = sectors of 512 bytes, counting from 0

   Device Boot    Start       End   #sectors  Id  System
/dev/xvda1   *      2048    206847     204800   7  HPFS/NTFS
/dev/xvda2        206848 125827071  125620224   7  HPFS/NTFS
/dev/xvda3             0         -          0   0  Empty
/dev/xvda4             0         -          0   0  Empty

BTW: I do have a backup of the image so if you help me mess it up that's ok.

EDIT:

sudo parted /dev/xvda print free

Model: Xen Virtual Block Device (xvd)
Disk /dev/xvda: 64.4GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start   End     Size    Type     File system  Flags
        32.3kB  1049kB  1016kB           Free Space
 1      1049kB  106MB   105MB   primary  ntfs         boot
 2      106MB   64.4GB  64.3GB  primary  ntfs
        64.4GB  64.4GB  1049kB           Free Space

Cool. Linux is showing free space at the end of the drive which is what I expect. But, the start and end is the same. No wonder windows can't see it. How can I correct this? obviously the partition table is broken somehow.

share|improve this question
OK Windows 7 uses 2 partitions. 1 is the boot partition and the other is the OS. the free space you have is because the image was re-sized not the partition. from windows you must re-size the C: Partition. – Taylor Bioniks Mar 23 '12 at 5:55
Correct, the image was resized and I expected the partition to still remain at 60GB. But windows is not detecting the free space I would have expected to see and parted is not showing free space correctly, i.e. it virtually ends where it starts? 1MB in size. – Matt H Mar 23 '12 at 6:11
I initially extended it by 10GB not 1MB. Initially when I started windows it appeared to grow the C partition by 10GB instead of keep C at 60GB and extend free unpartitioned space by 10GB. That's why I ran check disk to start with because it's not what I would have expected would happen. – Matt H Mar 23 '12 at 6:14
Check Disk then shrank it back down to 60GB leaving 1MB free (although you see nothing free in windows disk management). – Matt H Mar 23 '12 at 6:16
2  
This question appears to be abandoned and unanswered. If this question no longer applies then you can either delete it or answer it yourself if you've solved the problem. Thanks! – Eric Carvalho Mar 19 at 1:33
show 2 more comments

closed as too localized by Eric Carvalho, Eliah Kagan, Seth, Caesium, con-f-use Mar 28 at 17:27

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, see the FAQ.

Browse other questions tagged or ask your own question.