KVM: Resize NTFS partition in LVM volume

I am using Proxmox installed on Debian linux amd64. Always make a backup of important data. I take no responsibility for anything.

How to resize NTFS partition located in LVM logical volume? I will use parted, ntfsprogs and kpartx.

apt-get install parted ntfsprogs kpartx

I assume we have only one partition.

If we have no free space in LVM volume than we should grow it. Let's grow it to 3GB.

virtual:~# lvextend -L3G /dev/vg0/vm-101-disk-1 Extending logical volume vm-101-disk-1 to 3.00 GB Logical volume vm-101-disk-1 successfully resized

Next we should modify our partition table.

virtual:~# parted /dev/vg0/vm-101-disk-1 GNU Parted 1.8.8 Using /dev/mapper/vg0-vm--101--disk--1 Welcome to GNU Parted! Type 'help' to view a list of commands. (parted) unit Unit? [compact]? B (parted) print Model: Linux device-mapper (linear) (dm) Disk /dev/mapper/vg0-vm--101--disk--1: 3221225472B Sector size (logical/physical): 512B/512B Partition Table: msdos Number Start End Size Type File system Flags 1 32256B 2147483647B 2147451392B primary ntfs (parted) rm 1 (parted) mkpart primary ntfs 32256B 3221225471B (parted) print Model: Linux device-mapper (linear) (dm) Disk /dev/mapper/vg0-vm--101--disk--1: 3221225472B Sector size (logical/physical): 512B/512B Partition Table: msdos Number Start End Size Type File system Flags 1 32256B 3221225471B 3221193216B primary ntfs (parted) quit Information: You may need to update /etc/fstab.

We will use kpartx to map new partition table.

virtual:~# kpartx -a /dev/vg0/vm-101-disk-1

And finally grow NTFS file system.

virtual:~# ntfsresize /dev/mapper/vg0-vm--101--disk--1p1 ntfsresize v2.0.0 (libntfs 10:0:0) Device name : /dev/mapper/vg0-vm--101--disk--1p1 NTFS volume version: 3.1 Cluster size : 512 bytes Current volume size: 2147451392 bytes (2148 MB) Current device size: 3221193216 bytes (3222 MB) New volume size : 3221193216 bytes (3222 MB) Checking filesystem consistency ... 100.00 percent completed Accounting clusters ... Space in use : 159 MB (7.4%) 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/mapper/vg0-vm--101--disk--1p1'.

That is all. We can remove our mapping.

virtual:~# kpartx -d /dev/vg0/vm-101-disk-1