---
title: "Extend a Disk Partition and Filesystem | Hostman Docs"
description: "Extend the partition and EXT4 filesystem of a main or additional disk after resizing it in the dashboard, so Linux can use the new space."
---

> For the complete documentation index for AI agents, see [llms.txt](https://hostman.com/llms.txt).

After you increase a disk's size in the dashboard, extend its partition and filesystem so the OS can use the new space. The process is different depending on whether you [resized the main disk](https://hostman.com/docs/cloud-servers/server-configuration/#resize-a-main-disk) or an [additional disk](https://hostman.com/docs/cloud-servers/server-configuration/#resize-an-additional-disk).

Create a backup before you start.

## Extend the Main Disk

> [!NOTE]
> You only need to do this if you partitioned the main disk manually and it now has two or more partitions. Otherwise, the disk is repartitioned automatically after you [change the plan](https://hostman.com/docs/cloud-servers/server-configuration/#upgrade-the-server-plan) in the dashboard.

### Step 1. Boot the Server in Recovery Mode

See [Boot Mode](https://hostman.com/docs/cloud-servers/boot-mode/). 

### Step 2. Check the Disk Name

Go to the **Console** tab and run:

```shell
lsblk
```

Example output:

```shell
NAME    MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
sda       8:0    0   30G  0 disk 
├─sda1    8:1    0   10G  0 part /
├─sda2    8:2    0   4G  0 part 
├─sda14   8:14   0    4M  0 part 
├─sda15   8:15   0  106M  0 part /boot/efi
└─sda16 259:0    0  913M  0 part /boot
vda     253:0    0    1M  1 disk
```

In this example, `sda` is the system disk. On older servers, it may be called `vda`.

### Step 3. Review the Partition Table

Start `parted` with the system disk name:

```shell
parted /dev/sda
```

Run:

```shell
print
```

On the first run, you may see this message:

```shell
Warning: Not all of the space available to /dev/sda appears to be used, you can fix the GPT to use all of the space (an extra 31457280 blocks) or continue
with the current setting? 
Fix/Ignore?
```

Enter `Fix`. This updates the GPT table so the system can use all free disk space.

The output of `print` lists the partitions.

![7ed673b6 A2a5 4f0b A475 087f9c353782.png](https://content.hostman.com/assets/e7cf86a2-2b14-4c3c-a5c0-6fece0044185.png?width=1018&height=366)

-   To extend the last partition into the free space, go to Step 4a.
-   To create a new partition, go to Step 4b.

Creating several new partitions is beyond the scope of this article.

To delete a partition, run `rm` with the partition number:

```shell
rm <partition_number>
```

### Step 4a. Extend the Last Partition

Run `resizepart` with the partition number and the new end of the partition. Enter `100%` to use all available space:

```shell
resizepart <partition_number> 100%
```

Check the result:

```shell
print
```

Enter `q` to exit `parted` and go to Step 5.

### Step 4b. Create a New Partition

Run `mkpart` with the partition type (`primary` or `extended`), its number, and its size. Enter `100%` to use all available space: 

```shell
mkpart primary <partition_number> 100%
```

Enter `yes` to confirm the new partition size.

Check the result:

```shell
print
```

Enter `q` to exit `parted`.

Create a filesystem on the new partition, specifying its name:

```shell
mkfs.ext4 /dev/sda3
```

### Step 5. Check the Filesystem

Run `e2fsck` on the partition from Step 4 (`/dev/sda2`, `/dev/sda3`, and so on):

```shell
e2fsck -yf /dev/sda2
```

![10e9e2a0 F362 4314 Be34 65e4bec2eecd](https://content.hostman.com/assets/d3755bcf-579b-4742-a847-a4a8c15707d1.png?width=1083&height=200)

### Step 6. Resize the File System

Specify the partition name:

```shell
resize2fs /dev/sda2
```

![82049b53 F718 48ac 907b 81e7ddca35d1](https://content.hostman.com/assets/ace6bda6-207d-4dc6-bbd2-bb02e4486bd7.png?width=963&height=104)

### Step 7. Verify the New Size

Mount the partition you modified (`/dev/sda2`, `/dev/sda3`, and so on):

```shell
mount /dev/sda2 /mnt
```

Check the size:

```shell
df -h
```

![7dc701d2 2ddc 447f B8c7 F40f5f1ea16d](https://content.hostman.com/assets/dce45fd5-21ec-4c16-ac09-413cf5388d24.png?width=775&height=261)

If the size hasn't change, go back to **Step 1** and repeat the procedure.

If the size has changed, unmount the partition:

```shell
umount /mnt
```

### Step 8. Boot the Server in Standard Mode

See [Boot Mode](https://hostman.com/docs/cloud-servers/boot-mode/).

## Extend an Additional Disk

After you resize the disk in the dashboard, check its new size:

```shell
lsblk
```

Example output:

```shell
NAME    MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
sda       8:0    0   25G  0 disk
├─sda1    8:1    0 24.9G  0 part /
├─sda14   8:14   0    4M  0 part
└─sda15   8:15   0  106M  0 part /boot/efi
sdb       8:16   0   20G  0 disk
└─sdb1    8:17   0   10G  0 part
vda     252:0    0    1M  1 disk
```

Here, `sdb` has grown to 20 GB, but the `sdb1` partition is still 10 GB. You need to extend the partition and then the filesystem.

### Step 1. Unmount the Disk

If the disk is mounted through `/etc/fstab`, comment out its entry first so it isn't mounted automatically:

```shell
nano /etc/fstab
```

Find the line for `/dev/sdb1` (or its UUID) and add `#` at the beginning.

Before unmounting, check which processes are using the disk:

```shell
lsof /mnt/disk2
```

If the command returns no output, the disk is safe to unmount. Otherwise, stop the processes or close the applications that use it.

Unmount the disk:

```shell
sudo umount -l /mnt/disk2
```

### Step 2. Extend the Partition

Start `fdisk`:

```shell
fdisk /dev/sdb
```

Then:

1.  Enter `d` to delete the existing partition. If the disk has only one partition, as in this example, it's selected automatically. The data isn't affected.
2.  Enter `n` to create a new partition.
3.  Select the same partition type as before (for example, `p` for primary).
4.  Keep the default starting sector. It must match the previous value.
5.  Keep the default ending sector to use the maximum available size.

When prompted:

```shell
Partition #1 contains a ext4 signature.
Do you want to remove the signature? [Y]es/[N]o:
```

Enter `N` to keep your data.

Enter `w` to write the changes.

After you exit `fdisk`, update the partition table in the kernel. This way, the system recognizes the changes without a reboot:

```shell
partprobe /dev/sdb
```

If the command succeeds, it prints nothing.

Run `lsblk` again to verify that the partition now uses the full size:

```shell
lsblk
```

Example output:

```shell
NAME    MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
sda       8:0    0   25G  0 disk
├─sda1    8:1    0 24.9G  0 part /
├─sda14   8:14   0    4M  0 part
└─sda15   8:15   0  106M  0 part /boot/efi
sdb       8:16   0   20G  0 disk
└─sdb1    8:17   0   20G  0 part
vda     252:0    0    1M  1 disk
```

### Step 3. Extend the Filesystem

> [!NOTE]
> The following commands are for an EXT4 filesystem.

Check the filesystem:

```shell
e2fsck -f /dev/sdb1
```

Resize it:

```shell
resize2fs /dev/sdb1
```

### Step 4. Mount the Disk Again

Mount the disk:

```shell
mount -o barrier=0 /dev/sdb1 /mnt/disk2
```

Then uncomment its entry in `/etc/fstab`:

```shell
nano /etc/fstab
```

Verify the new size:

```shell
df -h
```

Example output:

```shell
Filesystem      Size  Used Avail Use% Mounted on
tmpfs            96M  728K   96M   1% /run
/dev/sda1        25G  2.6G   22G  11% /
tmpfs           479M     0  479M   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
/dev/sda15      105M  6.1M   99M   6% /boot/efi
tmpfs            96M     0   96M   0% /run/user/0
/dev/sdb1        20G   24K   19G   1% /mnt/disk2
```

The disk is ready for use.
