for debug purposes i need to extend my disk to all unallocated space, for example

my full disk size is 931.5GB and i have the following partitions

sda      8:0    0 931.5G  0 disk 
├─sda1   8:1    0   512M  0 part /boot/efi
├─sda2   8:2    0 107.5G  0 part /
└─sda3   8:3    0   3.8G  0 part [SWAP]

so my /dev/sda2 partiton is less than 931.5GB and i need to increase this partition with parted command to have more espace

unallocated space is : 819.72GB (see with gparted) parted /dev/sda resizepart 2 500GB but this command returns the following error :

 Can't have overlapping partitions

i am doing all this with a live usb in order to do not have mounted /dev/sda, the curious thing is that parted allow me to shrink the partition, i mean this

 parted /dev/sda resizepart 2 50GB

one more thing, if i can get the solution to this problem i would like to use the option -s in order to automate this process with some bash scripts

This is the output for fdisk -l command

Disk /dev/sda: 931.5 GiB, 1000204886016 bytes, 1953525168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: C680462D-DE3F-4A97-B2A2-50226E7F9668

Device         Start       End   Sectors   Size Type
/dev/sda1       2048   1050623   1048576   512M EFI System
/dev/sda2    1050624 226453503 225402880 107.5G Linux filesystem
/dev/sda3  226453504 234440703   7987200   3.8G Linux swap


  • What happens if you remove the SWAP partition temporarily. I can't tell because I can't "see with gparted" – Elder Geek Sep 15 '16 at 19:12
  • how can i do that ? – Humberto Perez Sep 15 '16 at 19:13
  • Please edit your question and include the output of sudo fdisk -l so that we can see where your partitions begin and end. – Elder Geek Sep 15 '16 at 19:15
  • done, please check the output for fdisk -l in the question – Humberto Perez Sep 15 '16 at 19:20
  • Checked and answered. – Elder Geek Sep 15 '16 at 19:32

The reason you can't grow /dev/sda2 is your swap partition at /dev/sda3 is too close to /dev/sda2 to allow for any growth. Note that your /dev/sda2 partition starts at sector 226453503 and your swap partition begins at the very next sector 226453504. So in effect you are asking to grow a partition over the following one (a very bad idea which is why it's not allowed)

In order to resolve this problem you could move the swap to the tail end of the drive (gparted comes to mind) or remove it and add it back after growing /dev/sda2 (with whatever partitioning tools you are most comfortable with). Sadly I have no suggestions for automating the process as it appears to be situationally dependent. However at least now you know the root cause of your problem.

There's a very similar issue and solution here: https://www.gnu.org/software/parted/manual/html_chapter/parted_2.html#SEC30

  • ok, i understand, i'll try this and i'll report back – Humberto Perez Sep 15 '16 at 19:37
  • 1
    that's fix mi issue, i deleted swap partition and then i can grow my partition, thanks a lot – Humberto Perez Sep 15 '16 at 20:04
  • You might need that swap partition. did you reserve space for it and put it back? – Elder Geek Sep 15 '16 at 20:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.