1

This is the disk schema I have which is coming from lsblk and lvs. What I want to do is resize sda5 which is of type Extended to the size of the block device /dev/sda which is 100GB

 NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 100G 0 disk |-sda1 8:1 0 243M 0 part /boot |-sda2 8:2 0 1K 0 part `-sda5 8:5 0 49.8G 0 part |-osiris-root 254:0 0 45.8G 0 lvm / `-osiris-swap_1 254:1 0 4G 0 lvm [SWAP] sr0 11:0 1 1024M 0 rom LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert root osiris-wi-ao---- 45.76g swap_1 osiris-wi-ao---- 4.00g 

Is there any way to do it using parted, fdisk or any other tool? Thanks in advance.

fdisk -l /dev/sda* outputs

Disk /dev/sda: 100 GiB, 107374182400 bytes, 209715200 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: 0x00082e2b Device Boot Start End Sectors Size Id Type /dev/sda1 * 2048 499711 497664 243M 83 Linux /dev/sda2 501758 104855551 104353794 49.8G 5 Extended /dev/sda5 501760 104855551 104353792 49.8G 8e Linux LVM Disk /dev/sda1: 243 MiB, 254803968 bytes, 497664 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/sda2: 1 KiB, 1024 bytes, 2 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: 0x00000000 Device Boot Start End Sectors Size Id Type /dev/sda2p1 2 104353793 104353792 49.8G 8e Linux LVM Disk /dev/sda5: 49.8 GiB, 53429141504 bytes, 104353792 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 
0

1 Answer 1

2

To extend your sda5, you need to extend its container too, sda2. Using command-line tools, the simplest way to do this is to use sfdisk:

sfdisk /dev/sda 

This will print the current partition table, which should match what you saw in fdisk:

Disk image: 100 GiB, 107374182400 bytes, 209715200 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: 0xe59ec859 Old situation: Device Boot Start End Sectors Size Id Type image1 * 2048 499711 497664 243M 83 Linux image2 501758 104855551 104353794 49.8G 5 Extended image5 501760 104855551 104353792 49.8G 83 Linux Type 'help' to get more information. 

At the >>> prompt, start re-defining all your partitions:

2048,497664,83,* 

(this is the first partition: start sector, length in sectors, type, and a * to make it bootable). sfdisk will respond with

Created a new DOS disklabel with disk identifier 0x03408377. Created a new partition 1 of type 'Linux' and of size 243 MiB. image1 : 2048 499711 (243M) Linux 

and prompts for image2 (sda2). Enter

501758,,5 

which tells sfdisk to create an extended partition starting at sector 501758 and occupying all the available space after that; sfdisk will output

Created a new partition 2 of type 'Extended' and of size 99.8 GiB. image2 : 501758 209715199 (99.8G) Extended 

For image3, enter simply

501760 

sfdisk will then output

Created a new partition 5 of type 'Linux' and of size 99.8 GiB. image5 : 501760 209715199 (99.8G) Linux 

and prompt for image6, which we don’t need, so enter

quit 

which will cause sfdisk to print the new partition table and ask if you want to write it to disk:

New situation: Device Boot Start End Sectors Size Id Type image1 * 2048 499711 497664 243M 83 Linux image2 501758 209715199 209213442 99.8G 5 Extended image5 501760 209715199 209213440 99.8G 83 Linux Do you want to write this to disk? [Y]es/[N]o: 

If you’re convinced the starting sectors all match, and sda1 is still OK, press Y to write the partition table and return to your shell.

Once that’s done, run

pvresize /dev/sda5 

to resize your LVM PV; you should then be able to use the newly-allocated disk space (in new LVs, or to extend existing LVs).

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.