Expand Windows NTFS drive on a vmware machine

We use Vmware Server quite heavily at RedBalloon and it gives us a huge amount of flexibility and scalablity without breaking the budget.

An example of this flexibility is how we dealt with a recent problem where one of the drives on our Domain Controller was too small, but we had space available on the underlying Ubuntu Linux VMware Host.

So the plan is to shut down the server, increase the size of the virtual drive, resize the filesystem and we should be good to go.

BTW - this is not for the faint hearted and if done wrong can hose your system.

Here are the steps:

First of all run a chkdsk on the windows drive you are about to resize from within windows:

chkdsk e:

Then make a backup the disk you are about to resize - it's a virtual disk so we copy the files on the host machine. From the VM directory

sudo mkdir backup
sudo cp myDisk.* backup

Expand the original disk with the vmware virtual disk manager and fix the permissions

sudo vmware-vdiskmanager -x 30GB myDisk.vmdk
sudo chown admin:admin myDisk*

You now have a big disk - but the windows NTFS filesystem is only using the original size of the disk. There is no built in way to resolve this in Window but never mind, Linux comes to the rescue again!

Reboot into a Ubuntu Live CD

Open a terminal and run the following commands to resize the filesystem

This is the most dangerous step - as it's where you can really mess up your system.

sudo fdisk /dev/sdb # insert relevant drive instead of sdb
# Then delete your the relevant partition and recreate a larger one
# Note that it needs to be recreated identically except that the end of the partition is bigger. I.e. it needs the same start point on the disk.

sudo ntfsresize /dev/sdb #Again change as relevant

Reboot and windows will run a chkdsk on the drive, then boot and you are all done.

Comments
Ryan's Gravatar Hey Mark,

Nice blog, here's my question, ive looked up the vmware-vdiskmanager -x command and i understand the vmware-vdiskmanager is the utility and the -x is responsible for resizing, where i am having trouble is that i have the option of sizing all partitions to 2gb so i have a bunch of *.vmdk files.

So my question is "Do i apply the change to only one file or is there a different method employed when the 2gb option is selected?"

Thanks a lot

Ryan
# Posted By Ryan | 9/29/06 3:55 PM
Mark Lynch's Gravatar Hi Ryan
You should apply this to the main .vmdk file - this will be the one that doesn't have a sequence number beside it.

eg: a 6GB disk might look like:
mydisk.vmdk
mydisk-001.vmdk
mydisk-002.vmdk
mydisk-003.vmdk

You should do any operations on the mydisk.vmdk which is a text file (have a look inside to get a better understanding of how it works).
Cheers,
Mark
# Posted By Mark Lynch | 11/1/06 9:13 PM
Araemo's Gravatar "You now have a big disk - but the windows NTFS filesystem is only using the original size of the disk. There is no built in way to resolve this in Window but never mind, Linux comes to the rescue again!"

Actually, you can deal with that under windows, if you have converted the disk to a dynamic disk. You can add a new volume in the new free space, and extend the existing volume onto the new volume using disk management, but only if the volume is not the boot volume (Or maybe boot disk), so best practice under windows server is to have a small(10G or less?) C drive, and install all your programs or data onto an expandable D drive.
# Posted By Araemo | 11/15/06 1:09 AM
Jeff's Gravatar have read your article as recently I've had this problem myself. Found a clear answer here: http://www.vmweekly.com/articles/expanding_the_vir...


Jeff
# Posted By Jeff | 11/24/06 12:26 AM
Fred Perloff's Gravatar Mark,

I don't understand the steps you take after having booted into a Live CD.

Are you using fdisk to re-create the /*host*/ partition on which the virtual disk resides? The host partition is already large enough. Likewise, how do you run ntfsresize on /dev/sdb? The virtual disk only consists of a vmdk file, not a device. ntfsresize will see a vmdk file, not a ntfs filesystem, correct?

I'd like to understand the procedure before I begin...

Thanks for helping,
Fred
# Posted By Fred Perloff | 2/22/07 6:27 PM
Mark Lynch's Gravatar Hi Jeff,

On re-reading the article I realise it wasn't totally clear. When you reboot using Ubuntu you are rebooting the virtual machine into ubuntu - as you are going to be doing low level stuff to the windows disk which you can't do when running windows.

When you have booted up the vmware machine with ubuntu you will be able to reference the virtual NTFS disk as something similar to /dev/sda1. You then follow the commands above to resize the disk. Then reboot the virtual machine and you should have a big disk!

PLEASE REMEMBER TO MAKE A BACKUP COPY OF ALL THE VMDK FILES OR THE ENTIRE MACHINE SO IF YOU GET IT WRONG YOU CAN TRY AGAIN.

Cheers,
Mark
# Posted By Mark Lynch | 2/22/07 8:19 PM
Fred Perloff's Gravatar Mark,

Great stuff. Thanks.

Hints:
*Boot virtual machine with Live CD of your choice
*sudo fdisk /dev/sdb
-> recreate partition
-> set partition type to "7" ntfs
-> set partition to active
*sudo ntfsresize -s 30G /dev/sdb1

Backup is good! I had to re-do the procedure 3 times before I got it right.

Fred
# Posted By Fred Perloff | 2/24/07 5:58 PM
Paul Duffy's Gravatar Should be noted that 'sudo ntfsresize' won't work, at least with Ubuntu 6.06, as /sbin and /usr/sbin are only in the $PATH if you're actually logged in as root (as with all recent distros.

So, the slight adjustment is: sudo /usr/sbin/ntfsresize /dev/$DEVICEID

Also to be noted is that something like /dev/hda will not work even if there is only one partion. You have to specify /dev/hda1
# Posted By Paul Duffy | 5/7/07 9:27 AM
Jason's Gravatar Not sure if anybody is still following this thread but for a flat disk (only), you don't need to boot the guest system at all for a Linux host.

# losetup /dev/loop0 my-disk-flat.vmdk
# fdisk /dev/loop0
# /sbin/sfdisk -d /dev/loop0
(repartition remember the starting sector and size)
# dmsetup create myntfs --table '0 <partition size> linear /dev/loop0 <starting sector>'
# ntfsresize /dev/mapper/myntfs
# dmsetup remove myntfs
# losetup -d /dev/loop0

I do not know how the 2GB split feature works but if it is just a clean logical break every 2GB, then you could in principle use disk mapper's striping feature to bundle them all up. However I think it would take less time to boot up a live CD in the guest.
# Posted By Jason | 7/17/07 9:05 PM
Jim Stringer's Gravatar The easy way is to boot a live cd with gparted on it and just run gparted. Click on the expand button and everything is done for you. Then reboot and windows does a chkdsk. I found I had to boot windows once more after. Thanks for the great idea.
# Posted By Jim Stringer | 11/28/07 8:28 AM
Murali V N's Gravatar The above instructions will probably work for data disks. I tried doing this to expand my boot disk and windows refused to boot off it..
Any ideas?
It mounts fine as an NTFS volume after the resizing, but for some reason Windows XP does not like to boot off of it.
# Posted By Murali V N | 1/13/08 7:03 PM
Loki's Gravatar I would like to add that you should probably press u while in fdisk before you print the partition data to switch to the more acurate method for showing the start and end of the partitions. Thie first time I tried this I didn't know to do it, the origianal partition said it started at 1 so I deleted it and recreated it it from 1 and the NTFSresize wouldn't work. so to know where the partition actually starts in fdisk press u to switch modes and then p to print the partition info.
# Posted By Loki | 1/18/08 7:51 AM
Scooter's Gravatar This worked just fine for me. When I ran ntfsresize --info, it gave an estimate of what needed to be plugged in. Of course, the estimate is a bit small, so I did some quick math by subtracting the current value from the total value. I didn't use the K/M/G method, but the extact byte usage. So if your total disk size before resizing is 2150400 and after it's 5427200, then just 5427200-2150400 = 3276800 and plug it in, like this:

ntfsresize -n -s 3276800 /dev/sdb1 (for the dry run)
ntfsresize -s 3276800 /dev/sdb1 (for real(!) )

Windows booted up, ran its chkdsk without error, restarted, reinstalled the disk driver, restarted again and it's up and running flawlessly!!
# Posted By Scooter | 4/21/08 5:35 PM
alex's Gravatar When you have booted up the vmware machine with ubuntu you will be able to reference the virtual NTFS disk as something similar to /dev/sda1. You then http://www.batteryfast.com/toshiba/pa2506ur.php new battery fits Toshiba Portege 7000 7020 PA2506UR laptop battery,
http://www.batteryfast.com/toshiba/pa3285u-1brs.ph... Battery For Toshiba PA3285U PA3284U A10 A15 E10 E15 F10 laptop battery,
http://www.batteryfast.com/toshiba/pa3123u-1brs.ph... New BATTERY For TOSHIBA 5000 5100 PA3123U PA3178U laptop battery,
http://www.batteryfast.com/toshiba/pa3176u-1bas.ph... Battery For Toshiba Portege M200 M205 PA3128U PA3191U black laptop battery,
http://www.batteryfast.com/toshiba/pa3209u-1brs.ph... Battery for Toshiba Satellite 1100 1110 PA3209U-1BRS laptop battery,
http://www.batteryfast.com/toshiba/pa3399u-1bas.ph... Battery for Toshiba PA3399U-1BRS PA3399U-2BAS 1BAS laptop battery,

http://www.batteryfast.com/toshiba/pa3356u-1brs.ph... Toshiba PA3356U-3BAS PA3356U-3BRS PA3456U-1BRS Battery laptop battery,
http://www.batteryfast.com/toshiba/pa3420u.php toshiba pa3420u-1brs l10 l15 l20 laptop battery,
http://www.batteryfast.com/toshiba/pa3451u.php TOSHIBA PA3451U-1BRS PABAS067 laptop battery,
http://www.batteryfast.com/toshiba/pa3383.php Battery For PA3383 TOSHIBA Satellite PA3383U-1BRS 12cells laptop battery,
http://www.batteryfast.com/toshiba/pa3431u-1brs.ph... TOSHIBA SATELLITE M65 BATTERY PA3431U-BRS PABAS068 laptop battery,
http://www.batteryfast.com/clevo/m540.php clevo m540 laptop battery,

http://www.batteryfast.com/clevo/m375.php clevo m375 m360 M300N M310N laptop battery,
http://www.batteryfast.com/clevo/dr202.php clevo dr202 me202bb laptop battery,
http://www.batteryfast.com/fujitsu/s2000.php fujitsu fpcbp64 s2000 s2010 s2020 laptop battery,
http://www.batteryfast.com/fujitsu/cbp109.php fujitsu fucbp109 S7011 S7021 S7025 laptop battery,
http://www.batteryfast.com/fujitsu/fpcbp49.php fujitsu fpcbp49 P1000 P2000 laptop battery,
http://www.batteryfast.com/uniwill/un255.php uniwill 255-3S4400-G1L1 un255 laptop battery,
follow the commands above to resize the disk. Then reboot the virtual machine and you should have a big disk!
# Posted By alex | 9/27/08 5:57 PM
warhammer gold's Gravatar leihualin
<A href="http://www.vipwargold.com/" target=_blank><FONT size=4><STRONG>war gold</STRONG></FONT></A><FONT size=4><STRONG>&nbsp; &nbsp;</STRONG></FONT><A href="http://www.vipwargold.com/" target=_blank><FONT size=4><STRONG>buy war gold</STRONG></FONT></A><FONT size=4><STRONG>&nbsp; &nbsp; </STRONG></FONT><A href="http://www.vipwargold.com/" target=_blank><FONT size=4><STRONG>warhammer gold</STRONG></FONT></A><BR><A href="http://www.cheaperzone.com/" target=_blank><FONT size=4><STRONG>warhammer gold</STRONG></FONT></A><FONT size=4><STRONG>&nbsp; &nbsp;</STRONG></FONT><A href="http://www.cheaperzone.com/Buy-WOW-Gold/WOW-Gold.Html" target=_blank><FONT size=4><STRONG>buy warhammer gold</STRONG></FONT></A><FONT size=4><STRONG>&nbsp; &nbsp; </STRONG></FONT><A href="http://www.cheaperzone.com/" target=_blank><FONT size=4><STRONG>war gold</STRONG></FONT></A><BR><FONT size=4><A href="http://www.vipwarhammergold.com/" target=_blank><FONT size=4><STRONG>warhammer gold</STRONG></FONT></A><STRONG>&nbsp; &nbsp;</STRONG><A href="http://www.vipwarhammergold.com/" target=_blank><STRONG>buy warhammer gold</STRONG></A><STRONG>&nbsp; &nbsp; </STRONG><A href="http://www.vipwarhammergold.com/" target=_blank><STRONG>war gold</STRONG></A></FONT><BR><FONT size=4><A href="http://www.buyfastgold.com/" target=_blank><FONT size=4><STRONG>warhammer gold</STRONG></FONT></A><STRONG>&nbsp; &nbsp;</STRONG><A href="http://www.buyfastgold.com/buy-warhammer-gold/" target="_blank">http://www.buyfastgold.com/buy-warhammer-gold/" target=_blank><STRONG>buy warhammer gold</STRONG></A><STRONG>&nbsp; &nbsp; </STRONG><A href="http://www.buyfastgold.com/" target=_blank><FONT size=4><STRONG>war gold</STRONG></FONT></A></FONT><BR><FONT size=4><A href="http://warhammer-gold.rgtrcredit.com/" target=_blank><FONT size=4><STRONG>warhammer gold</STRONG></FONT></A><STRONG>&nbsp; &nbsp;</STRONG><A href="http://warhammer-gold.rgtrcredit.com/Buy-warhammer-gold.html" target="_blank">http://warhammer-gold.rgtrcredit.com/Buy-warhammer..." target=_blank><STRONG>buy warhammer gold</STRONG></A><STRONG>&nbsp; &nbsp; </STRONG><A href="http://warhammer-gold.rgtrcredit.com/" target=_blank><STRONG>war gold</STRONG></A></FONT><BR><FONT size=4><A href="http://warhammer.hellgate-pd.com/" target=_blank><FONT size=4><STRONG>warhammer gold</STRONG></FONT></A><STRONG>&nbsp; &nbsp;</STRONG><A href="http://warhammer.hellgate-pd.com/buy-warhammer-gold.html" target="_blank">http://warhammer.hellgate-pd.com/buy-warhammer-gol..." target=_blank><STRONG>buy warhammer gold</STRONG></A><STRONG>&nbsp; &nbsp; </STRONG><A href="http://warhammer.hellgate-pd.com/" target=_blank><FONT size=4><STRONG>war gold</STRONG></FONT></A></FONT><BR><FONT size=4><A href="http://www.vipaocgold.com/" target=_blank><FONT size=4><STRONG>aoc gold</STRONG></FONT></A><STRONG>&nbsp; &nbsp;</STRONG><A href="http://www.vipaocgold.com/buy-aoc-gold/" target=_blank><STRONG>buy aoc gold</STRONG></A><STRONG>&nbsp; &nbsp; </STRONG><A href="http://www.vipaocgold.com/" target=_blank><STRONG>age of conan gold</STRONG></A></FONT><BR><FONT size=4><FONT size=4><FONT size=4><A href="http://www.aocsale.com/" target=_blank><FONT size=4><FONT size=4><STRONG>age of conan gold</STRONG></FONT></FONT></A></FONT><STRONG>&nbsp; &nbsp;</STRONG><A href="http://www.aocsale.com/buy-aoc-gold/" target="_blank">http://www.aocsale.com/buy-aoc-gold/" target=_blank><STRONG>buy age of conan gold</STRONG></A><STRONG>&nbsp; &nbsp; </STRONG><A href="http://www.aocsale.com/" target=_blank><STRONG>aoc gold</STRONG></A></FONT></FONT><BR><FONT size=4><A href="http://www.gold-warhammer.com/" target=_blank><FONT size=4><STRONG>warhammer gold</STRONG></FONT></A></FONT
# Posted By warhammer gold | 9/28/08 5:58 PM