# Increase Virtual Disk Size of an Image¶

Clear Linux* OS pre-built images come in different sizes, ranging from 300 MB to 20 GB. This guide describes how to increase the disk size of your pre-built image if you need more capacity. We will use the KVM image as an example to demonstrate the process of increasing disk size and expanding the last partition to take up the added space.

## Determine disk size and list of partitions¶

There are two methods to find the disk size and the list of partitions of a pre-built Clear Linux OS image.

### Method 1: Use lsblk on the VM¶

The first method is to boot up your VM and execute the lsblk command as shown below:

lsblk


An example output of the lsblk command:

NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
fd0      2:0    1    4K  0 disk
sr0     11:0    1 1024M  0 rom
vda    254:0    0  8.6G  0 disk
├─vda1 254:1    0  510M  0 part
├─vda2 254:2    0   33M  0 part [SWAP]
└─vda3 254:3    0    8G  0 part /


An example of this can also be seen in Figure 1.

### Method 2: Look at the image configuration YAML file¶

The second method to look at the image configuration YAML file that was used to produce the image.

For example, to find the size of the KVM image version number 31880, follow these steps:

1. Go to the releases repository.

2. Drill down into the 31880 > clear > config > image directory.

3. Download and open the kvm.yaml file.

4. Locate the targetMedia section.

The example shows a total disk size of 8.54 GB, 512 MB for the EFI partition, 32 MB for the swap partition, and 8 GB for the root partition.

  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 targetMedia: - name: ${bdevice} size: "8.54G" type: disk children: - name:${bdevice}1 fstype: vfat mountpoint: /boot size: "512M" type: part - name: ${bdevice}2 fstype: swap size: "32M" type: part - name:${bdevice}3 fstype: ext4 mountpoint: / size: "8G" type: part 

## Increase virtual disk size¶

Before you can expand the last partition of your image, you must make space available by increasing the virtual disk size. After that, you can resize the last partition and finally resize the filesystem. Follow these steps:

### Increase virtual disk size¶

2. Use the process defined by your hypervisor or cloud provider to increase the virtual disk size of your Clear Linux OS VM.

### Resize the last partition of the virtual disk¶

2. Open a terminal window.

3. Add the storage-utils bundle to install the parted and resize2fs tools.

sudo swupd bundle-add storage-utils

4. Launch the parted tool.

sudo parted

5. In the parted tool, perform these steps:

1. Press p to print the partitions table.

2. If the warning message below is displayed, enter Fix.

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

Fix/Ignore?

3. Enter resizepart <partition number> where <partition number> is the number of the partition to modify.

4. Enter the new End size.

Note

If you want a partition to take up the remaining disk space, then enter the total size of the disk. When you print the partitions table with the p command, the total disk size is shown after the Disk label.

An example of this can be seen in Figure 1.

5. Enter q to exit parted when you are finished resizing the partition.

Figure 1 depicts the described steps to resize the partition of the virtual disk from 8.5 GB to 30 GB.

Figure 1: Increase root partition size

### Resize the filesystem¶

1. Enter sudo resize2fs -p /dev/<modified partition name> where <modified partition name> is the partition that was changed in the parted tool.

2. Run lsblk to verify that the filesystem size has increased.

Figure 2 depicts the described steps to resize the filesystem of the virtual disk from 8.5 GB to 30 GB.

Figure 2: Increase root filesystem with resize2fs