Resize NTFS partition - Windows 7 guest, Ubuntu Host

This is how I managed to resize the harddrive.vdi file of a VirtualBox Windows 7 guest form 40G to 60G, using a spare Ubunt guest to do some of the dirty work.

First, used the main VirtualBox window to detach the hard drive from my Windows virtual guest. Then I had to clone the .vdi file so that the --resize command would work.

$ vboxmanage clonehd win.vdi win7new.vdi
$ vboxmanage modifyhd --resize 61440 win7new.vdi

Now the virtual drive was 60G, but the partition and file system were still 40G.
I launched an Ubuntu guest VM with win7new.vdi attached as a spare drive, it showed up as /dev/sdb. I ran parted, removed the 40G partition and then recreated it to use the full drive.

# parted /dev/sdb
GNU Parted 2.2
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print
Model: ATA VBOX HARDDISK (scsi)
Disk /dev/sdb: 64.4GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Number Start End Size Type File system Flags
1 1049kB 106MB 105MB primary ntfs boot
2 106MB 42.9GB 42.8GB primary ntfs
(parted) rm 2
(parted) mkpart primary ntfs 106MB 100%
(parted) print
Model: ATA VBOX HARDDISK (scsi)
Disk /dev/sdb: 64.4GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Number Start End Size Type File system Flags
1 1049kB 106MB 105MB primary ntfs boot
2 106MB 64.4GB 64.3GB primary ntfs
(parted) q

Next I ran the ntfsresize command to resize the NTFS filesystem.

# ntfsresize /dev/sdb2
ntfsresize v2.0.0 (libntfs 10:0:0)
Device name : /dev/sdb2
NTFS volume version: 3.1
Cluster size : 4096 bytes
Current volume size: 42841666048 bytes (42842 MB)
Current device size: 64318603264 bytes (64319 MB)
New volume size : 64318599680 bytes (64319 MB)
Checking filesystem consistency ...
100.00 percent completed
Accounting clusters ...
Space in use : 40124 MB (93.7%)
Collecting resizing constraints ...
WARNING: Every sanity check passed and only the dangerous operations left.
Make sure that important data has been backed up! Power outage or computer
crash may result major data loss!
Are you sure you want to proceed (y/[n])? y
Schedule chkdsk for NTFS consistency check at Windows boot time ...
Resetting $LogFile ... (this might take a while)
Updating $BadClust file ...
Updating $Bitmap file ...
Updating Boot record ...
Syncing device ...
Successfully resized NTFS on device '/dev/sdb2'.

Now for the smoke test! Back into VirtualBox, detach the drive from the Ubuntu guest and reattach to the Windows guest. Launch the Windows system and ... Ta-da! Windows wanted to run a file system check at boot, ran fine thereafter.