/ ubuntu

enlarge ubuntu root partition in vmware

I have a ubuntu vmware guest with 30Gb root partition, but it's not enough after restore data from production environment, so I have to enlarge it.

  • shutdown ubuntu
  • enlarge partition on vmware guest setting
  • start ubuntu, it's better use text mode
  • sudo fdisk /dev/sda (I have only one device in ubuntu, sda)
  • delete swap partition and root partition with d command (yes, delete all partitions)
  • create root partition (primary partition) with n command, be careful the start selector must be as same as old root partition (default is good), end selector is the size what you want the partition be, e.g. +45G, is a 45Gb partiton
  • (optional) create swap partition if you need, with n command, and then change swap partition type with t command, swap type code is 82
  • write changes with w
  • reboot ubuntu
  • sudo resize2fs /dev/sda1, enlarge sda1 to default new size, e.g. 45Gb
  • (optional) sudo mkswp /dev/sda2 if you create swap partition
  • (optional) change swap partition record in /etc/fstab, new swap partition uuid or label could be found on sudo blkid