> For the complete documentation index, see [llms.txt](https://docs.glesys.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.glesys.com/products/compute/vmware-virtual-machines/how-tos/resize-virtual-machines/increase-the-partition-size-in-linux-vms-created-before-2018.md).

# Increase the partition size in Linux VMs created before 2018

***

{% hint style="info" %}
This applies only to servers created before 2018-02-01. For servers created after this date, expanding the disk space via the control panel is sufficient.
{% endhint %}

{% hint style="danger" %}
This maneuver is performed at your own risk; make a backup before modifying partition tables and file systems.
{% endhint %}

After you expand the disk by dragging the slider in the control panel, the server will restart. Once the server has rebooted, log in as root and run the following:

{% code title="Command" %}

```
fdisk /dev/sda
```

{% endcode %}

You are now inside the `fdisk` utility. Print the current partitions with `p`.

<pre data-title="fdisk session. Prompts and commands are highlighted."><code><strong>Command (m for help): p
</strong>
Disk /dev/sda: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 cylinders, total 62914560 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00026e2c

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048      391167      194560   83  Linux
/dev/sda2          391168     2344959      976896   82  Linux swap / Solaris
/dev/sda3         2344960    62914559    30284800   83  Linux
</code></pre>

Remove the partition you wish to expand using `d`. In this case, it's the last partition, number 3.

<pre data-title="fdisk session. Prompts and commands are highlighted."><code><strong>Command (m for help): d
</strong><strong>Partition number (1-4): 3
</strong></code></pre>

Create a new partition with `n`. Then, press <kbd>Enter</kbd> to accept the defaults (but double-check everything so it makes sense).

<pre data-title="fdisk session. Prompts and commands are highlighted."><code><strong>Command (m for help): n
</strong>Partition type:
p   primary (2 primary, 0 extended, 2 free)
e   extended
<strong>Select (default p):
</strong>Using default response p
<strong>Partition number (1-4, default 3):
</strong>Using default value 3
<strong>First sector (2344960-83886079, default 2344960):
</strong>Using default value 2344960
<strong>Last sector, +sectors or +size{K,M,G} (2344960-83886079, default 83886079):
</strong>Using default value 83886079
</code></pre>

Finally, you write the partition table to the disk with `w`.

<pre><code><strong>Command (m for help): w
</strong>The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.
</code></pre>

Now that the partition has been expanded, reboot the server so the operating system reads the new partition table. After the server has restarted, log in as root again and run:

{% code title="Command" %}

```
resize2fs /dev/sda3
```

{% endcode %}

This will output something similar to this:

{% code title="Output" %}

```
resize2fs 1.42.5 (29-Jul-2012)
Filesystem at /dev/sda3 is mounted on /; on-line resizing required
old_desc_blocks = 2, new_desc_blocks = 3
Performing an on-line resize of /dev/sda3 to 10192640 (4k) blocks.
The filesystem on /dev/sda3 is now 10192640 blocks long.
```

{% endcode %}

If you now run `df -h`, you should see that the filesystem has been expanded and more disk space is available.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.glesys.com/products/compute/vmware-virtual-machines/how-tos/resize-virtual-machines/increase-the-partition-size-in-linux-vms-created-before-2018.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
