1

My compiles are failing on Solaris 11.3 due to out of memory kills. The box is an UltraSPARC workstation with 600GB drives and 8 GB of RAM and a fresh OS install. It is absolutely befuddling there's not enough memory for the system and I am suffering DoS'es out of the box.

I'm trying to follow Adding Swap Space on a Solaris System to add some more space.

# Step 1 $ sudo su - ... # Step 2 # mkdir /var mkdir: Failed to make directory "/var"; File exists # mkfile 2048m /var/swap # Step 3 # ls -l /var/swap -rw------- 1 root root 2147483648 Jul 16 11:42 /var/swap # Step 4 # swap -a /var/swap "/var/swap" is not valid for swapping. It must be a block device or a regular file with the "save user text on execution" bit set. 

I have two questions. First, what is so broken at Oracle that nearly every document is wrong?

Second, how do I create the god damn swap space? How do I make the T appear in an ls listing?


Here is the doc's Step 3. Notice the addition of the T:

Verify that the file was created by typing:

ls -l /directory/swap-file-name 

The new file appears in the directory. For example:

ls -l /foo/16mswap -rw------T 1 root other 16777216 Dec 12 14:24 /foo/16mswap 
1
  • It is absolutely befuddling there's not enough memory for the system What's the initial swap configuration? Solaris doesn't lie about how much memory is available - no memory overcommit is done, so if you don't have enough swap, that's what you get. what is so broken at Oracle that nearly every document is wrong? The document you posted excerpts from is not wrong. It's an example that happens to be incomplete. The Solaris 11 swap man page even states: "Using a regular file for swap is not supported on a ZFS file system." Commented Jul 16, 2018 at 15:06

2 Answers 2

4

The page you found relates to Solaris Studio 12.3, which dates back to 2011, and a time when Solaris still used swap files. With Solaris 11.3, which uses ZFS as the root filesystem, the process is slightly different, as a real block device is required. Fortunately, ZFS makes using real block devices very easy, via ZFS Volumes.

First, check for your existing volumes:

zfs list -t volume 

You will most likely see a volume named swap @ /rpool/swap, so you'll need a different name for your new device, like swap2.

Here's what I see:

bash-[501]# zfs list -t volume NAME USED AVAIL REFER MOUNTPOINT rpool/dump 3.08G 139G 2.99G - rpool/swap 2.06G 139G 2.00G - 

Also, take a look at your existing swap devices:

bash-[502]# swap -l swapfile dev swaplo blocks free /dev/zvol/dsk/rpool/swap 275,1 8 4194296 4194296 

Next step is to create the new volume. In the next command, the -V option indicates that we are creating a raw block device, as opposed to a device with a filesystem, and the 2G is the size:

bash-[503]# zfs create -V 2G rpool/swap2 

Now you'll see your list of volumes has changed:

bash-[504]# zfs list -t volume NAME USED AVAIL REFER MOUNTPOINT rpool/dump 3.08G 137G 2.99G - rpool/swap 2.06G 137G 2.00G - rpool/swap2 2.06G 137G 2.00G - 

Then you can activate that block device as swap:

bash-[505]# swap -a /dev/zvol/dsk/rpool/swap2 

And, as always, you can see your swap devices with swap -l.

bash-[506]# swap -l swapfile dev swaplo blocks free /dev/zvol/dsk/rpool/swap 275,1 8 4194296 4194296 /dev/zvol/dsk/rpool/swap2 275,3 8 4194296 4194296 
1
  • Thanks @Tim. zfs set volsize=2G rpool/swap was sufficient to compile a program. I'm still amazed the compiler does not work out of the box and something special has to be done... Commented Jul 24, 2018 at 17:28
2

The T attribute may be set on the file using

chmod +t filename 

Note that using a swap file is not supported if the file lives on an ZFS filesystem.

You must log in to answer this question.