You are not logged in.

#1 2021-04-04 06:34:02

caray
Member
Registered: 2021-04-04
Posts: 25

resize swap partition?

i need help to do this, my swap partition is only 1G and i need it to be 6G. When I installed arch linux i followed a tutorial and i believe i used gdisk to create the partitions if that's relevant. I tried GParted but it wouldnt let me resize it.

Offline

#2 2021-04-04 06:47:15

GaKu999
Member
From: US/Eastern
Registered: 2020-06-21
Posts: 696

Re: resize swap partition?

For resizing swap you’ll need to make unpartitioned space for it to grow, it can get quite complex depending on your partitioning.

Post output of:

# fdisk -l

My reposSome snippets

Heisenberg might have been here.

Offline

#3 2021-04-04 07:00:11

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,545

Re: resize swap partition?

You can also use a swap file, https://wiki.archlinux.org/index.php/Swap (and yes, it's also gonna work for hibernation)

Offline

#4 2021-04-04 13:29:25

ian.soarch.blvd.00
Member
Registered: 2020-03-29
Posts: 10

Re: resize swap partition?

Agree with seth.

I use swap as a file. I can change its size whenever I want.
If you encrypt your root partition, then you don't even have to take care of your swap about it.

Offline

#5 2021-04-04 16:17:27

caray
Member
Registered: 2021-04-04
Posts: 25

Re: resize swap partition?

output from fdisk -l:

Disk /dev/nvme0n1: 119.24 GiB, 128035676160 bytes, 250069680 sectors
Disk model: WDC PC SN520 SDAPNUW-128G-1014         
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: gpt
Disk identifier: 3A2A3117-05F5-4E3F-91D5-C2AC7E34E43A

Device           Start       End   Sectors   Size Type
/dev/nvme0n1p1    2048    616447    614400   300M EFI System
/dev/nvme0n1p2  616448   2713599   2097152     1G Linux swap
/dev/nvme0n1p3 2713600 250069646 247356047 117.9G Linux filesystem


yeah this is for hibernation, last night my crontab failed to hibernate due to not enough swap space, so my options seem to be, a complicated resizing or just deleting the swap partition altogether and using a swap file. my only goal here is to get hibernation working, but i fear messing up my system, im not so great at partitioning stuff. so any further help would be much appreciated, thank you.

Offline

#6 2021-04-04 17:33:59

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,545

Re: resize swap partition?

Please wrap shell IO and file contents in code tags, https://bbs.archlinux.org/help.php#bbcode

For swap file hibernation, see the link I previously posted about swap, there's a section on how to create a swap file.
For hibernating there see https://wiki.archlinux.org/index.php/Po … _swap_file

Resizing the existing swap is a bad idea because you'd have to shrink your root partition rightwards (move its beginning, not its end) what is not trivial.

Offline

#7 2021-04-04 17:57:45

caray
Member
Registered: 2021-04-04
Posts: 25

Re: resize swap partition?

ok cool thanks so just to confirm what i should do:
1) delete the swap partition
2) create a swap file

question: will it matter that the swap was partition 2, and i'll still have a 1 and 3 partition but no 2?

Offline

#8 2021-04-04 18:09:16

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,545

Re: resize swap partition?

You can keep the swap partition and use it in addition (but NOT for hibernation, that has to be a consecutive space)
Since you're going to refer the swap device (root partition) by its UUID, the gap doesn't matter.
It should™ also remain stable even if you wedge multiple partitions in there.

Offline

#9 2021-04-09 16:06:38

Evanston
Member
Registered: 2021-03-31
Posts: 13

Re: resize swap partition?

Resizing the swap file will take some effort you have to resize the main partition somehow in a different environment then expand the swap to fit in the space.

Offline

#10 2021-04-09 17:11:15

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,545

Re: resize swap partition?

I think you're conflating files and partitions there… and the hazzle about resizing the root partition isn't the need to do it offline, but that the swap partition is left of it.

Offline

Board footer

Powered by FluxBB