diff --git a/source/_figures/increase-virtual-disk-size/01-increase-virtual-disk-size-original.png b/source/_figures/increase-virtual-disk-size/01-increase-virtual-disk-size-original.png new file mode 100644 index 00000000..db6ec855 Binary files /dev/null and b/source/_figures/increase-virtual-disk-size/01-increase-virtual-disk-size-original.png differ diff --git a/source/_figures/increase-virtual-disk-size/01-increase-virtual-disk-size.png b/source/_figures/increase-virtual-disk-size/01-increase-virtual-disk-size.png new file mode 100644 index 00000000..63a23b1c Binary files /dev/null and b/source/_figures/increase-virtual-disk-size/01-increase-virtual-disk-size.png differ diff --git a/source/_figures/increase-virtual-disk-size/02-increase-virtual-disk-size-original.png b/source/_figures/increase-virtual-disk-size/02-increase-virtual-disk-size-original.png new file mode 100644 index 00000000..91443668 Binary files /dev/null and b/source/_figures/increase-virtual-disk-size/02-increase-virtual-disk-size-original.png differ diff --git a/source/_figures/increase-virtual-disk-size/02-increase-virtual-disk-size.png b/source/_figures/increase-virtual-disk-size/02-increase-virtual-disk-size.png new file mode 100644 index 00000000..207888c5 Binary files /dev/null and b/source/_figures/increase-virtual-disk-size/02-increase-virtual-disk-size.png differ diff --git a/source/guides/maintenance/figures/increase-virtual-disk-size-1.png b/source/guides/maintenance/figures/increase-virtual-disk-size-1.png deleted file mode 100644 index a4692c9a..00000000 Binary files a/source/guides/maintenance/figures/increase-virtual-disk-size-1.png and /dev/null differ diff --git a/source/guides/maintenance/figures/increase-virtual-disk-size-2.png b/source/guides/maintenance/figures/increase-virtual-disk-size-2.png deleted file mode 100644 index 90b1eb28..00000000 Binary files a/source/guides/maintenance/figures/increase-virtual-disk-size-2.png and /dev/null differ diff --git a/source/guides/maintenance/increase-virtual-disk-size.rst b/source/guides/maintenance/increase-virtual-disk-size.rst index e633f506..f2f22719 100644 --- a/source/guides/maintenance/increase-virtual-disk-size.rst +++ b/source/guides/maintenance/increase-virtual-disk-size.rst @@ -1,103 +1,111 @@ .. _increase-virtual-disk-size: -Increase virtual disk size of an image +Increase Virtual Disk Size of an Image ###################################### -This guide describes how to increase the disk size of your prebuilt |CL-ATTR| -image if you need more capacity. +|CL-ATTR| 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 :ref:`KVM image` as +an example to demonstrate the process of increasing disk size and expanding +the last partition to take up the added space. .. contents:: :local: :depth: 1 -Determine the partition order and sizes of the prebuilt image -************************************************************* +Determine disk size and list of partitions +****************************************** -|CL| prebuilt images come in different sizes, ranging from 300 MB to 20 -GB. +There are two methods to find the disk size and the list of partitions of +a pre-built |CL| image. -There are two methods to find the order and sizes of partitions virtual disk -of your prebuilt |CL| image. +Method 1: Use :command:`lsblk` on the VM +======================================== -In both examples, the prebuilt Hyper-V image has a disk size of 8.5 GB with -:file:`/dev/sda3` being the partition for the root filesystem (/) - -Checking :command:`lsblk` on the VM -=================================== - -The first method is to boot up your :abbr:`VM (Virtual Machine)` and -execute the :command:`lsblk` command as shown below: +The first method is to boot up your VM and execute the :command:`lsblk` +command as shown below: .. code-block:: bash - sudo lsblk + lsblk An example output of the :command:`lsblk` command: .. code-block:: console + :emphasize-lines: 4,7 - NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT - sda 8:0 0 8.5G 0 disk - ├─sda1 8:1 0 512M 0 part - ├─sda2 8:2 0 32M 0 part [SWAP] - └─sda3 8:3 0 8G 0 part / + 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. -Checking :file:`config.json` used to build the image -==================================================== +Method 2: Look at the image configuration YAML file +=================================================== -The second method to determine partition to check the :file:`config.json` -file used to create prebuilt image, located in the `releases`_ repository. -For example, to find the size of the Hyper-V\* image version number 20450, +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: #. Go to the `releases`_ repository. -#. Drill down into the `20450 > clear > config > image` directory. -#. Open the :file:`hyperv-config.json` file. -#. Locate the `PartitionLayout` key. - - The example shows 512 MB for the EFI partition, 32 MB for the swap - partition, and 8 GB for the root partition. +#. Drill down into the `31880 > clear > config > image` directory. +#. Download and open the :file:`kvm.yaml` file. +#. 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. .. code-block:: console + :linenos: + :emphasize-lines: 3,9,13,18 - "PartitionLayout" : [ { "disk" : "hyperv.img", - "partition" : 1, - "size" : "512M", - "type" : "EFI" }, - { "disk" : "hyperv.img", - "partition" : 2, - "size" : "32M", - "type" : "swap" }, - { "disk" : "hyperv.img", - "partition" : 3, - "size" : "8G", - "type" : "linux" } ], + 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 ************************** -Once you have determined the disk and partition to be increased, you are -ready to perform the actual increase of the disk, partition, and filesystem. -Power off VM and 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: -To increase the virtual disk size for a prebuilt image, perform the steps -below: +Increase virtual disk size +========================== -#. Shut down your VM if it is running. -#. Use the process defined by your hypervisor or cloud provider to increase +#. Shut down your VM. +#. Use the process defined by your hypervisor or cloud provider to increase the virtual disk size of your |CL| VM. -#. Power up the VM. +#. Power up your VM. +Resize the last partition of the virtual disk +============================================= -Resize the partition of the virtual disk -======================================== - -#. Log in to an account with root privileges. -#. Open a terminal emulator. +#. Log in. +#. Open a terminal window. #. Add the :command:`storage-utils` bundle to install the :command:`parted` and :command:`resize2fs` tools. @@ -105,7 +113,7 @@ Resize the partition of the virtual disk sudo swupd bundle-add storage-utils -#. Launch the `parted` tool. +#. Launch the :command:`parted` tool. .. code-block:: bash @@ -113,21 +121,20 @@ Resize the partition of the virtual disk #. In the `parted` tool, perform these steps: - #. Press :command:`p` to print the partitions table. + a. Press :command:`p` to print the partitions table. #. If the warning message below is displayed, enter :command:`Fix`. .. code-block:: 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 ... + 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? - #. Enter :command:`resizepart [partition number]` where - *[partition number]* is the partition number of the partition to modify. - #. Enter :command:`yes` when prompted. - #. Enter the new End size. + #. Enter :command:`resizepart ` where + ** is the number of the partition to modify. + #. Enter the new `End` size. .. note:: @@ -139,36 +146,37 @@ Resize the partition of the virtual disk An example of this can be seen in Figure 1. #. Enter :command:`q` to exit `parted` when you are finished resizing the - image. + partition. - Figure 1 depicts the described steps to resize the partition of the virtual disk from 8.5GB to 20GB. + Figure 1 depicts the described steps to resize the partition of the + virtual disk from 8.5 GB to 30 GB. - .. figure:: figures/increase-virtual-disk-size-1.png + .. rst-class:: dropshadow + + .. figure:: ../../_figures/increase-virtual-disk-size/01-increase-virtual-disk-size.png :scale: 100 % :alt: Increase root partition size - Figure 1: Increase root partition size. + Figure 1: Increase root partition size Resize the filesystem ===================== -#. Enter :command:`sudo resize2fs -p /dev/[modified partition name]` where - *[modified partition name]* is the partition that was changed in the `parted` +#. Enter :command:`sudo resize2fs -p /dev/` where + ** is the partition that was changed in the `parted` tool. -#. Run the :command:`df -h` to verify that the filesystem size has - increased. +#. Run :command:`lsblk` to verify that the filesystem size has increased. - Figure 2 depicts the described steps to resize the partition of the virtual - disk from 8.5GB to 20GB. + Figure 2 depicts the described steps to resize the filesystem of the virtual + disk from 8.5 GB to 30 GB. - .. figure:: figures/increase-virtual-disk-size-2.png + .. rst-class:: dropshadow + + .. figure:: ../../_figures/increase-virtual-disk-size/02-increase-virtual-disk-size.png :scale: 100 % :alt: Increase root filesystem with resize2fs - Figure 2: Increase root filesystem size after partition has been expanded. + Figure 2: Increase root filesystem with :command:`resize2fs` -**Congratulations!** You have resized the disk, partition, and filesystem. At -this point, the increase in disk capacity is usable. - -.. _releases: https://cdn.download.clearlinux.org/releases/ \ No newline at end of file +.. _releases: https://cdn.download.clearlinux.org/releases/