

Sector size (logical/physical): 512 bytes / 512 bytes


Ssh into the system, switch to root and run cfdiskĭisk /dev/sda: 20 GiB, 21474836480 bytes, 41943040 sectors The following example is extending volume on root partition on a system that is already using LVM. Tested in Ubuntu Server 16.04 to 18.10Īfter extending the volume in VMware ESXi (shutdown vm, backup/export vm, remove all snapshots, then increased number in disk size, take snapshot of vm again before following the next steps so you can revert mistake/error). That's it, we've just resized a partition on which Ubuntu is installed, without booting from an external drive. Run sudo resize2fs /dev/sda1 - this form will default to making the filesystem to take all available space on the partition. When the system boots, you'll have a smaller filesystem living inside a larger partition. You'll get a message telling that the kernel couldn't re-read the partition table because the device is busy, but that's ok. review your changes, make a deep breath and use w to write the new partition table to disk.use a to toggle the bootable flag on the new /dev/sda1.For the end cylinder agree with the default choice, which is to make the partition to span the whole disk. Make sure its start cylinder is exactly the same as the old /dev/sda1 used to have. use n to create a new primary partition.This is very scary but is actually harmless as the data is not written to the disk until you write the changes to the disk. use d to delete first the swap partition ( 2) and then the /dev/sda1 partition.Make note of the start cylinder of /dev/sda1 For this exercise we want to remove the swap partition an extend /dev/sda1 to the whole disk.Īs always, make sure you have a backup of your data - since we're going to modify the partition table there's a chance to lose all your data if you make a typo, for example. Here's the list of steps for a simple scenario where you have two partitions, /dev/sda1 is an ext4 partition the OS is booted from and /dev/sdb2 is swap. As a matter of fact, you CAN enlarge the root filesystem while Ubuntu is running (I learned this recently myself here) - this sounds incredible but it's true :)
