You are on page 1of 5

Increase Virtual Disk Size of an Image — Documentation for Clear L... https://www.clearlinux.org/clear-linux-documentation/guides/mainten...

• Home • About • Developer • Software


 / Get started / Increase Virtual Disk Size of an Image

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 par��on to take up the added space.

• Determine disk size and list of par��ons


• Increase virtual disk size

Determine disk size and list of partitions


There are two methods to find the disk size and the list of par��ons 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:

bash

lsblk

An example output of the lsblk command:

Console

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

1 di 5 12/09/2023, 15:29
Increase Virtual Disk Size of an Image — Documentation for Clear L... https://www.clearlinux.org/clear-linux-documentation/guides/mainten...
The second method to look at the image configura�on 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 sec�on.

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

Console

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

Increase virtual disk size


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

Increase virtual disk size

1. Shut down your VM.


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

Resize the last partition of the virtual disk

1. Log in.
2. Open a terminal window.
3. Add the storage-u�ls bundle to install the parted and resize2fs tools.
2 di 5 12/09/2023, 15:29
Increase Virtual Disk Size of an Image — Documentation for Clear L... https://www.clearlinux.org/clear-linux-documentation/guides/mainten...
bash

sudo swupd bundle-add storage-utils

4. Launch the parted tool.

bash

sudo parted

5. In the parted tool, perform these steps:

a. Press p to print the par��ons table.


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

Console

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?

c. Enter resizepart <par��on number> where <par��on number> is the number of the par��on to
modify.
d. Enter the new End size.

 Note

If you want a par��on to take up the remaining disk space, then enter the total size of the
disk. When you print the par��ons table with the p command, the total disk size is shown
a�er the Disk label.

An example of this can be seen in Figure 1.

e. Enter q to exit parted when you are finished resizing the par��on.

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

3 di 5 12/09/2023, 15:29
Increase Virtual Disk Size of an Image — Documentation for Clear L... https://www.clearlinux.org/clear-linux-documentation/guides/mainten...

Figure 1: Increase root par��on size

Resize the filesystem

1. Enter sudo resize2fs -p /dev/<modified par��on name> where <modified par��on name> is the
par��on 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.

4 di 5 12/09/2023, 15:29
Increase Virtual Disk Size of an Image — Documentation for Clear L... https://www.clearlinux.org/clear-linux-documentation/guides/mainten...

Figure 2: Increase root filesystem with resize2fs

*Other names and brands may be claimed as the property of others.

*Trademarks Cookies Privacy Terms

5 di 5 12/09/2023, 15:29

You might also like