Skip to content

Instantly share code, notes, and snippets.

@csamsel
Created June 14, 2018 19:57
Show Gist options
  • Save csamsel/a6bd13b0963bcdf2eaf34eea27632a4a to your computer and use it in GitHub Desktop.
Save csamsel/a6bd13b0963bcdf2eaf34eea27632a4a to your computer and use it in GitHub Desktop.
resize ext4 root partition in ubuntu under ESXi
# parted /dev/sda
GNU Parted 3.2
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) rm 3
(parted) p
Model: VMware Virtual disk (scsi)
Disk /dev/sda: 32.2GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 1049kB 538MB 537MB fat32 EFI System Partition boot, esp
2 538MB 12.9GB 12.3GB ext4
(parted) resizepart
Partition number? 2
Warning: Partition /dev/sda2 is being used. Are you sure you want to continue?
Yes/No? yes
End? [12.9GB]? 28GB
(parted) p
Model: VMware Virtual disk (scsi)
Disk /dev/sda: 32.2GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 1049kB 538MB 537MB fat32 EFI System Partition boot, esp
2 538MB 28.0GB 27.5GB ext4
(parted) quit
Information: You may need to update /etc/fstab.
root@unifi:~# resize2fs /dev/sda2
resize2fs 1.44.1 (24-Mar-2018)
Filesystem at /dev/sda2 is mounted on /; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 2
The filesystem on /dev/sda2 is now 6704609 (4k) blocks long.
@adrianmihalko
Copy link

I got error:

madrian@ubuntu:~$ sudo parted
GNU Parted 3.4
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print                                                            
Model: VMware Virtual disk (scsi)
Disk /dev/sda: 137GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags: 

Number  Start   End     Size    Type      File system     Flags
 1      65.5kB  56.9GB  56.9GB  primary   ext4            boot
 2      56.9GB  59.1GB  2146MB  extended
 5      56.9GB  59.1GB  2145MB  logical   linux-swap(v1)

(parted) resizepart                                                       
Partition number? 2                                                       
Warning: Partition /dev/sda2 is being used. Are you sure you want to continue?
Yes/No? yes                                                               
End?  [59.1GB]? 128                                                       
Error: Can't have the end before the start! (start sector=111151104 length=-110901103)
(parted)                                                                  

@csamsel
Copy link
Author

csamsel commented Feb 11, 2023

@adrianmihalko i assume you meant to enter 128GB instead of 128?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment