How to extend an EXT4 partition using parted and resize2fs

Firstly, we want to extend the partition using parted:

Bash:
root@cana:~# parted /dev/sda
GNU Parted 3.2
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) resizepart 1                                                  
Warning: Partition /dev/sda1 is being used. Are you sure you want to continue?
Yes/No? Yes                                                            
End?  [275GB]? -0                                                      
(parted) quit                                                          
Information: You may need to update /etc/fstab.

root@cana:~#


Hint:

  • resizepart 1 to resize /dev/sda1
  • -0 resizes it to the end of the disk. - Indicates that it should count from the end of the disk, not the start. This makes -0 the last sector of the disk - which is suitable when you want to make it as big as possible.


If we type df -H it will still showing the old size:

Bash:
root@cana:~# df -H
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1       271G  240G   18G  94% /
udev             11M     0   11M   0% /dev
tmpfs           1.3G  8.8M  1.3G   1% /run
tmpfs           3.2G   25k  3.2G   1% /dev/shm
tmpfs           5.3M     0  5.3M   0% /run/lock
tmpfs           3.2G     0  3.2G   0% /sys/fs/cgroup
root@cana:~#


Secondly, we need to use resize2fs to extend the volume:
(The file system meta information needs to indicate the size of the disk, and resize2fs updates this.)

Bash:
root@cana:~# resize2fs /dev/sda1
resize2fs 1.42.12 (29-Aug-2014)
Filesystem at /dev/sda1 is mounted on /; on-line resizing required
old_desc_blocks = 16, new_desc_blocks = 29
The filesystem on /dev/sda1 is now 117964544 (4k) blocks long.

root@cana:~#
  • resize2fs, parted
  • 5 Users Found This Useful
Was this answer helpful?

Related Articles

How to create a .ppk from private key on Windows

Using a Public/Private key to authenticate when logging into SSH can provide added convenience or...

Connecting using PuTTY on Windows workstations

Configuring PuTTY In PuTTY, under Session, enter your Host Name Under Connection choose Data...

Connecting using SSH on Linux or OSX workstations

Use the ssh command to connect to your instance. Specify your username and the external IP...

How to connect to MySQL (Web interface & CLI)

Web Interface Adminer is a database management web applicarion URL :...

How to install the php-mcrypt module on a Plesk server

Question How to install the php-mcrypt module on a Plesk server? Answer Notes: The solution in...