I want to run an idea by you... I have an Ubuntu 16.04.3 with an LVM on a second drive I would like to extend. I want to complete this only using this CLI, no GUI. I have put my steps below how I complete this using gparted, if we can mimic these steps in the CLI.
I think what I am missing is honestly just whatever is the CLI equivalent to "Right-Click and extending it in gparted"
Here is a quick over of my setup view. In attempt to save some time and space I shortened some items. My steps will follow:
fdisk:
Disk /dev/sdb: 170 GiB, 182536110080 bytes, 356515840 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
Disklabel type: dos
Disk identifier: 0x7fbfd5c7
Device Boot Start End Sectors Size Id Type
/dev/sdb2 1001470 293601279 292599810 139.5G 5 Extended
/dev/sdb5 1001472 293601279 292599808 139.5G 8e Linux LVM
Disk /dev/mapper/nextcloud--vg-root: 137.5 GiB, 147660472320 bytes,
288399360 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/nextcloud--vg-swap_1: 2 GiB, 2147483648 bytes, 4194304
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
vgdisplay:
--- Volume group ---
VG Name nextcloud-vg
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 7
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 1
Act PV 1
VG Size 139.52 GiB
PE Size 4.00 MiB
Total PE 35717
Alloc PE / Size 35717 / 139.52 GiB
Free PE / Size 0 / 0
VG UUID huX2Hk-jG98-HieD-bAuV-Z0Wi-mAMi-nRGwDI
lvdisplay:
--- Logical volume ---
LV Path /dev/nextcloud-vg/root
LV Name root
VG Name nextcloud-vg
LV UUID TPebe1-nMhS-5kse-OR9G-IlGA-CBIc-QERaVE
LV Write Access read/write
LV Creation host, time nextcloud, 2016-07-27 13:27:51 -0400
LV Status available
# open 2
LV Size 137.52 GiB
Current LE 35205
Segments 2
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 252:0
--- Logical volume ---
LV Path /dev/nextcloud-vg/swap_1
LV Name swap_1
VG Name nextcloud-vg
LV UUID 90e1zB-ZuSK-2wiV-webN-55Of-fD6H-8ex5M7
LV Write Access read/write
LV Creation host, time nextcloud, 2016-07-27 13:27:52 -0400
LV Status available
# open 2
LV Size 2.00 GiB
Current LE 512
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 252:1
cat /proc/mounts | grep '^/':
/dev/mapper/nextcloud--vg-root / ext4 rw,relatime,errors=remount ro,data=ordered 0 0
/dev/sda1 /boot ext4 rw,relatime,data=ordered 0 0
pvs:
PV VG Fmt Attr PSize PFree
/dev/sdb5 nextcloud-vg lvm2 a-- 169.52g 0
All of this appears simple enough:
- Boot to an ISO
- Run gparted
- Right-click "Deactivate" /dev/sdb5 (Sometimes I have to click this 2 or 3
- times to make the key actually go away and allow changes. No errors are ever thrown) < Is this normal?
- Click "Apply"
- Right-click, resize/move and extend the partition /dev/sdb2,
- Right-click resize/move and extend the partition /dev/sdb5
- Click "Apply"
- lvextend –l +100%FREE /dev/nextcloud-vg/root
- reboot the machine
- resize2fs /dev/nextcloud-vg/root
And I'm good.
EDIT - 1/3/18
If I try and accomplish the same thing through fdisk and CLI I cannot create the logical partition from the same sector. Details below
root@nextcloud:/home/ncadmin# fdisk /dev/sdb
Command (m for help): d
Partition number (2,5, default 5): 2
Partition 2 has been deleted.
Command (m for help): n
Partition type
p primary (0 primary, 0 extended, 4 free)
e extended (container for logical partitions)
Select (default p): e
Partition number (1-4, default 1): 2
First sector (2048-367001599, default 2048): 1001470
Last sector, +sectors or +size{K,M,G,T,P} (1001470-367001599, default 367001599):
Created a new partition 2 of type 'Extended' and of size 174.5 GiB.
Command (m for help): n
Partition type
p primary (0 primary, 1 extended, 3 free)
l logical (numbered from 5)
Select (default p): l
Adding logical partition 5
First sector (1003518-367001599, default 1003520):
Last sector, +sectors or +size{K,M,G,T,P} (**1003520**-367001599, default 367001599):