Studied about LVM since days, but can't proceed

I can show proof of studying if you want. I destroyed my home lab yesterday trying to add disk.

basically, my homelab server was getting full as I had only 20GB of storage. So, I wanted to extend the / partition by adding 200GB extra using LVM. Using LVM, because in the future, I might need to add even more disk space as I am logging a lot of information about the visitors visiting my site.

I studied from a course, read few articles, my problem is I didn't know what was I really doing? I suspect there is some basic preriquisite understanding of the operating system concepts before I am able to do LVM.

Here's what I want to do:

  • Add 200GB disk.
  • Mount it into / partition.
    That's all.

A small step for mankind - and giant work for a man :wink:
LVM consists of PVs, organized in VGs (disk pools), and of LVs.

Do you have a Linux running now?
Where is / mounted? Where is the 200G disk?

lsblk -p

In principal you create a PV on the new disk, add it to a VG, and allocate space from the VG to the LV that is mounted on /

2 Likes

I'll explain what I did.
I added a disk using virtualbox.
lsblk shows that disk as sdb.
Now I created physical volume, then volume group then logical volume.
Now, I had my volume group up and running with 200GB.
BUT, I wanted to mount it at / partition, meanwhile, it got mounted at /mnt/my_volume_group as I followed the tutorial without much understanding.

I've rocky linux running now and a snapshot of vm (That doesn't contain any changes that broke it).

You must extend/grow the current /
Where is it mounted?

[root@localhost ~]# df -H
Filesystem           Size  Used Avail Use% Mounted on
devtmpfs             4.2M     0  4.2M   0% /dev
tmpfs                1.8G  246k  1.8G   1% /dev/shm
tmpfs                688M  582k  687M   1% /run
/dev/mapper/rl-root   19G  6.3G   12G  35% /
/dev/sda1            1.1G  416M  592M  42% /boot
tmpfs                344M  4.1k  344M   1% /run/user/0
[root@localhost ~]# lsblk -p
NAME                    MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
/dev/sda                  8:0    0   20G  0 disk
├─/dev/sda1               8:1    0    1G  0 part /boot
└─/dev/sda2               8:2    0   19G  0 part
  ├─/dev/mapper/rl-root 253:0    0   17G  0 lvm  /
  └─/dev/mapper/rl-swap 253:1    0    2G  0 lvm  [SWAP]
/dev/sr0                 11:0    1 1024M  0 rom

This is it. This is a fresh vm and a disk hasn't been added now.

Add the disk so it shows up in lsblk (perhaps after rescanning the SCSI bus).

Further overview comnands are pvs, vgs, lvs

Then pvcreate the new disk, so pvs lists it.

Then add it to the existing VG named rl
(I guess this is the name. Check with vgs)

Then lvextend the /dev/mapper/rl-root
Check with lvs

Then grow the file system on /dev/mapper/rl-root
The grow command depends on the fs type.
Check fs type and size with df -hT /
(Also lsblk -f shows the fs type.)

1 Like

Here's something that just works(I don't understand it in detail(I will one day)).

pvcreate /dev/sdb

sdb is the new disk added via virtualbox.

vgextend rl /dev/sdb

You get rl as the volume group that you want to extend and /dev/sdb is the physical volume that you want to add.

lvextend -l +100%FREE /dev/rl/root

This will extend the logical volume /dev/rl/root

Finally, grow fs.

xfs_growfs /dev/rl/root
1 Like