[SOLVED] How do I swap drive for a larger drive and expand LVM partition

Zoker

Active Member
Oct 31, 2020
36
10
28
Hi there,

Since my 500GB nvme storage was to small over time, I upgraded to a 1TB Samsung 980 drive.
I used the dd tool to make an exact copy of the drive and just replaced the old with the new drive.

Now I have the issue, that since I just copied the old drive (including partition) to the new drive, the new space is not yet used.
Currently my partitions look like this:
1670628348997.png
How can I expand the LVM partition to use the currently unlocated space?
I tried to google, but was unsure which guide is the correct one (expand LVM or just expand partition etc.).

So if someone could give me a hint, that would be amazing!

Thanks!
 
A quick google search for "lvm extend physical volume disk resize" brings up https://www.thegeekdiary.com/centos...-in-lvm-by-extending-the-disk-partition-used/
Whether this article is an exact match to your needs is unclear as there is not enough details in your post. Make sure you understand the commands you are running - heed to the warning in the article "Potential Data Loss Warning"

@rason I believe you misunderstood the poster - there is no new _additional_ disk involved.


Blockbridge : Ultra low latency all-NVME shared storage for Proxmox - https://www.blockbridge.com/proxmox
 
  • Like
Reactions: Zoker
A quick google search for "lvm extend physical volume disk resize" brings up https://www.thegeekdiary.com/centos...-in-lvm-by-extending-the-disk-partition-used/
Whether this article is an exact match to your needs is unclear as there is not enough details in your post. Make sure you understand the commands you are running - heed to the warning in the article "Potential Data Loss Warning"

@rason I believe you misunderstood the poster - there is no new _additional_ disk involved.


Blockbridge : Ultra low latency all-NVME shared storage for Proxmox - https://www.blockbridge.com/proxmox
Sorry, for that, you're right. I've deleted my post. OP should follow the tutorial you've provided
 
I hade the same problem but i found a good solution

https://www.youtube.com/watch?v=9ntPaLcf1eQ
https://i12bretro.github.io/tutorials/0644.html

Bash:
# Run the following commands in terminal
# login as root if needed (not needed for proxmox)
sudo su
# list disks and partitions
fdisk -l
# list volume groups
vgdisplay
# list logical volumes
lvdisplay
# edit partitions with fdisk, change device id as needed
fdisk /dev/sda
# print the partition table
p
# delete a partition
d
# enter the lvm partition number
3
# create a new partition
n
# enter the new partition number, same as the number deleted
3
# press enter to accept the default first sector
# press enter to accept the default last sector
# when prompted about removing the LVM signature, enter N
n
# set the partition type
t
# enter the partition number
3
# set the type to Linux LVM
30
# write the changes
w
# list disks and partitions, noting the size increase
fdisk -l
# extend the existing physical volume
pvresize /dev/sda3
# extend the pve-root logical volume to 100% available free space
lvresize -L +8GB /dev/pve/root
# extend the underlying file system
resize2fs /dev/mapper/pve-root
# list logical volumes, noting root is now 8GB larger
lvdisplay
# extend the data to 100% available free space
lvextend -l +100%FREE pve/data
# list logical volumes, noting data is now over 35GB
lvdisplay
 
I hade the same problem but i found a good solution

https://www.youtube.com/watch?v=9ntPaLcf1eQ
https://i12bretro.github.io/tutorials/0644.html

Bash:
# Run the following commands in terminal
# login as root if needed (not needed for proxmox)
sudo su
# list disks and partitions
fdisk -l
# list volume groups
vgdisplay
# list logical volumes
lvdisplay
# edit partitions with fdisk, change device id as needed
fdisk /dev/sda
# print the partition table
p
# delete a partition
d
# enter the lvm partition number
3
# create a new partition
n
# enter the new partition number, same as the number deleted
3
# press enter to accept the default first sector
# press enter to accept the default last sector
# when prompted about removing the LVM signature, enter N
n
# set the partition type
t
# enter the partition number
3
# set the type to Linux LVM
30
# write the changes
w
# list disks and partitions, noting the size increase
fdisk -l
# extend the existing physical volume
pvresize /dev/sda3
# extend the pve-root logical volume to 100% available free space
lvresize -L +8GB /dev/pve/root
# extend the underlying file system
resize2fs /dev/mapper/pve-root
# list logical volumes, noting root is now 8GB larger
lvdisplay
# extend the data to 100% available free space
lvextend -l +100%FREE pve/data
# list logical volumes, noting data is now over 35GB
lvdisplay
Hi, i am in this situation, i have cloned with dd my 500hdd into 1tb ssd and of course i have 500gb of unformatted space according to the command sfdisk --list-free /dev/sda, also parted > free shows me the exact starting and ending sector. how can i extend my local-lvm partition? This guide makes you delete and create a new one, but i have VMs in it
 
Hi MrnMrk,
this is no problem, all vm's are working.
Follow the YouTube instructions.
But keep your old 500GB HDD (this is your current backup) .
 
I hade the same problem but i found a good solution

https://www.youtube.com/watch?v=9ntPaLcf1eQ
https://i12bretro.github.io/tutorials/0644.html

Bash:
# Run the following commands in terminal
# login as root if needed (not needed for proxmox)
sudo su
# list disks and partitions
fdisk -l
# list volume groups
vgdisplay
# list logical volumes
lvdisplay
# edit partitions with fdisk, change device id as needed
fdisk /dev/sda
# print the partition table
p
# delete a partition
d
# enter the lvm partition number
3
# create a new partition
n
# enter the new partition number, same as the number deleted
3
# press enter to accept the default first sector
# press enter to accept the default last sector
# when prompted about removing the LVM signature, enter N
n
# set the partition type
t
# enter the partition number
3
# set the type to Linux LVM
30
# write the changes
w
# list disks and partitions, noting the size increase
fdisk -l
# extend the existing physical volume
pvresize /dev/sda3
# extend the pve-root logical volume to 100% available free space
lvresize -L +8GB /dev/pve/root
# extend the underlying file system
resize2fs /dev/mapper/pve-root
# list logical volumes, noting root is now 8GB larger
lvdisplay
# extend the data to 100% available free space
lvextend -l +100%FREE pve/data
# list logical volumes, noting data is now over 35GB
lvdisplay
NCom you are the real MVP. Followed your instructions exactly, only thing I had to change was the type which for me was 43 instead of 30. Worked like a charm.

Tip for others who are nervous about upgrading in place or increasing storage like this - get one of these cheap SATA drive duplicators and back up your entire OS drive before you start! I felt much more confident going in knowing I could fall back to my old drive if something went wrong.

https://www.amazon.com/dp/B0759567JT
 
  • Like
Reactions: NCom