> ## Documentation Index
> Fetch the complete documentation index at: https://docs.apinizer.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Disk Expansion on Linux

> Step-by-step explanation of how to configure a new disk added to a Linux system using LVM (Logical Volume Manager). Covers creating physical volume, adding to volume group, and expanding logical volume operations.

<Warning>
  <strong>Very Important:</strong> This is a risky operation and is not recommended if the server does not have a backup.
</Warning>

## Checking Disks

To list disks in the system:

```bash theme={null}
lsblk
```

<img src="https://mintcdn.com/apinizer/LoT_QidIA2t_0Oih/images/operations/disk-genisletme1.png?fit=max&auto=format&n=LoT_QidIA2t_0Oih&q=85&s=92e6b6cc4b34a360f29b45800548f829" alt="Disk List" width="800" height="400" style={{ borderRadius: '0.5rem' }} data-path="images/operations/disk-genisletme1.png" />

As seen in the image, the added disk appears as **/dev/sdb**. Example commands will proceed with **/dev/sdb**.

## Creating Partition on New Disk

```bash theme={null}
sudo fdisk /dev/sdb
```

Follow the steps below in the `fdisk` interface:

<Steps>
  <Step title="Add New Partition">
    Press <code>n</code> key and create a new partition.
  </Step>

  <Step title="Select Type">
    Press <code>p</code> key to create a primary partition.
  </Step>

  <Step title="Enter Partition Number">
    Type <code>1</code> to specify the partition number.
  </Step>

  <Step title="Use Default Settings">
    Press <code>Enter</code> key (twice) to accept all default settings.
  </Step>

  <Step title="Write and Exit">
    Press <code>w</code> key to save changes.
  </Step>
</Steps>

## Creating Physical Volume

```bash theme={null}
sudo pvcreate /dev/sdb1
```

## Listing Volume Groups

```bash theme={null}
vgdisplay
```

<img src="https://mintcdn.com/apinizer/LoT_QidIA2t_0Oih/images/operations/disk-genisletme2.png?fit=max&auto=format&n=LoT_QidIA2t_0Oih&q=85&s=6d7395041db45e1e3ffc05510ec72c94" alt="Volume Group List" width="800" height="400" style={{ borderRadius: '0.5rem' }} data-path="images/operations/disk-genisletme2.png" />

## Adding New Disk to Existing Volume Group

You can use the following command to add the `/dev/sdb1` disk to the volume group in your system:

```bash theme={null}
sudo vgextend <VG-NAME> /dev/sdb1
```

## Listing Logical Volumes

```bash theme={null}
lvdisplay
```

<img src="https://mintcdn.com/apinizer/LoT_QidIA2t_0Oih/images/operations/disk-genisletme3.png?fit=max&auto=format&n=LoT_QidIA2t_0Oih&q=85&s=833dc027171c7fb87489be6c854ac0a8" alt="Logical Volume List" width="800" height="400" style={{ borderRadius: '0.5rem' }} data-path="images/operations/disk-genisletme3.png" />

## Expanding Logical Volume

To expand the logical volume named **ubuntu-lv** in the volume group named ubuntu-vg with 100% free space, you can run the following command:

```bash theme={null}
sudo lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv
```

## Expanding File System

```bash theme={null}
sudo resize2fs /dev/ubuntu-vg/ubuntu-lv
```
