bedHedd
October 23, 2023, 4:40am
659
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 …
I had to do this again recently and couldn’t remember what was the correct sequence of commands. I figured it out with chatgpt passing in the instructions from the solution
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 usual…
After testing it on my desktop I had it summarize the steps that worked.
I was thinking of replying to the old thread, but decided not to since it was 2 years old and I figured it would be better to write up a new ssd cloning guide, and will adapt these instructions for the commands below.
Inspect Current Disk Layout :
Command:
lsblk -o NAME,FSTYPE,SIZE,MOUNTPOINT,LABEL,UUID /dev/nvme0n1
Sample Output:
NAME FSTYPE SIZE MOUNTPOINT LABEL UUID
nvme0n1 476.9G
├─nvme0n1p1 vfat 600M /boot/efi 6542-F15B
├─nvme0n1p2 ext4 1G /boot 08fa06a0-672f-4231-b84e-b3ca6a832cbe
└─nvme0n1p3 LVM2_member 236.9G UwB9Uf-03PH-pbh8-q0F8-WllR-h8FN-Sh4PzL
Partition the Unallocated Space : Command:
sudo fdisk /dev/nvme0n1
Steps:
Enter n
to create a new partition
Press Enter
to accept the default partition number
Press Enter
again to accept the default first sector
Press Enter
once more to allocate the entire remaining space, or specify a specific size/end sector if desired.
Type w
to write changes and exit.
Sample output
Created a new partition 4 of type 'Linux' and of size XXX.XX GiB.
Create Physical Volume on Unallocated Space :
Command:
sudo pvcreate /dev/nvme0n1p4
Sample Output:
WARNING: ext4 signature detected on /dev/nvme0n1p4 at offset 1080. Wipe it? [y/n]: y
Wiping ext4 signature on /dev/nvme0n1p4.
Physical volume "/dev/nvme0n1p4" successfully created.
Verify Physical Volumes and Available Space :
Commands:
sudo pvs
Sample Output:
PV VG Fmt Attr PSize PFree
/dev/nvme0n1p3 fedora_localhost-live lvm2 a-- <236.89g 0
/dev/nvme0n1p4 lvm2 --- 238.46g 238.46g
sudo vgdisplay | grep "Free PE"
Free PE / Size 61046 / 238.46 GiB
@bedHedd note: if you get a empty output from vgdisplay, use
sudo vgdisplay fedora_localhost-live | grep "Free PE / Size"
Sample Output
Free PE / Size 183140 / 715.39 GiB
Extend Logical Volume (root) :
Command:
sudo lvextend -l +50%FREE /dev/mapper/fedora_localhost--live-root
Sample Output:
Size of logical volume fedora_localhost-live/root changed from 70.00 GiB (17920 extents) to 189.23 GiB (48491 extents).
@bedHedd note: repeat this step for the other partitions (for example home and swap)
Verify Changes :
Command:
lsblk -o NAME,FSTYPE,SIZE,MOUNTPOINT,LABEL,UUID /dev/nvme0n1
Sample Output:
NAME FSTYPE SIZE MOUNTPOINT LABEL UUID
nvme0n1 953.9G
├─nvme0n1p1 vfat 600M /boot/efi 6542-F15B
├─nvme0n1p2 ext4 1G /boot 08fa06a0-672f-4231-b84e-b3ca6a832cbe
├─nvme0n1p3 LVM2_member 236.9G UwB9Uf-03PH-pbh8-q0F8-WllR-h8FN-Sh4PzL
│ ├─fedora_localhost--live-root ext4 427.7G / 19ef8134-2f63-4c22-ba02-e0cf0409e853
│ ├─fedora_localhost--live-swap swap 7.9G [SWAP] f6ed0d66-b805-4eb4-86ee-9e1245539caf
│ └─fedora_localhost--live-home ext4 337.8G /home c60a9949-e17f-46a3-be7b-7c51e346113a
└─nvme0n1p4 LVM2_member 715.4G 8t13xm-NHfU-qhbS-j8NG-6ztw-wnoL-zHelot
├─fedora_localhost--live-root ext4 427.7G / 19ef8134-2f63-4c22-ba02-e0cf0409e853
└─fedora_localhost--live-home ext4 337.8G /home c60a9949-e17f-46a3-be7b-7c51e346113a
Resize the Filesystem for Root to Utilize the New Space :
Command:
sudo resize2fs /dev/mapper/fedora_localhost--live-root
Sample Output:
Resizing the filesystem on /dev/mapper/fedora_localhost--live-root to 49638400 (4k) blocks.
The filesystem on /dev/mapper/fedora_localhost--live-root is now 49638400 (4k) blocks long.
1 Like