1swap(1M) System Administration Commands swap(1M)
2
3
4
6 swap - swap administrative interface
7
9 /usr/sbin/swap -a swapname [swaplow] [swaplen]
10
11
12 /usr/sbin/swap -d swapname [swaplow]
13
14
15 /usr/sbin/swap -l [-h | -k]
16
17
18 /usr/sbin/swap -s [-h]
19
20
22 The swap utility provides a method of adding, deleting, and monitoring
23 the system swap areas used by the memory manager.
24
26 The following options are supported:
27
28 -a swapname [swaplow] [swaplen]
29
30 Add the specified swap area. This option can only be used by the
31 superuser or by one who has assumed the Primary Administrator role.
32 swapname is the name of the swap area or regular file. For example,
33 on system running a UFS root file system, specify a slice, such as
34 /dev/dsk/c0t0d0s1, or a regular file for a swap area. On a system
35 running a ZFS file system, specify a ZFS volume, such as
36 /dev/zvol/dsk/rpool/swap, for a swap area. Using a regular file for
37 swap is not supported on a ZFS file system. In addition, you cannot
38 use the same ZFS volume for both the swap area and a dump device
39 when the system is running a ZFS root file system.
40
41 swaplow is the offset in 512-byte blocks into the file where the
42 swap area should begin. swaplen is the desired length of the swap
43 area in 512-byte blocks. The value of swaplen can not be less than
44 16. For example, if n blocks are specified, then (n-1) blocks would
45 be the actual swap length. swaplen must be at least one page in
46 length. The size of a page of memory can be determined by using the
47 pagesize command. See pagesize(1). Since the first page of a swap
48 file is automatically skipped, and a swap file needs to be at least
49 one page in length, the minimum size should be a multiple of 2
50 pagesize bytes. The size of a page of memory is machine-dependent.
51
52 swaplow + swaplen must be less than or equal to the size of the
53 swap file. If swaplen is not specified, an area will be added
54 starting at swaplow and extending to the end of the designated
55 file. If neither swaplow nor swaplen are specified, the whole file
56 will be used except for the first page. Swap areas are normally
57 added automatically during system startup by the /sbin/swapadd
58 script. This script adds all swap areas which have been specified
59 in the /etc/vfstab file; for the syntax of these specifications,
60 see vfstab(4).
61
62 To use an NFS or local file system swapname, you should first cre‐
63 ate a file using mkfile(1M). A local file system swap file can now
64 be added to the running system by just running the swap -a command.
65 For NFS mounted swap files, the server needs to export the file. Do
66 this by performing the following steps:
67
68 1. Add the following line to /etc/dfs/dfstab:
69
70 share -F nfs -o \
71 rw=clientname,root=clientname path-to-swap-file
72
73
74 2. Run shareall(1M).
75
76 3. Have the client add the following line to /etc/vfstab:
77
78 server:path-to-swap-file - local-path-to-swap-file nfs \
79 --- local-path-to-swap-file -- swap ---
80
81
82 4. Have the client run mount:
83
84 # mount local-path-to-swap-file
85
86
87
88 5. The client can then run swap -a to add the swap space:
89
90 # swap -a local-path-to-swap-file
91
92
93
94
95 -d swapname
96
97 Delete the specified swap area. This option can only be used by the
98 super-user. swapname is the name of the swap file: for example,
99 /dev/dsk/c0t0d0s1 or a regular file. swaplow is the offset in
100 512-byte blocks into the swap area to be deleted. If swaplow is not
101 specified, the area will be deleted starting at the second page.
102 When the command completes, swap blocks can no longer be allocated
103 from this area and all swap blocks previously in use in this swap
104 area have been moved to other swap areas.
105
106
107 -h
108
109 All sizes are scaled to a human readable format. Scaling is done by
110 repetitively dividing by 1024.
111
112
113 -k
114
115 Write the files sizes in units of 1024 bytes.
116
117
118 -l
119
120 List the status of all the swap areas. The output has five columns:
121
122 path
123
124 The path name for the swap area.
125
126
127 dev
128
129 The major/minor device number in decimal if it is a block spe‐
130 cial device; zeroes otherwise.
131
132
133 swaplo
134
135 The swaplow value for the area in 512-byte blocks.
136
137
138 blocks
139
140 The swaplen value for the area in 512-byte blocks.
141
142
143 free
144
145 The number of 512-byte blocks in this area that are not cur‐
146 rently allocated.
147
148 The list does not include swap space in the form of physical memory
149 because this space is not associated with a particular swap area.
150
151 If swap -l is run while swapname is in the process of being deleted
152 (by swap-d), the string INDEL will appear in a sixth column of the
153 swap stats.
154
155
156 -s
157
158 Print summary information about total swap space usage and avail‐
159 ability:
160
161 allocated
162
163 The total amount of swap space in bytes currently allocated for
164 use as backing store.
165
166
167 reserved
168
169 The total amount of swap space in bytes not currently allo‐
170 cated, but claimed by memory mappings for possible future use.
171
172
173 used
174
175 The total amount of swap space in bytes that is either allo‐
176 cated or reserved.
177
178
179 available
180
181 The total swap space in bytes that is currently available for
182 future reservation and allocation.
183
184 These numbers include swap space from all configured swap areas as
185 listed by the -l option, as well swap space in the form of physical
186 memory.
187
188
190 On the 32-bit operating system, only the first 2 Gbytes -1 are used for
191 swap devices greater than or equal to 2 Gbytes in size. On the 64-bit
192 operating system, a block device larger than 2 Gbytes can be fully uti‐
193 lized for swap up to 2^63 −1 bytes.
194
196 See environ(5) for descriptions of the following environment variables
197 that affect the execution of swap: LC_CTYPE and LC_MESSAGE.
198
200 See attributes(5) for descriptions of the following attributes:
201
202
203
204
205 ┌─────────────────────────────┬─────────────────────────────┐
206 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
207 ├─────────────────────────────┼─────────────────────────────┤
208 │Availability │SUNWcsu │
209 └─────────────────────────────┴─────────────────────────────┘
210
212 pagesize(1), mkfile(1M), shareall(1M), getpagesize(3C), vfstab(4),
213 attributes(5), largefile(5)
214
216 For information about setting up a swap area with ZFS, see the ZFS
217 Administration Guide.
218
220 No check is done to determine if a swap area being added overlaps with
221 an existing file system.
222
223
224
225SunOS 5.11 11 Apr 2008 swap(1M)