Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

In order to use the new volume, there are several possibility. Here, we show how to extend an existing partition on the disk to use the added volumeadded volume.

In this example, we have a 10 GB partition, which we want to increase to 20 GB.

Running `df -h` should show the previous size of the mounted partition, with output like

```

Filesystem Size Used Avail Use% Mounted on
udev 3.9G 0 3.9G 0% /dev
tmpfs 798M 760K 797M 1% /run
/dev/vda1 15G 11G 3.7G 75% /
tmpfs 3.9G 0 3.9G 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
/dev/vda15 105M 8.9M 96M 9% /boot/efi
/dev/vdb1 9.8G 3.1G 6.3G 33% /data-1
tmpfs 798M 0 798M 0% /run/user/352200006

```

Where `/dev/vdb1` is the partition which we want to increase.

  1. Check if the command line tool `parted` is installed, e.g. call `parted --help`
  2. Make sure you have sudo rights on the VM
  3. If you just execute `parted`, you will land in on the parted console, which you can exit typing `quit`.
  4. Launch parted as superuser.
  5. Type the command `print all` which should show information about the partitions ```

    (parted) print all
    Model: Virtio Block Device (virtblk)
    Disk /dev/vdb: 21.5GB
    Sector size (logical/physical): 512B/512B
    Partition Table: msdos
    Disk Flags:

    Number Start End Size Type File system Flags
    1 1049kB 10.7GB 10.7GB primary ext4


    Model: Virtio Block Device (virtblk)
    Disk /dev/vda: 16.1GB
    Sector size (logical/physical): 512B/512B
    Partition Table: gpt
    Disk Flags:

    Number Start End Size File system Name Flags
    14 1049kB 5243kB 4194kB bios_grub
    15 5243kB 116MB 111MB fat32 boot, esp
    1 116MB 16.1GB 16.0GB ext4

    ```

    Which shows, that the volume has been extended to the desired size, but the partition is not using it entirely.
  6. Select the partition you want to extend typing `select /dev/vdb`. The command `print` should now show only information on this disk.
  7. Now, type the command `resizepart` and give the relevant answers. In this example: Partition number? 1; Are you sure you want to continue? Yes; End? 100%; 
    (parted) resizepart
    Partition number? 1
    Warning: Partition /dev/vdb1 is being used. Are you sure you want to continue?
    Yes/No? Yes
    End? [10.7GB]? 100%
  8. Now `print` should show that the partition is now using the entire disk space.
  9. Type `quit` to exit the parted console.

Now, we still need to tell the filesystem to use the entire partition. This can be done using typing using the command resize2fs, which in this example is `sudo resize2fs /dev/vdb1`.

Now, running `df -h` will show the correct size.