Figuring out how to add space to fedora partition

continuation of

solution

how do I take this free space and give it to partition 3?
image

Tried following this guide

initial df -h

df -h                                                                                                                                                                                        (base) 
Filesystem                               Size  Used Avail Use% Mounted on
devtmpfs                                 7.8G     0  7.8G   0% /dev
tmpfs                                    7.8G     0  7.8G   0% /dev/shm
tmpfs                                    3.2G  2.2M  3.2G   1% /run
tmpfs                                    4.0M     0  4.0M   0% /sys/fs/cgroup
/dev/mapper/fedora_localhost--live-root   69G   61G  4.6G  94% /
tmpfs                                    7.8G  3.6M  7.8G   1% /tmp
/dev/nvme0n1p2                           976M  354M  555M  39% /boot
/dev/mapper/fedora_localhost--live-home  156G   49G   99G  34% /home
/dev/nvme0n1p1                           599M   21M  579M   4% /boot/efi
/dev/sda1                                932G  898G   34G  97% /mnt/sda1
tmpfs                                    1.6G  212K  1.6G   1% /run/user/1000

vgs output

vgs                                                                                                                                                                                         (base) 
  VG                    #PV #LV #SN Attr   VSize    VFree  
  fedora_localhost-live   2   3   0 wz--n- <475.35g 238

fdisk -l output for the nvme drive

Disk /dev/nvme0n1: 476.94 GiB, 512110190592 bytes, 1000215216 sectors
Disk model: KXG6AZNV512G TOSHIBA                    
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: gpt
Disk identifier: 1142DC35-FEE5-477D-A2E2-A752EBD2B7EE

Device             Start        End   Sectors   Size Type
/dev/nvme0n1p1      2048    1230847   1228800   600M EFI System
/dev/nvme0n1p2   1230848    3327999   2097152     1G Linux filesystem
/dev/nvme0n1p3   3328000  500117503 496789504 236.9G Linux LVM
/dev/nvme0n1p4 500117504 1000214527 500097024 238.5G Linux filesystem


Disk /dev/mapper/fedora_localhost--live-root: 70 GiB, 75161927680 bytes, 146800640 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/fedora_localhost--live-swap: 7.89 GiB, 8468299776 bytes, 16539648 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/zram0: 4 GiB, 4294967296 bytes, 1048576 sectors
Units: sectors of 1 * 4096 = 4096 bytes
Sector size (logical/physical): 4096 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes


Disk /dev/mapper/fedora_localhost--live-home: 159 GiB, 170724950016 bytes, 333447168 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

lvresize (from another guide)

lvresize -L +5G --resizefs /dev/mapper/fedora_localhost--live-home                                                                                                                          (base) 
  Size of logical volume fedora_localhost-live/home changed from 159.00 GiB (40704 extents) to 164.00 GiB (41984 extents).
  Logical volume fedora_localhost-live/home successfully resized.
resize2fs 1.45.6 (20-Mar-2020)
Filesystem at /dev/mapper/fedora_localhost--live-home is mounted on /home; on-line resizing required
old_desc_blocks = 20, new_desc_blocks = 21
The filesystem on /dev/mapper/fedora_localhost--live-home is now 42991616 (4k) blocks long.

current lsblk

lsblk                                                                                                                                                                                        (base) 
NAME                            MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda                               8:0    0 931.5G  0 disk 
└─sda1                            8:1    0 931.5G  0 part /mnt/sda1
sdb                               8:16   0 223.6G  0 disk 
├─sdb1                            8:17   0 223.1G  0 part 
└─sdb2                            8:18   0   467M  0 part 
sdc                               8:32   0 447.1G  0 disk 
└─sdc1                            8:33   0 447.1G  0 part 
sr0                              11:0    1  1024M  0 rom  
zram0                           252:0    0     4G  0 disk [SWAP]
nvme0n1                         259:0    0 476.9G  0 disk 
├─nvme0n1p1                     259:1    0   600M  0 part /boot/efi
├─nvme0n1p2                     259:2    0     1G  0 part /boot
├─nvme0n1p3                     259:3    0 236.9G  0 part 
│ ├─fedora_localhost--live-root 253:0    0    75G  0 lvm  /
│ ├─fedora_localhost--live-swap 253:1    0   7.9G  0 lvm  [SWAP]
│ └─fedora_localhost--live-home 253:2    0   164G  0 lvm  /home
└─nvme0n1p4                     259:4    0 238.5G  0 part 
  ├─fedora_localhost--live-root 253:0    0    75G  0 lvm  /
  └─fedora_localhost--live-home 253:2    0   164G  0 lvm  /home

current fdisk -l


Disk /dev/nvme0n1: 476.94 GiB, 512110190592 bytes, 1000215216 sectors
Disk model: KXG6AZNV512G TOSHIBA                    
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: gpt
Disk identifier: 1142DC35-FEE5-477D-A2E2-A752EBD2B7EE

Device             Start        End   Sectors   Size Type
/dev/nvme0n1p1      2048    1230847   1228800   600M EFI System
/dev/nvme0n1p2   1230848    3327999   2097152     1G Linux filesystem
/dev/nvme0n1p3   3328000  500117503 496789504 236.9G Linux LVM
/dev/nvme0n1p4 500117504 1000214527 500097024 238.5G Linux filesystem


Disk /dev/mapper/fedora_localhost--live-root: 75 GiB, 80530636800 bytes, 157286400 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/fedora_localhost--live-swap: 7.89 GiB, 8468299776 bytes, 16539648 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/zram0: 4 GiB, 4294967296 bytes, 1048576 sectors
Units: sectors of 1 * 4096 = 4096 bytes
Sector size (logical/physical): 4096 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes


Disk /dev/mapper/fedora_localhost--live-home: 164 GiB, 176093659136 bytes, 343932928 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

The thing that’s confusing me is

└─nvme0n1p4                     259:4    0 238.5G  0 part 
  ├─fedora_localhost--live-root 253:0    0    75G  0 lvm  /
  └─fedora_localhost--live-home 253:2    0   164G  0 lvm  /home

didlvresize -L +5G --resizefs /dev/mapper/fedora_localhost--live-home
create another home directory?

1 Like

If you are in doubt, blivet-gui can give you a topology of your current partitions. So you can have a better visual representation or gparted if you like…

1 Like

run

lvs

will likely only see one LV for home

and you have the initial df -h output…

/dev/mapper/fedora_localhost–live-home 156G 49G 99G 34% /home

but wheres the df -h output after the lvresize cmd you ran?

idk the diff b/t lvresize and lvextend… but i have always used lvextend to grow a LV

the output of

└─fedora_localhost–live-home 253:2 0 164G 0 lvm /home

makes me think it resized the LV like you wanted.

===

also…

did you get the free space added to partiion 3 like you wanted?
Im assuming so since your VG says theres 2 PVs in it.
im guessing you created another PV out of partition 4 and grew the VG with it…right

3 Likes

No, lsblk is just using partitions as the highest level of organisation rather than the LVs. The major:minor numbers of the LVs (device-mapper devices) on /dev/nvme0n1p4 are the same as those on /dev/nvme0n1p3 - same device and filesystem.

I think it’s lvextend

2 Likes

I hope you have a backup, because you might break your system. But it should be fine.

What you would normally do

You create a new partition using that space. I see that you already did /dev/nvme0n1p4, but it’s formatted as a Linux FS (probably ext4).

fdisk /dev/nvme0n1
t
## change type of a partition ##
4
## select partition 4 ##
30
## 30 is usually Linux LVM, make sure that is correct by pressing L before this ##
w
## write changed ##
q
## quit fdisk ##


vgextend fedora_localhost /dev/nvme0p1n4
## extending the volume group of which your root, swap and home logical volumes and partitions are part of ##
lvextend -L +60G /dev/mapper/fedora_localhost--live-root
## expanding your root logical volume with 60GB
lvextend -l +100%FREE /dev/mapper/fedora_localhost--live-home
## expand your home logical volume with the rest of the available free space on the volume group named fedora_localhost ##

resize2fs /dev/mapper/fedora_localhost--live-root
## actual resize of the root partition, in case you added 60 GB ##
## NOTE: resize2fs ONLY WORKS WITH EXT4 ##
resize2fs /dev/mapper/fedora_localhost--live-home
## actual resize of the home partition ##

In your situation I have no idea what commands you have ran. Normally you would have to run vgextend on your volume group, using the nvme partition 4 as your new space to allocate. Ok, let me explain.

So, normally a disk would have a bare partition on it, like say formatting /dev/sda1 as ext4 or as ntfs. What LVM does is what its name implies: Logical Volumes. What are logical volumes? Well, in short, it allows you to have a whole file system reside on multiple physical disks, or in this case, multiple partitions, kinda like RAID0 (but not really). Well, LVM does more (like snapshots) but I won’t get into what it does.

LVM works this way: you have Physical Volumes (pv). a PV is a physical partition on a drive. Then, LVM has something called Volume Groups (vg). VGs can hold inside them multiple PVs, either multiple partitions from a single drive, or partitions from multiple drives, or a single partition, or any combination you want. Volume Groups define a “total amount of space” available. After that, you get into Logical Volumes (lv). Those are basically “partitions” on volume groups. I mean, partition, as in partitioning a volume into multiple smaller parts. You can have a single big LV spanning the entirety of a VG, or as is in your case, multiple LVs on a VG. Then, on top of the LV, you add a file system. That is, you format a specific LV with a certain FS, in this case it’s most likely ext4.

So, now that you hopefully understand how LVM works, let’s continue.

It is weird that you see nvme0n1p4 inside the LVM group in lsblk. I believe you already ran vgextend. I can see in your vgs output that you have 2 PVs, which can only be physical NVME partitions 3 and 4. So, from there, you should be able to just run

lvextend -l +100%FREE /dev/mapper/fedora_localhost--live-home
resize2fs /dev/mapper/fedora_localhost--live-home

And be good to go. Unless you want to add some storage to root or swap too, which I show how in the above.

The reason why you are seeing home and root on 2 partitions is because the LV reside on 2 partitions. It’s not that it has created a new home and root folders, it’s that your /home and / folders (actually the entire /home and / ext4 partitions) reside on 2 physical disk partitions (nvme0n1p3 and nvme0n1p4). If you add another disk, format it as LVM and expand the same volume group, you will see that now root, home and swap reside on 3 partitions.

Note that in your lsblk output, swap still resides only on partition 3. I guess you have expanded your root and home partitions on the new partition.

Also worth explaining is that LVM is not exactly RAID0, i.e. it doesn’t balance data between 2 disks and you don’t need the same size disks (or partitions) to run LVM. But just like RAID0, if you lose a partition or disk that is part of a volume group, you lose the whole data on the volume group. You may be able to recover some portions of the data that still remained on the disks that still work, but it will be a royal PITA to get even that back.

If you didn’t have LVM and just had plain ext4 on your / and /home, you would have been able to use gparted (that you show in a screenshot) to expand the partitions directly (if they were unmounted, or if you were on a live USB environment). But LVM allows you to expand both your root and whatever other partition on-the-fly, avoiding down-time. But it’s also nifty if you want to have a single volume spanning on multiple disks without using RAID (due to same size requirement of RAID).

1 Like

Got it working! Using this

I reverted to a backup from my laptop using clonezilla

pre change outputs

image

df -h

 df -h                                                                                                                                                                                            (base) 
Filesystem                               Size  Used Avail Use% Mounted on
devtmpfs                                 7.8G     0  7.8G   0% /dev
tmpfs                                    7.8G     0  7.8G   0% /dev/shm
tmpfs                                    3.2G   11M  3.2G   1% /run
tmpfs                                    4.0M     0  4.0M   0% /sys/fs/cgroup
/dev/mapper/fedora_localhost--live-root   69G   61G  4.6G  93% /
tmpfs                                    7.8G   52K  7.8G   1% /tmp
/dev/nvme0n1p2                           976M  357M  552M  40% /boot
/dev/nvme0n1p1                           599M   21M  579M   4% /boot/efi
/dev/mapper/fedora_localhost--live-home  156G   48G  100G  33% /home
/dev/sda1                                932G  898G   34G  97% /mnt/sda1
tmpfs                                    1.6G  164K  1.6G   1% /run/user/1000

vgsrun with sudo

  VG                    #PV #LV #SN Attr   VSize    VFree
  fedora_localhost-live   1   3   0 wz--n- <236.89g    0 

fdisk -l

Disk /dev/nvme0n1: 476.94 GiB, 512110190592 bytes, 1000215216 sectors
Disk model: KXG6AZNV512G TOSHIBA                    
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: gpt
Disk identifier: 1142DC35-FEE5-477D-A2E2-A752EBD2B7EE

Device             Start        End   Sectors   Size Type
/dev/nvme0n1p1      2048    1230847   1228800   600M EFI System
/dev/nvme0n1p2   1230848    3327999   2097152     1G Linux filesystem
/dev/nvme0n1p3   3328000  500117503 496789504 236.9G Linux LVM
/dev/nvme0n1p4 500117504 1000214527 500097024 238.5G Linux filesystem

lsblk

lsblk                                                                                                                                                                                            (base) 
NAME                            MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda                               8:0    0 931.5G  0 disk 
└─sda1                            8:1    0 931.5G  0 part /mnt/sda1
sdb                               8:16   0 223.6G  0 disk 
├─sdb1                            8:17   0 223.1G  0 part 
└─sdb2                            8:18   0   467M  0 part 
sdc                               8:32   0 447.1G  0 disk 
└─sdc1                            8:33   0 447.1G  0 part 
sr0                              11:0    1  1024M  0 rom  
zram0                           252:0    0     4G  0 disk [SWAP]
nvme0n1                         259:0    0 476.9G  0 disk 
├─nvme0n1p1                     259:1    0   600M  0 part /boot/efi
├─nvme0n1p2                     259:2    0     1G  0 part /boot
├─nvme0n1p3                     259:3    0 236.9G  0 part 
│ ├─fedora_localhost--live-root 253:0    0    70G  0 lvm  /
│ ├─fedora_localhost--live-swap 253:1    0   7.9G  0 lvm  [SWAP]
│ └─fedora_localhost--live-home 253:2    0   159G  0 lvm  /home
└─nvme0n1p4                     259:4    0 238.5G  0 part 

had to change it to
vgextend fedora_localhost-live /dev/nvme0n1p4

before running that would lead to a device not found

vgextend fedora_localhost /dev/nvme0p1n4                                                                                                                                                    
  Device /dev/nvme0p1n4 not found.

post change outputs

image

df -h

Filesystem                               Size  Used Avail Use% Mounted on
devtmpfs                                 7.8G     0  7.8G   0% /dev
tmpfs                                    7.8G     0  7.8G   0% /dev/shm
tmpfs                                    3.2G   11M  3.2G   1% /run
tmpfs                                    4.0M     0  4.0M   0% /sys/fs/cgroup
/dev/mapper/fedora_localhost--live-root  128G   61G   62G  50% /
tmpfs                                    7.8G  3.6M  7.8G   1% /tmp
/dev/nvme0n1p2                           976M  357M  552M  40% /boot
/dev/nvme0n1p1                           599M   21M  579M   4% /boot/efi
/dev/mapper/fedora_localhost--live-home  332G   48G  269G  16% /home
/dev/sda1                                932G  898G   34G  97% /mnt/sda1
tmpfs                                    1.6G  168K  1.6G   1% /run/user/1000

vgsrun with sudo

  VG                    #PV #LV #SN Attr   VSize    VFree
  fedora_localhost-live   2   3   0 wz--n- <475.35g    0 

fdisk -l run with sudo

Disk /dev/nvme0n1: 476.94 GiB, 512110190592 bytes, 1000215216 sectors
Disk model: KXG6AZNV512G TOSHIBA                    
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: gpt


Device             Start        End   Sectors   Size Type
/dev/nvme0n1p1      2048    1230847   1228800   600M EFI System
/dev/nvme0n1p2   1230848    3327999   2097152     1G Linux filesystem
/dev/nvme0n1p3   3328000  500117503 496789504 236.9G Linux LVM
/dev/nvme0n1p4 500117504 1000214527 500097024 238.5G Linux LVM


Disk /dev/mapper/fedora_localhost--live-root: 130 GiB, 139586437120 bytes, 272629760 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/fedora_localhost--live-swap: 7.89 GiB, 8468299776 bytes, 16539648 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/zram0: 4 GiB, 4294967296 bytes, 1048576 sectors
Units: sectors of 1 * 4096 = 4096 bytes
Sector size (logical/physical): 4096 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes


Disk /dev/mapper/fedora_localhost--live-home: 337.46 GiB, 362345922560 bytes, 707706880 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

lsblk

lsblk                                                                                                                                                                                            (base) 
NAME                            MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda                               8:0    0 931.5G  0 disk 
└─sda1                            8:1    0 931.5G  0 part /mnt/sda1
sdb                               8:16   0 223.6G  0 disk 
├─sdb1                            8:17   0 223.1G  0 part 
└─sdb2                            8:18   0   467M  0 part 
sdc                               8:32   0 447.1G  0 disk 
└─sdc1                            8:33   0 447.1G  0 part 
sr0                              11:0    1  1024M  0 rom  
zram0                           252:0    0     4G  0 disk [SWAP]
nvme0n1                         259:0    0 476.9G  0 disk 
├─nvme0n1p1                     259:1    0   600M  0 part /boot/efi
├─nvme0n1p2                     259:2    0     1G  0 part /boot
├─nvme0n1p3                     259:3    0 236.9G  0 part 
│ ├─fedora_localhost--live-root 253:0    0   130G  0 lvm  /
│ ├─fedora_localhost--live-swap 253:1    0   7.9G  0 lvm  [SWAP]
│ └─fedora_localhost--live-home 253:2    0 337.5G  0 lvm  /home
└─nvme0n1p4                     259:4    0 238.5G  0 part 
  ├─fedora_localhost--live-root 253:0    0   130G  0 lvm  /
  └─fedora_localhost--live-home 253:2    0 337.5G  0 lvm  /home

1 Like