When resizing disk partitions, it is very easy to make a mistake and lose everything!
Step 1 : Back up the VM before starting
Step 2 : take a snapshot before starting so you can restore the VM in case something unexpected happens.
The first thing to do is take a snapshot of the VM. Go to the VM in Nutanix, right-click on it, and select Take Snapshot
Enter a meaningful name for the snapshot such as "Pre Disk Expansion"
To perform the expansion, a free open source tool will be needed called the GNOME Partition Editor (GParted). It can be downloaded from https://gparted.org/download.php . The file link to be followed that is for 64-bit virtual machines hosted on Nutanix is Download gparted-live-1.6.0-3-amd64.iso .
Upload the GNOME Partition Editor (GParted) to the Nutanix Image Service. This is done by first selecting the gear icon in the top right.
Next, select Image Configuration from the left menu.
Click the Upload Image button
In the Create Image dialog box, enter the following information and click save:
Enter the name: GParted
Enter the description/annotation: GNOME Partition Editor
Specify the Image Type: ISO
Choose a storage container
Click the "Choose File" button, locate the ISO file, and click Open
When all of this is done, click Save to upload the image.
Next, navigate to the VM window by clicking on the home menu and selecting VM. Afterwards, double-click the VM to open the Update VM window.
Scroll down the Udpdate VM dialog window until the disks section is visible. Click on the pencil icon for the CD-ROM to select an ISO to connect to the VM.
In the Update Disk dialog, select Clone from Image Service and select the GParted ISO that was uploaded above. Afterwards, click the Update button to close the dialog window.
Select the pencil icon next to Disk scsi.0 to open the dialog to alter the size of the disk on the VM.
Enter the new size of the disk. While the disk cannot be reduced in size it can be expanded.
Note: when the disk is expanded, it will not immediately consume the space on the disk. All disks on Nutanix systems are thin provisioned because the file system contains segments that become immutable during snapshots and redirects to other portions of storage automatically occur when data is written.
After the new disk size has been entered, click the Update button to save the change.
After returning to the Update VM dialog window, click the Save button.
If the VM is on - restart it.
If the VM is off - start it.
Right-click on the VM and select Launch Console
When the boot window opens, select the GParted (Default Settings)
GParted will display a window. In the window leave the selection on "Don't Touch Keymap". Press tab to move the red highlight to OK. Then press Enter.
Select the language. As an example, for English it is 33 and then press Enter to continue.
Next, GParted has an option to manually set the video settings. Accept the default by pressing the Enter key to continue.
GParted will now display the partitions on the disk.
The next steps are:
Expand the extended partition to the end of the disk
Move the linux-swap partition to the end of the disk
Resize the extended partition's start point to be 199GB from the front of the disk.
Resize the ext4 partition, /dev/sda1, to be 199GB in size.
Right-click on the extended partition, /dev/sda2, then select resize/move.
Set the Extended partition to the maximum size-100. The maximum size is listed in the resize dialog window. After entering the new size, the space after the partition should be 100.
Afterwards, click the Resize/Move button to accept the change.
To apply the change, click on the Edit menu, and select Apply all Operations. Afterwards, click the Apply button for the change to be applied.
GParted should now show the message that "All operations were completed successfully." Click the Close button to continue.
Right-click the swap partition, /dev/sda5, then click the Resize/Move menu option.
The Resize/Move dialog window is displayed. It will start with the value of 0 free space preceeding, the current size, and the free space following.
Take the number for the free space following and enter it into the free space preceding. Then click the tab button. Afterwards, click the Resize/Move button to move the partition.
Since a partition will be moved, GParted will present a warning about moving partitions used for booting. In this case, the partition being moved is a swap partition and not used to boot the system. Due to this, it is okay to click the OK button at the bottom of the window to continue.
To apply the change, click on the Edit menu, and select Apply all Operations. Afterwards, click the Apply button for the change to be applied.
Next, right-click the extended partition and select Resize/Move. When the Resize/Move window appears, subtract the minimum size from the Maximum size and enter this into free space preceding. The New Size should be equal to the minimum size and the free space following should be 100.
Afterwards, click the Resize/Move button to move the partition.
To apply the change, click on the Edit menu, and select Apply all Operations. Afterwards, click the Apply button for the change to be applied.
The completion window should appear showing that all operations completed successfully. Click the Close button to continue.
Next, right-click the boot partition, /dev/sda1, then click Resize/Move.
For the new size subtract 1,000 from the maximum size. This will leave 1,000 MiB between the boot partition and the extended partition. While it's possible to leave 0 bytes free, on rare occasions boundary math can lead to a collision. To prevent this issue, leave some space between the partitions.
To apply the change, click on the Edit menu, and select Apply all Operations. Afterwards, click the Apply button for the change to be applied.
GParted will expand the partition and then resize the file system. This will eliminate the manual step later of having to resize the file system.
When complete, a dialog window will show all operations completed successfully. Click the close button to continue.
Next, it is safe to quit GParted, click the power icon, and select the power cycle option to restar the virtual machine.
Click the power icon in the top right of the console, select power off, then click the submit button.
After clicking submit, the console will present an error dialog because there is nothing for it to display. Switch to the browser window with Prism.
Double-click the VM to open the Update VM dialog window. Scroll down to Disks. To the right of cd-rom click the eject icon.
A progress dialog window will appear while the virtual cd-rom is ejected. After it is ejected, click either the close or the save button to close the window.
Power on the VM but right-clicking on it and selecting Power On. Then switch back to the console window for the virtual machine.
Log into the virtual machine and go to terminal. In terminal, issue the command df. The number of 1K-blocks should now be the new larger size for the virtual machine. Congratulations, you have expanded the boot disk of your virtual machine!