Skip to content

Instantly share code, notes, and snippets.

@bradfitz
Created April 18, 2018 02:31
Show Gist options
  • Save bradfitz/8d803135606c3a222fdb6d9fb666b962 to your computer and use it in GitHub Desktop.
Save bradfitz/8d803135606c3a222fdb6d9fb666b962 to your computer and use it in GitHub Desktop.
failing to enlarge a partition
Trying to enlarge a VM's LVM partition from 400GB to 800GB.
I gave it more disk from the hypervisor and had the kernel rescan the SCSI bus, which worked:
dmesg:
[3879444.655318] sd 0:0:0:0: [sda] 1677721600 512-byte logical blocks: (859 GB/800 GiB)
[3879444.655447] sda: detected capacity change from 429496729600 to 858993459200
Old values:
# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 800G 0 disk
├─sda1 8:1 0 243M 0 part /boot
├─sda2 8:2 0 1K 0 part
└─sda5 8:5 0 399.8G 0 part
└─sda5_crypt 254:0 0 399.8G 0 crypt
├─bard--vg-root 254:1 0 391.8G 0 lvm /
└─bard--vg-swap_1 254:2 0 8G 0 lvm [SWAP]
sr0 11:0 1 1024M 0 rom
I want to make the sda5* stuff twice as big.
root@bard:/home/bradfitz# fdisk /dev/sda
Welcome to fdisk (util-linux 2.29.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): p
Disk /dev/sda: 800 GiB, 858993459200 bytes, 1677721600 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: 0x817488f7
Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 499711 497664 243M 83 Linux
/dev/sda2 501758 838858751 838356994 399.8G 5 Extended
/dev/sda5 501760 838858751 838356992 399.8G 83 Linux
Command (m for help): d
Partition number (1,2,5, default 5):
Partition 5 has been deleted.
Command (m for help): d
Partition number (1,2, default 2):
Partition 2 has been deleted.
Command (m for help): p
Disk /dev/sda: 800 GiB, 858993459200 bytes, 1677721600 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: 0x817488f7
Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 499711 497664 243M 83 Linux
Command (m for help): n
Partition type
p primary (1 primary, 0 extended, 3 free)
e extended (container for logical partitions)
Select (default p): e
Partition number (2-4, default 2):
First sector (499712-1677721599, default 499712): 501758
Last sector, +sectors or +size{K,M,G,T,P} (501758-1677721599, default 1677721599):
Created a new partition 2 of type 'Extended' and of size 799.8 GiB.
Command (m for help): p
Disk /dev/sda: 800 GiB, 858993459200 bytes, 1677721600 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: 0x817488f7
Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 499711 497664 243M 83 Linux
/dev/sda2 501758 1677721599 1677219842 799.8G 5 Extended
Command (m for help): p
Disk /dev/sda: 800 GiB, 858993459200 bytes, 1677721600 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: 0x817488f7
Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 499711 497664 243M 83 Linux
Command (m for help): n
All space for primary partitions is in use.
Adding logical partition 5
First sector (503806-1677721599, default 503808): 501760
Value out of range.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment