Home>

Hello everyone,

I rented a cloud server for Ubuntu with 20GB and additional disk space for 10GB (this is a test server, the real numbers will be higher). The screenshot shows how the space is allocated by default:

I would like to merge the two drives into one 30GB disk space so that any directory in the root directory can use all the free space, without breakdowns or anything else. I thought to use LVM for this (combine two volumes into a group and create a logical volume based on it), but the problem is that /dev /sda1 is not initialized as a Physical Volume, which means I cannot manipulate it through LVM. I tried the commandpvcreate /dev /sda1, but I get the error "Can't open /dev /sda1 exclusively. Mounted filesystem?" -as I understand it, the matter is that the disk is being used by the system.

Question: is it possible to combine sda1 and sdb into a volume group (and then create one logical volume) and how to do it?

P.S. If this cannot be done through LVM, I am ready to consider other options, since I am only interested in the final result.

I will assume that you need to boot from disk (I do not know about yours, but at least VPS /VDS hosting services usually allow you to download your ISO image) and reinstall the system from LVM

andreymal2021-09-26 13:09:11

Support, easier to reinstall with LVM setup. But if there is no time, the hoster does not give, something else ... Maybe it's easier to make symlinks for heavy directories on an additional disk and not bother?

Andrey Mihalev2021-09-26 13:09:11
  • Answer # 1

    You can't. They need to be formatted as PV first. This cannot be done on a system running from this disk. You need to reinstall the system to LVM.

    Without this, you can do the following maneuver: shrink the file system, shrink the /dev /sda1 partition to 1.55GB, create a new partition and create an LVM volume on it, move the root and fix the bootloader.

    The hardest part of this maneuver is to shrink the live section:

    If you have access to the server console, it's easier to reboot into initrd.