This is a complete guide to extend an existing partition of 250GB (LVM) then
resize it to 500GB. Obviously, only for Linux systems.
Procedure will detail,
the partition create, its configuration and the LVM extension.
And cover
2 exceptions too (parition larger than 2TB, and vmware 16TB+ extension).
categories:
• sysadmin
description: Linux LVM extension
This is a complete guide to extend an existing partition of 250GB (LVM) then resize it to 500GB. Obviously, only for Linux systems.
Procedure will detail, the partition create, its configuration and the LVM extension.
And cover 2 exceptions too (parition larger than 2TB, and vmware 16TB+ extension).
bash fdisk /dev/sdb n (for new) p (for primary) 1 (partition number)
Set the type
bash t (for setting a partition type) 1 (select the correct partition) L (get the list) 8e (select LVM) p (verify) w (write configuration)
Initialize the partition
pvcreate /dev/sdb1 pvdisplay => physical volume informations pvscan => scan all supported LVM block devices
Create the Volume Group
vgcreate vg_backup /dev/sdb1
Create the Logical Volume
lvcreate --name lv_backup -l 100%FREE vg_backup lvdisplay ...
Format the new partition
mkfs.ext4 /dev/vg_backup/lv_backup
Create mount point
mkdir /backup mount /dev/vg_backup/lv_backup /backup #(edit /etc/fstab configuration)
Verify
df -h /dev/sda2 début fin block 8e 821248 167772159 83475456 Linux LVMOLD
Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 499711 497664 243M 83 Linux
/dev/sda2 501758 125827071 125325314 59.8G 5 Extended
/dev/sda5 501760 125827071 125325312 59.8G 8e Linux LVM
NEW
First sector (499712-230686719, default 499712):
Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 499711 497664 243M 83 Linux
/dev/sda2 501758 125827071 125325314 59.8G 5 Extended
/dev/sda3 125827072 230686719 104859648 50G 8e Linux LVM
/dev/sda5 501760 125827071 125325312 59.8G 8e Linux LVM
Add the needed space on vSphere Client, then rescan the scsi bus
echo '1' > /sys/class/scsi_disk/0\:0\:0\:0/device/rescan
or (adapt in function of you device bus order)
echo '1' > /sys/class/scsi_disk/2\:0\:1\:0/device/rescan
Resize the partition the Physical Volume
pvresize /dev/sdb1
Physical volume "/dev/sdb1" changed
1 physical volume(s) resized / 0 physical volume(s) not resized
init 6
pvresize /dev/sdb1
partprobe -s
pvdisplay
PV Name /dev/sdb1
VG Name vg_backup
PV Size 500.00 GiB / not usable 2.00 MiB
lvextend -l +100%FREE /dev/vg_backup/lv_backup lvdisplay |grep Size LV Size 500.00 GiB
resize2fs /dev/vg_backup/lv_backup
df -h |grep mapper /dev/mapper/vg1-lv001 18G 1.8G 15G 11% / /dev/mapper/vg_backup-lv_backup 493G 70M 470G 1% /backup
(>=2TB partition) For partition larger than 2TB, we cannot use fdisk, software can't use parted instead
parted /dev/sdb mklabel gpt print free mkpart data1 ext4 17.4kb 4398GBprint free
Number Start End Size File system Name Flags
1 17.4kB 4398GB 4398GB data1
set 1 lvm on
print (or just "p")
#### Create the physical volume
```bash
pvcreate /dev/sdb1
Have done this for 4 partitions sdb sdc sdd sde (4x4To)
vgcreate vg_shares /dev/sdb1 /dev/sdc1 /dev/sdd1 /dev/sde1 lvcreate --name lv_shares -l 100%FREE vg_shares
VMware, cannot add a new disk larger than 16TB on a VM using the vSphere Client. Through ESX command-line you can get the VM id
[root@localhost:~] vim-cmd vmsvc/getallvms Vmid
...
vim-cmd vmsvc/device.diskadd 2 18000000 scsi0 2 datastore1
device.diskadd =>
2 =>
18000000 => 18TB
scsi0 => first scsi bus
2 => second position for the disk, already one in the first position
datastore1 => name of the datastore