# Quick Guide: Expanding Disks

====================================================================================

### Virtual Disk Expansion

<div id="bkmrk-">  
</div><div id="bkmrk-1.-scan-for-disk-har">1. Scan for disk hardware changes:</div><div id="bkmrk--1"></div>```
 for i in /sys/class/scsi_host/host*/scan; do echo "- - -" > $i; done
 for i in /sys/class/scsi_device/*/device/rescan; do echo "1" > $i; done 
```

2\. Check for updated disk size:

```
lsblk
```

Your output will look something like this:

```
NAME            MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
 sda               8:0    0   120G  0 disk
 ├─sda1            8:1    0   512M  0 part /boot
 └─sda2            8:2    0 103.5G  0 part
   ├─eCloud-root 253:0    0 102.5G  0 lvm  /
   └─eCloud-swap 253:1    0     1G  0 lvm  [SWAP]
 sdc               8:32   0   200G  0 disk
 └─sdc1            8:33   0   200G  0 part
 sr0              11:0    1  1024M  0 rom 
```

<span class="TextRun SCXO5168568 BCX0" data-contrast="none" lang="EN-GB" xml:lang="EN-GB"><span class="NormalTextRun SCXO5168568 BCX0">3. Check partitions using fdisk</span></span>

```
fdisk -l
```

<span class="TextRun SCXO5168568 BCX0" data-contrast="none" lang="EN-GB" xml:lang="EN-GB"><span class="NormalTextRun SCXO5168568 BCX0">Output will look something like this:</span></span>

```
 [root@server ~]# fdisk -l
 Disk /dev/sda: 128.8 GB, 128849018880 bytes, 251658240 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 label type: dos
 Disk identifier: 0x000b9cfe
    Device Boot      Start         End      Blocks   Id  System
 /dev/sda1   *        2048     1050623      524288   83  Linux
 /dev/sda2         1050624   218103774   108526575+  8e  Linux LVM 
```

<span class="TextRun SCXO5168568 BCX0" data-contrast="none" lang="EN-GB" xml:lang="EN-GB"><span class="NormalTextRun SCXO5168568 BCX0">4. Run growpart against the expanded device:</span></span>

```
growpart /dev/sda 2
```

<span class="TextRun SCXO5168568 BCX0" data-contrast="none" lang="EN-GB" xml:lang="EN-GB"><span class="NormalTextRun SCXO5168568 BCX0">5. Run pvresize command against the partition:</span></span>

```
pvresize /dev/sda2
```

6\. Resize the logical volume, ensure to replace vg and lv with the appropriate values (these will typically be the same as seen on df -h):

```
lvresize -rl +100%FREE /dev/mapper/vg/lv
```

7\. Check that the space has been applied to the filesystem:

```
df -h
```

====================================================================================

### Physical Disk Expansion (Additional Disk)

<div id="bkmrk-1.-scan-for-disk-har-1">1. Scan for disk hardware changes:</div><div id="bkmrk--2"></div>```
 for i in /sys/class/scsi_host/host*/scan; do echo "- - -" > $i; done
 for i in /sys/class/scsi_device/*/device/rescan; do echo "1" > $i; done 
```

2\. Check for updated disk size:

```
lsblk
```

Your output will look something like this:

```
NAME                MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda                   8:0    0 111.3G  0 disk
├─sda1                8:1    0     1G  0 part /boot
└─sda2                8:2    0 110.3G  0 part
  ├─vg_main-lv_root 253:0    0   105G  0 lvm  /
  └─vg_main-lv_swap 253:1    0     4G  0 lvm  [SWAP]
sdb                   8:16   0 111.8G  0 disk /mnt
sdc                   8:32   0 237.9G  0 disk
```

In this example, the additional disk is /dev/sdc.

3\. Create a new partition on the additional disk:

```
fdisk /dev/sdc
```

Once you've run the above command, you'll be entered into the fdisk prompt, the below options are typically suitable:

p - print

n - make new partition

p - primary

w - write

4\. Check the physical volume and create a new physical volume on the new partition:

```
[root@test ~]# pvs
  PV         VG      Fmt  Attr PSize    PFree
  /dev/sda2  vg_main lvm2 a--  <110.25g <1.25g
```

 Create a new physical volume on the new partition:

```
pvcreate /dev/sdc1
```

Show new Physical Volume

```
[root@test ~]# pvs
  PV         VG      Fmt  Attr PSize    PFree
  /dev/sda2  vg_main lvm2 a--  <110.25g  <1.25g
  /dev/sdc1          lvm2 ---   237.87g 237.87g
```

6: Extend the volume group “vg\_main” over the new partition

```
vgextend vg_main /dev/sdc1
```

Show volume group

```
[root@test ~]# vgs
  VG      #PV #LV #SN Attr   VSize    VFree
  vg_main   2   2   0 wz--n- <348.12g <239.12g
```

7\. Resize the logical volume, ensure to replace vg and lv with the appropriate values (these will typically be the same as seen on df -h):

```
lvresize -rl +100%FREE /dev/mapper/vg/lv
```

8\. Check that the space has been applied to the filesystem:

```
df -h
```