Score:0

Resize partition adjacent to two partitions

tr flag

PFA the current partitions on my disk. The second partition (selected one) is the swap partition (8gb), but recently I upgraded ram and want to make swap 16gb.

I get this message when using systemctl hibernate:

 Failed to hibernate system via logind: Not enough swap space for hibernation

Originally I wanted to shrink nvme0n1p3 and shift it towards right end and then expand the 2nd partition. However life isn't so easy and Gparted doesn't allow those kind of operations (at least I wasn't able to figure that out).

Another idea I have is to delete the swap partition, and expand the nvme0n1p3 partition to left, and the shrink it from right to make space for swap. However I am not sure whether that will work or is that the best way to go around it. Also if I do this, are there any chances that GRUB would somehow manage to not boot into my OS. I have only one OS, no dual boot.

Can someone pls guide me.

enter image description here

ChanganAuto avatar
us flag
A better idea is leave the swap alone. Just because you have more RAM now, unless you intend to use hibernation, then you're expected to need even less swap, not more. And to answer your "Gparted doesn't allow" you need to understand the partitions are mounted. Any operation must be done from a live session, as always.
oldfred avatar
cn flag
Why hibernate? With a NVMe drive you can probably boot faster than recovery from hibernation.
PonJar avatar
in flag
If you change to a swap file you can make use of unused space in the third partition. However whichever way you go you need a live session to tidy up. That can be achieved by booting the Ubuntu installation media and choosing “Try Ubuntu”. Then you use GParted from there.
Abhay Patil avatar
tr flag
@ChanganAuto yeah right I need to use a live boot. Totally slipped out of my mind.
Abhay Patil avatar
tr flag
@oldfred always booting is always faster than unhibernation (even if not nvme), but I also need to resume my work from where it was last left.
Abhay Patil avatar
tr flag
@PonJar U have heard hibernation with swapfile is prone to errors. Not sure though. Do you have any prior experience. Yeah I need a live boot.
HomerSimpson avatar
sa flag
Your 'another idea' will fail as you cannot extend a partition to the left. You have to move the entire partition you want to extend to the left, then you can extend the partition to the right. Or just move it to the left. Then shrink it by 8GB and make your 16 GB Swap-partittion in the empty space that was left there. Why did you make your swap-partition at the beginning of the disk? They should be at the end of the disk, so problems like this won't occur. All this should be done, as mentioned, from Usb-stick (Live environment), as the partition you want to resize/move cannot be mounted.
Abhay Patil avatar
tr flag
@HomerSimpson Yeah I understand I shouldn't have made swap at the beginning, but no point crying over spilt milk. Thanks for the suggestion.
heynnema avatar
ru flag
@AbhayPatil Please see my answer. If it's helpful, please remember to accept it by clicking on the checkmark icon that appears just to the left of my answer. Thanks!
heynnema avatar
ru flag
Status please...
heynnema avatar
ru flag
Status please...
Abhay Patil avatar
tr flag
@heynnema I am currently on vacation, will update in a few days.
Score:0
ru flag

Make sure that you have a good backup of your important Ubuntu files, as this procedure can corrupt or lose data.

Keep these things in mind:

  • always start the entire procedure with issuing a swapoff on any mounted swap partitions, and end the entire procedure with issuing a swapon on that same swap partition

  • a move is done by pointing the mouse pointer at the center of a partition and dragging it left/right with the hand cursor

  • a resize is done by dragging the left/right side of a partition to the left/right with the directional arrow cursor

  • if any partition can't be moved/resized graphically, you may have to manually enter the specific required numeric data (don't do this unless I instruct you to)

  • you begin any move/resize by right-clicking on the partition in the lower pane of the main window, and selecting the desired action from the popup menu, then finishing that action in the new move/resize window

Do the following...

Note: if the procedure doesn't work exactly as I outline, STOP immediately and DO NOT continue.

  • boot to a Ubuntu Live DVD/USB, in “Try Ubuntu” mode
  • start gparted
  • resize the right side of the p3 partition down by 10-15G
  • move the p3 partition all the way to the right
  • swapoff on the p2 partition
  • resize the right side of the p2 partition all the way to the right
  • click the Apply icon
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.