Sparse virtual machine disk image resizing weirdness?
Posted
by
Matt H
on Ask Ubuntu
See other posts from Ask Ubuntu
or by Matt H
Published on 2012-03-23T05:01:34Z
Indexed on
2012/03/23
5:39 UTC
Read the original article
Hit count: 325
partitioning
|xen
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 is 10GB which is what I expect. The problem is windows isn't seeing this?
© Ask Ubuntu or respective owner