root on zfs: adjust swap space postinstallation

Hello,

I used gkontos' great zfs root how to. Unfortunatly I only typed the commands down and forgot to adjust the the size of the swap size. I only have set 4GB swap space. Is it possible to expand the swap space in use?

I think so :) So how do I do this?

Regards
 
How much RAM do you have and where is your swap?
Your question implies that your swap is not on a ZFS pool, which is good, and since primary swap is on a physical slice, you could create a secondary swap in your ZFS pool as back-up. However, 4G should be more than enough (depending on your RAM situation).
 
Hi,

I have 8GB, SWAP is on a ZFS dataset.

Code:
fallback# zfs list
NAME                        USED  AVAIL  REFER  MOUNTPOINT
zroot                      5.39G   581G   344M  /
zroot/swap                 4.13G   585G    16K  -
zroot/tmp                    36K   581G    36K  /tmp
zroot/usr                   952M   581G   270M  /usr
zroot/usr/home               61K   581G    61K  /usr/home
zroot/usr/ports             333M   581G   310M  /usr/ports
zroot/usr/ports/distfiles  23.6M   581G  23.6M  /usr/ports/distfiles
zroot/usr/ports/packages     31K   581G    31K  /usr/ports/packages
zroot/usr/src               349M   581G   349M  /usr/src
zroot/var                   572K   581G   126K  /var
zroot/var/crash            31.5K   581G  31.5K  /var/crash
zroot/var/db                198K   581G    99K  /var/db
zroot/var/db/pkg           98.5K   581G  98.5K  /var/db/pkg
zroot/var/empty              31K   581G    31K  /var/empty
zroot/var/log              50.5K   581G  50.5K  /var/log
zroot/var/mail               31K   581G    31K  /var/mail
zroot/var/run                73K   581G    73K  /var/run
zroot/var/tmp                32K   581G    32K  /var/tmp

SWAP is created with:
Code:
zfs create -V 4G zroot/swap
zfs set org.freebsd:swap=on zroot/swap
zfs set checksum=off zroot/swap

However, 4G should be more than enough (depending on your RAM situation).
I have an unused 640GB drive as zroot and I thought when only 5GB are in use for the whole system what would be wrong for more swap?
 
If your swap is a zvol, then it's trivial to make it bigger.

Disable swap:
# swapoff /dev/zvol/zroot/swap

Destroy the zvol:
# zfs destroy zroot/swap

Create a new larger zvol:
# zfs create -o org.freebsd:swap=on -o checksum=off -V 8G zroot/swap

Re-enable swap:
# swapon /dev/zvol/zroot/swap

Unless you're finding your system swapping heavily, I'd question whether you really need a larger swap. FreeBSD can't do a crashdump to ZFS-based swap, so there's no need to ensure that it's at least the same size as physical memory.
 
Hi jem,

Can I do this in active state without the danger of having a kernel panic?
 
No need to destroy the dataset.
# zfs get all zroot/swap
You should be able to see one or both of these properties:
Code:
refreservation=4G
reservation=4G
Just change it (whichever was set in above)
# zfs set refreservation=8G zroot/swap
# zfs set reservation=8G zroot/swap

There is a general consensus against ZFS based swap, the subject does depend on several things of course...
 
Hi you missed setting the volsize but thank you for easy solution.
Works now :)
Code:
# zfs get all zroot/swap
NAME        PROPERTY              VALUE                  SOURCE
zroot/swap  type                  volume                 -
zroot/swap  creation              Sat May  5 15:03 2012  -
zroot/swap  used                  4.13G                  -
zroot/swap  available             585G                   -
zroot/swap  referenced            16K                    -
zroot/swap  compressratio         1.00x                  -
zroot/swap  reservation           none                   default
zroot/swap  volsize               4G                     local
zroot/swap  volblocksize          8K                     -
zroot/swap  checksum              off                    local
zroot/swap  compression           off                    default
zroot/swap  readonly              off                    default
zroot/swap  copies                1                      default
zroot/swap  refreservation        4.13G                  local
zroot/swap  primarycache          all                    default
zroot/swap  secondarycache        all                    default
zroot/swap  usedbysnapshots       0                      -
zroot/swap  usedbydataset         16K                    -
zroot/swap  usedbychildren        0                      -
zroot/swap  usedbyrefreservation  4.13G                  -
zroot/swap  logbias               latency                default
zroot/swap  dedup                 off                    default
zroot/swap  mlslabel                                     -
zroot/swap  sync                  standard               default
zroot/swap  refcompressratio      1.00x                  -
zroot/swap  org.freebsd:swap      on                     local
# zfs set refreservation=8G zroot/swap
cannot set property for 'zroot/swap': 'refreservation' is greater than current volume size
# zfs set volsize=8G zroot/swap
# zfs set refreservation=8G zroot/swap
# zfs set reservation=8G zroot/swap
 
Back
Top