How to add unallocated disk space to LVM /home

I’m familiar with the lvextend command but it won’t work in this case. Do I have to create a partition to get the unallocated space into the LVM?

(parted) print free
Model: DELL PERC H710 (scsi)
Disk /dev/sda: 1799GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags: 

Number  Start   End     Size    Type     File system  Flags
        1024B   1049kB  1048kB           Free Space
 1      1049kB  2001MB  2000MB  primary  ext4         boot
 2      2001MB  1519GB  1517GB  primary               lvm
        1519GB  1799GB  280GB            Free Space


fdisk -l
Disk /dev/sda: 1.7 TiB, 1799054426112 bytes, 3513778176 sectors
Disk model: PERC H710       
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xa23c34a0

Device     Boot   Start        End    Sectors  Size Id Type
/dev/sda1  *       2048    3907583    3905536  1.9G 83 Linux
/dev/sda2       3907584 2966028287 2962120704  1.4T 8e Linux LVM

Disk /dev/mapper/ourserver-root: 279.4 GiB, 300001787904 bytes, 585940992 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk /dev/mapper/ourserver-swap: 15.5 GiB, 16588472320 bytes, 32399360 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk /dev/mapper/ourserver-var: 186.3 GiB, 200001191936 bytes, 390627328 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk /dev/mapper/ourserver-usr_local: 186.3 GiB, 200001191936 bytes, 390627328 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk /dev/mapper/ourserver-home: 745.1 GiB, 800000573440 bytes, 1562501120 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
1 Like
  • Expand the /dev/sda2 partition with parted/GParted.
  • Expand the /dev/sda2 PV:
sudo pvresize /dev/sda2
  • Expand the LV and FS:
sudo lvextend -r -l +100%FREE /dev/VGNAME/LVNAME
1 Like

There’s only 8.00MB left on /dev/sda2. How do I get the unallocated space noted from the screenshot? Do I need to create a partition for that?

You can resize the /dev/sda2 partition using the following free space, which is unallocated 261.19 GiB on your screenshot.

1 Like

Well that didn’t work. Only added the 1 MB.

pvresize /dev/sda2
  WARNING: Failed to connect to lvmetad. Falling back to device scanning.
  Physical volume "/dev/sda2" changed
  1 physical volume(s) resized or updated / 0 physical volume(s) not resized

Disk /dev/mapper/fedora_home: 745.1 GiB, 800000573440 bytes, 1562501120 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

and then I ran:

  WARNING: Failed to connect to lvmetad. Falling back to device scanning.
  Size of logical volume fedoras/home changed from <745.06 GiB (190735 extents) to <745.07 GiB (190737 extents).
  Logical volume fedora/home successfully resized.
meta-data=/dev/mapper/fedora-home isize=512    agcount=4, agsize=48828160 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=1, sparse=0, rmapbt=0
         =                       reflink=0
data     =                       bsize=4096   blocks=195312640, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0, ftype=1
log      =internal log           bsize=4096   blocks=95367, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data blocks changed from 195312640 to 195314688

In GParted, did you try right clicking on /dev/sda2 and clicking “Resize”?

2 Likes

Sorry missed that step as well as running the actual operation in GParted.

pvresize /dev/sda2
  WARNING: Failed to connect to lvmetad. Falling back to device scanning.
  Physical volume "/dev/sda2" changed
  1 physical volume(s) resized or updated / 0 physical volume(s) not resized

Then ran:

lvextend -r -l +100%FREE /dev/mapper/fedora-home
  WARNING: Failed to connect to lvmetad. Falling back to device scanning.
  Size of logical volume fedora/home changed from <745.07 GiB (190737 extents) to 1006.25 GiB (257601 extents).
  Logical volume fedora/home successfully resized.
meta-data=/dev/mapper/fedora-home isize=512    agcount=5, agsize=48828160 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=1, sparse=0, rmapbt=0
         =                       reflink=0
data     =                       bsize=4096   blocks=195314688, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0, ftype=1
log      =internal log           bsize=4096   blocks=95367, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data blocks changed from 195314688 to 263783424

Finally:

df -h
[...]
/dev/mapper/fedora-home      1006G  514G  493G  52% /u/ourusers

All good now. Still have to test a reboot.

Side question, why this warning?

WARNING: Failed to connect to lvmetad. Falling back to device scanning

sudo journalctl -u lvm2-lvmetad.service -u lvm2-lvmetad.socket