3

nvme0n1p3 has 8.5G, ubuntu--vg-ubuntu--lv has 4G. How can I expand ubuntu--vg-ubuntu--lv to 8G?

 NAME                      MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT 
nvme0n1                   259:0    0   10G  0 disk 
├─nvme0n1p1               259:1    0  512M  0 part /boot/efi
├─nvme0n1p2               259:2    0    1G  0 part /boot
└─nvme0n1p3               259:3    0  8.5G  0 part 
  └─ubuntu--vg-ubuntu--lv 253:0    0    4G  0 lvm  /

When I try to do vgextend ubuntu--vg-ubuntu--lv /dev/nvme0n1p3 it says

Physical volume '/dev/nvme0n1p3' is already in volume group 'ubuntu-vg'
Unable to add physical volume '/dev/nvme0n1p3' to volume group 'ubuntu-vg'
  /dev/nvme0n1p3: physical volume not initialized.

1 Answer 1

4

The procedure is relatively sample. First you need to extend the LV:

lvextend -L+1GB /dev/mapper/ubuntu--vg-ubuntu--lv

The last command add 1 GB space to / and then extend your filesystem. If it's ext4 use command:

resize2fs /

If its XFS you can use command

xfs_growfs -d /

Both resize commands can be done on the fly (w/o unmount the filesystem)

5
  • 1
    lvextend has a option to resize the file system as part of growing the LV. Use -r or --resizefs.
    – doneal24
    Sep 17, 2022 at 17:08
  • @doneal24, never used and prefer one command, one function :) Sep 17, 2022 at 17:09
  • Is creating a larger usable file system on disk one function that can be done in one command? The UNIX philosophy is good overall but can be taken too far. Not criticism as I generally agree with you here but should we tell newcomers not to use parted because all of its features can be duplicated with fdisk and file system utilities?
    – doneal24
    Sep 17, 2022 at 17:18
  • @doneal24, for some cases I agree with you, but in this particular I prefer to be more conservative :) Sep 17, 2022 at 17:22
  • 2
    @doneal24 Because of how it handles the resize, lvextend is not guaranteed to be able to resize arbitrary filesystems. IIRC, right now it only properly supports ext*, XFS, and ReiserFS. By just choosing to do the resize yourself, you avoid having to deal with such issues. Sep 18, 2022 at 0:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .