How to increase SWAP space/partition

Place to ask questions about partitioning, labelling, filesystems, encryption or anything else related to storage area.

How to increase SWAP space/partition

Postby alie » 17 Aug 2011, 10:28

Like the title, is there any way to increase swap partition ?

Thanks in advance
[color="DarkRed"]www.alielee.com[/color]
FreeBSD FreeBSD 9.1-PRERELEASE #0 r243320 /usr/obj/usr/src/sys/EZYCLIE amd64
User avatar
alie
Member
 
Posts: 561
Joined: 11 Dec 2008, 08:13
Location: Somewhere in the world

Postby Beastie » 17 Aug 2011, 10:39

I don't think you can resize the existing partition. At least not easily. But you may create a swap file (see section 11.14.3 Swapfiles).
May the source be with you!
Beastie
Senior Member
 
Posts: 1859
Joined: 28 Mar 2009, 11:27
Location: /dev/earth0

Postby alie » 17 Aug 2011, 10:48

How about delete the existing swap partition then resize the root to use the swap space, is it possible ?
[color="DarkRed"]www.alielee.com[/color]
FreeBSD FreeBSD 9.1-PRERELEASE #0 r243320 /usr/obj/usr/src/sys/EZYCLIE amd64
User avatar
alie
Member
 
Posts: 561
Joined: 11 Dec 2008, 08:13
Location: Somewhere in the world

Postby jem » 17 Aug 2011, 11:24

You can certainly remove your swap partition, then grow your root filesystem into the available space.

You'd use [MAN=8]bsdlabel[/MAN] to delete the [FILE]b:[/FILE] partition, then increase the size of the [FILE]a:[/FILE] partition to fill the freed space.

After that's done, you use [MAN=8]growfs[/MAN] to expand the UFS filesystem inside the [FILE]a:[/FILE] partition.
jem
Member
 
Posts: 342
Joined: 23 Oct 2009, 11:24

Postby SirDice » 17 Aug 2011, 11:24

You can add multiple swap partitions.

Code: Select all
dice@molly:~>swapinfo
Device          1K-blocks     Used    Avail Capacity
/dev/gpt/swap4    2097152   113344  1983808     5%
/dev/gpt/swap5    2097152   113824  1983328     5%
/dev/gpt/swap6    2097152   112936  1984216     5%
/dev/gpt/swap7    2097152   112660  1984492     5%
Total             8388608   452764  7935844     5%
dice@molly:~>grep swap /etc/fstab
/dev/gpt/swap4          none                    swap            sw              0       0
/dev/gpt/swap5          none                    swap            sw              0       0
/dev/gpt/swap6          none                    swap            sw              0       0
/dev/gpt/swap7          none                    swap            sw              0       0
Senior UNIX Engineer at Unix Support Nederland
Experience is something you don't get until just after you need it.
User avatar
SirDice
Old Fart
 
Posts: 16161
Joined: 17 Nov 2008, 16:50
Location: Rotterdam, Netherlands

Postby NewGuy » 21 Aug 2011, 14:06

You can install a tool like swapexd, which will grow a swap file for you on an as-needed basis. It's a tad slow, but gives you flexibility of just having the amount of swap you need.
NewGuy
Member
 
Posts: 133
Joined: 23 Nov 2009, 18:11

Postby alie » 13 Jan 2012, 09:50

Can someone help me with the commands to delete [file]/dev/ad10s1b[/file] partition and then grow [file]/dev/ad10s1a[/file] partition? I am not familiar how the partition works.

Code: Select all
[/usr/home/alie]# disklabel -e /dev/ad10s1b
# /dev/ad10s1b:
8 partitions:
#          size     offset    fstype   [fsize bsize bps/cpg]
  a: 1953521009       4096    4.2BSD        0     0     0
  b:       4096          0      swap
  c: 1953525105          0    unused        0     0     # "raw" part, don't edit


then quit with q!

Code: Select all
~
~
~
~
~
:q
partition a: partition extends past end of unit
partition c: partition extends past end of unit
disklabel: partition c doesn't cover the whole unit!
disklabel: An incorrect partition c may cause problems for standard system utilities
re-edit the label? [y]:


I didn't make any changes yet but seems there is something wrong with my partition.

Thanks
[color="DarkRed"]www.alielee.com[/color]
FreeBSD FreeBSD 9.1-PRERELEASE #0 r243320 /usr/obj/usr/src/sys/EZYCLIE amd64
User avatar
alie
Member
 
Posts: 561
Joined: 11 Dec 2008, 08:13
Location: Somewhere in the world

Postby kpa » 13 Jan 2012, 10:30

You're looking at the wrong device, [FILE]/dev/ad10s1b[/FILE] is the partition itself. You should use the slice with the bsd disklabel:

[CMD="#"]bsdlabel -e /dev/ad10s1[/CMD]

[man=8]gpart[/man] can resize partitions in a bsdlabel'ed slice as well, deleting [FILE]ad10s1b[/FILE] and then resizing [FILE]ad10s1a[/FILE]
should go like this:

[CMD="#"]gpart delete -i 2 ad10s1[/CMD]
[CMD="#"]gpart resize -i 1 -s newsize ad10s1[/CMD]

The "-i 1" option means the 1st partition inside geom [FILE]ad10s1[/FILE], [FILE]ad10s1a[/FILE]
kpa
MFC'd
 
Posts: 3392
Joined: 05 Jul 2010, 13:19
Location: People's Technocratic Republic of Finland


Return to Storage

Who is online

Users browsing this forum: No registered users and 0 guests