0

I create an Oracle Linux 9.4 as a kvm Guest initially with 40G virtual hard disk After a while I needed to increase the disk size to 60G so I did it with qemu-img resize /media/kvm/storage1/oracle-9.4 +20G. However I was not able to resize the root partion inside Oracle Linux. After some trying I end up with this

# fdisk -l
Disc /dev/vda: 60 GiB, 64424509440 bytes, 125829120 sectors
Units: sector de 1 * 512 = 512 bytes
Size de setor (log/phys): 512 bytes / 512 bytes
Size I/O (mínimo/ótimo): 512 bytes / 512 bytes
Type: dos
Id: 0x86f77589

Dev       boot             Start     End    Sectors     size Id Type
/dev/vda1   *               2048   2099199  2097152      1G 83 Linux
/dev/vda2                2099200  85985279 83886080     40G 8e Linux LVM
/dev/vda3               85985280 125829119 39843840     19G 83 Linux


Disc /dev/mapper/ol-root: 57,99 GiB, 62268637184 bytes, 121618432 sectors
Units: setor de 1 * 512 = 512 bytes
Size de sector (log/phys): 512 bytes / 512 bytes
Size I/O (min/best): 512 bytes / 512 bytes
# lsblk 
NAME        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
sr0          11:0    1 1024M  0 rom  
vda         251:0    0   60G  0 disk 
├─vda1      251:1    0    1G  0 part /boot
├─vda2      251:2    0   40G  0 part 
│ └─ol-root 252:0    0   58G  0 lvm  /
└─vda3      251:3    0   19G  0 part 
  └─ol-root 252:0    0   58G  0 lvm  /
# df -h
File system.           Tam. Used Disp. Use% Mounted 
devtmpfs             4,0M     0  4,0M   0% /dev
tmpfs                3,7G     0  3,7G   0% /dev/shm
tmpfs                1,5G  9,4M  1,5G   1% /run
/dev/mapper/ol-root   39G   35G  5,0G  88% /
/dev/vda1            960M  553M  408M  58% /boot
tmpfs                749M  896K  748M   1% /run/user/1000

I would like to have all 58GB in the / mount point

1 Answer 1

0

You have gotten most of the way through the process. You have added a new partition, made a PV (physical volume) out of that partition, and extended the VG (Volume Group) to include that new PV. Now you just need to expand the LV (Logical Volume) and filesystem.

Most of the time, you can expand both in a single command, something similar to

# lvextend -L +60G -r /dev/mapper/ol-root

This command will tell your system to expand the ol-root logical volume (/dev/mapper/ol-root) by 60 G (-L +60G), and to also expand the filesystem to the largest size possible within that logical volume (-r).

In some rare cases, the lvextend command may not understand the filesystem you're using or the filesystem can only be expanded when unmounted. these are very rare cases.

3
  • Thanks @johnI tried this command but here is the return Insufficient free space: 15360 extents needed, but only 0 available I have run lvextend -L +60G -r /dev/mapper/ol-root Commented Oct 4, 2024 at 13:20
  • Then something didn't complete the way it should have in previous steps. Check to make sure the disk actually expanded. Check to make sure the new space is in vda3. Check to make sure that PV expanded, or to make sure you added a new partition (vda4) and made a PV on it and added that new PV to the VG. Commented Oct 4, 2024 at 13:34
  • In one of my first attempts I decided to remove a partition that was already in LVM and the guest stop booting. Then after some search I found a link link that shows how to mount a qcow2 file and then using fdisk I was able to restore the guest. Some days ago I have learned to use the Web Console (cockpit.service) and using this graphical tool I was able to increase the root partion of the Oracle Linux (guest) although I do not know exactly how I did it Commented Oct 16, 2024 at 4:39

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.