Resize KVM NTFS File System

Home » CentOS » Resize KVM NTFS File System
CentOS 10 Comments

Hey all,

I resized a partition inside a KVM RAW file system disk image. When I
start the Win7 virtual machine it does not report the new partition size. It shows the file system as 15GB instead of the 50GB size of the partition that it lives on. I gather from hours so reading the manual that I need to increase the NTFS file system size to fill the new larger partition where it lives.

The ntfresize command does not seem to be compatible with disk image files. Do I have to mount the disk image file with a loopback first?

I tried doing it inside the Win7 VM using the disk management tools but that didn’t work either.

Any suggestions welcome.


_
°v°
/(_)\
^ ^ Mark LaPierre Registered Linux user No #267004
https://linuxcounter.net/
****

10 thoughts on - Resize KVM NTFS File System

  • While yes, you do need to increase the NTFS file system, I’d expect what you’ll find is the partition still needs to be enlarged first.

    In the past I’ve booted up with a GNU/Linux live CD that has GParted and enlarged the partition that Windows occupies. Expect Windows to do a check disk (I think) following the resize.

    Or [instead of using GParted] I’d expect you could boot to a live environment and use fdisk to delete the Windows partition (after marking down the start of the existing partition). Then create an NTFS partition in the same place that is of the larger desired size. From there you might be able to boot your Windows OS and have it resize … but I don’t know for certain (though worth a test if you have a backup and don’t mind testing it!).

    If you were feeling adventurous, you could also loopback mount it and choose my second suggestion with fdisk. But if you had gparted or ntfs-3g you could also use utilities to manipulate the disk and file system. Certainly not as easy as booting a live CD in the VM (let alone GParted GUI).

    Please back up your VM’s disk image/backing before trying any of this. ;-)

    HTH

  • It’s generally recommended to use Windows tools to do NTFS re-sizing. I can’t help with that, but from Linux you would need to run
    kpartx -a -v /path/to/image/file to create the /dev/mapper/loop?p? devices for the partitions within the image. You can then access those devices just like regular disk partitions.

    Run “kpartx -d -v /path/to/image/file” to delete the loop devices.

  • Within windows, use diskpart from a command shell:

    C:\>diskpart

    Microsoft DiskPart version 6.3.9600

    Copyright (C) 1999-2013 Microsoft Corporation. On computer: TEST

    DISKPART> rescan

    Please wait while DiskPart scans your configuration…

    DiskPart has finished scanning your configuration.

    DISKPART> lis dis

    Disk ### Status Size Free Dyn Gpt
    ——– ————- ——- ——- — –

  • As I recall, right click on “Computer,” select “Manage.” Select the
    “Storage” item on the left. Right click on the volume you want to expand and resize it.

  • I tend to disagree with that advice… I would recommend http://gparted.org/livecd.php over the microsoft-supplied tools, in a heartbeat.

    Boot off that Live image on a CD or thumbdrive (or use the version of GPartEd included with the System Rescue Live CD from http://www.sysresccd.org/ ), select the correct disk from the drop down menu in the upper-right, set the borders of the partitions where you want them with the GUI, then tell it to Apply the pending actions.

    If I recall correctly, the disk management tool in the windows MMC won’t resize the partition it’s running from, by the way.

  • Why? If you use gparted (ntfsprogs, under the covers, IIRC), the system will chkdsk on the next boot. No such requirement exists with Microsoft’s tools.

    You do not recall correctly.

  • That’s not been my experience… gparted does use ntfs-3g to work on NTFS
    partitions (what linux-based tool doesn’t?), but does not by default set the dirty bit. Its GUI also offers much-finer granularity than microsoft’s.

  • hey, I’d hang up, too. I don’t trust in-place partition shrinking, no matter WHAT the software.

    my preferred method of resizing NTFS is to use Acronis TrueImage or another similar backup tool to make a complete file system image of the partitions of the disk onto external media, then repartition the disk and restore that image to new smaller partitions. If anything goes wrong like a system crash, power fail, etc during the first step, nothing is lost, just redo it. and if something goes wrong during the
    2nd step, well, you have that full backup, you can restore it again.

  • What I normally do is power off the VM; add the drive I want to extend onto another windows VM and use Microsoft diskpart tool to extend the volume and it works in VMware, Virtual Box and KVM without fail or corrupting any file system.