It took me a while to figure out how to resize a hard drive on a Linux Mint 17.x VM running under VMWare. Basically it’s a mashup of instructions I found online for resizing drives in Ubuntu and LVM guides.
My Linux Mint 17 installation isn’t very special. I basically ran through the default FDisk setup steps and put everything in one partition, the main drive. Mint ended up creating a boot partition and an extended partition with a logical LVM partition containing all the drive data. I don’t have a picture of this from GParted but it looks like 2 partitions as I described.
My version of VMWare (7.1.x) doesn’t recognize Linux Mint so I created it in VMWare as an Ubuntu 14 machine. I try to avoid too much customization of the VMWare instance since it’s not Ubuntu, it’s Mint.
You will need:
- Linux Mint 17.x VM running under VMWare
- Linux Minut 17 installation ISO
I tried to use GParted to finish the steps but I wasn’t able to specify all the needed information for the new partition, so I ended up going with FDisk. FDisk provides low-level disk partition operations so be careful, you can nuke your installation! Here are the steps:
- Power down the Linux Mint VM. Use the Linux Mint start menu/power-off.
- Resize the SCSI hard drive in VMWare. Keep track of the exact size difference as you’ll want this later.
- Connect the CD/DVD-ROM Drive to the Linux Mint 17 ISO
- Set the machine to start from CD-ROM in VMWare
- Start the VM. Immediately focus the window. When it starts you can press F2 to enter the boot menu. Choose boot option #1 to boot from the CD-ROM (ISO installation file).
- Linux Mint 17 Live installation will boot. Once booted no login is required.
- Open a terminal in the Live boot desktop.
- First run gparted to verify your installation resembles mine and to get a visual picture of the partition table.
- sudo gparted &
- If things look OK in GParted then proceed with fdisk. My installation has the primary drive mapped to /dev/sda — this might be different in your installation if you customized it or have a different version of Mint.
- sudo fdisk /dev/sda to start the FDisk command line.
- Enter command ‘q’ to abort any changes made below.
- Enter command ‘p’ to list partition tables.
- Write the start cylinders for the Extended partition (/dev/sda2 on my installation) and the Logical Partition (/dev/sda5 on my installation) on a piece of paper.
- Delete the logical and extended partitions. DO NOT delete the boot partition.
- Enter command ‘d’ to delete a partition – choose 5 to delete /dev/sda5, for example
- Enter command ‘d’ to delete a partition – choose 2 to delete /dev/sda2, for example
- Re-create the extended and logical partitions.
- Enter command ‘n’ to create a partition. Choose ‘e’ for extended partition type. Choose 2 to create /dev/sda2. Set the start cylinder to what you noted from fdisk ‘p’ above. For end cylinder I used the maximum value to allocate all of the new space from VMWare.
- Enter command ‘n’ to create a partition. FDisk should know you are creating a logical partition. Choose 5 for /dev/sda5. Now you need to choose the default start cylinder given in FDisk. This is because the default partition type in FDisk is Linux (0x83), not LVM (0x8e). Accept the minimum start and end values to use the maximum space.
- Now the twist is to reset the start cylinder.
- Enter the ‘x’ command to enter expert mode.
- First set the new logical partition type to LVM. Enter the ‘i’ command, enter 8e for LVM.
- Next move the beginning of data. Enter the ‘b’ command, then enter the start cylinder of the logical drive you noted above.
- Enter the ‘p’ command to verify the new table.
- If the changes look OK then enter ‘w’ to write the new partition table and exit. Particularly verify that all start cylinders for the extended and logical partitions match your notes. Also the end cylinders should be larger than before (larger HDD). Do not proceed (enter ‘q’ and start over) if the start cylinders are different – you will probably lose your VM installation!
- We’re not done yet so return the Mint CLI. Now we need to allocate the new space in LVM. Again, be very careful with these steps! Unlike FDisk these commands are executed immediately! You may need to refer to http://www.techrepublic.com/blog/smb-technologist/extending-partitions-on-linux-vmware-virtual-machines/ for more information, however things are quite different in Mint.
- df -h to find the name of the volume group (mine is mint-vg).
- lvm to open the LVM CLI. You should see a prompt like lvm>. Now enter these commands.
- vgextend mint-vg /dev/sda5
- lvextend -L+5G /dev/mint-vg/lv_root to extend the logical volume by 5gigabytes. Adjust this number for the size you increased the VMWare drive.
- resize2fs /dev/mint-vg/lv_root to expand the filesystem in the logical volume. You may have to run this command twice (2x) because an error is generated the first time with instructions to resolve. Follow the instructions provided upon the first execution. The instruction says something like execute mkfs /dev/mint-vg/lv_root first.
- Exit the LVM CLI.
- df -h to verify that all new space is allocated.
- Restart the VM from the Mint start menu. VMWare should automatically unmount the cd-rom Live installation ISO, but if not then do this manually before restarting.
- Your Linux Mint VMWare VM should now have all the new disk space you allocated to it.
Thanks to the following links for helpful info: