Zone Swap Space

A non-global zone inherits its swap space setting from the global zone. For example, in my global zone:

bleonard@solaris:~$ swap -sh
total: 604M allocated + 122M reserved = 724M used, 836M available

And in my local zone:

bleonard@myzone:~$ swap -sh
total: 604M allocated + 122M reserved = 724M used, 836M available 

If I need to increase swap space in a particular zone, I need to add swap to the entire system. As covered in Adjusting the Sizes of Your ZFS Swap and Dump Devices, first add another swap volume:

bleonard@solaris:~$ sudo zfs create -V 1G rpool/swap2
Password: 

Then add the new volume to the swap:

bleonard@solaris:~$ sudo swap -a /dev/zvol/dsk/rpool/swap2

bleonard@solaris:~$ swap -sh
total: 612M allocated + 133M reserved = 748M used, 1.8G available

The new swap is also immediately recognized by the zone:

bleonard@myzone:~$ swap -sh
total: 612M allocated + 133M reserved = 748M used, 1.8G available

To permanently add the swap to the system, you need to add the device to the /etc/vfstab file:

bleonard@solaris:~$ cat /etc/vfstab 
#device		device		mount		FS	fsck	mount	mount
#to mount	to fsck		point		type	pass	at boot	options
#
/devices	-		/devices	devfs	-	no	-
/proc		-		/proc		proc	-	no	-
ctfs		-		/system/contract ctfs	-	no	-
objfs		-		/system/object	objfs	-	no	-
sharefs		-		/etc/dfs/sharetab	sharefs	-	no	-
fd		-		/dev/fd		fd	-	no	-
swap		-		/tmp		tmpfs	-	yes	-

/dev/zvol/dsk/rpool/swap	-		-		swap	-	no	-
/dev/zvol/dsk/rpool/swap2	-		-		swap	-	no	-

You can also control the amount of swap space used by zones with resource caps, for example:

bleonard@solaris:~$ sudo zonecfg -z myzoney  
zonecfg:myzone> add capped-memory
zonecfg:myzone:capped-memory> set swap=1G
zonecfg:myzone:capped-memory> end
zonecfg:myzone> verify
zonecfg:myzone> exit

This change will require a zone reboot:

bleonard@solaris:~$ sudo zoneadm -z myzone reboot

After which the swap cap will be in place:

bleonard@myzone:~$ swap -sh
total: 33M allocated + 0K reserved = 33M used, 988M available


Comments:

Post a Comment:
  • HTML Syntax: NOT allowed
About

The Observatory is a blog for users of Oracle Solaris. Tune in here for tips, tricks and more as we explore the Solaris operating system from Oracle.

Connect with Oracle Solaris:


Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today