Swap FS Creating and FS Tuning

On modern hardware with 32GB memory or more swap space is rarely used for its primary purpose. Bu Solaris has a very elegant idea of linking swap space and /tmp. In other words /tmp in Solaris is memory based filesystem and files in it disappear on reboot.  That means that it is important for Solaris administrators to understand the features of the Solaris swap. There are three major area of interest here:

  • Swap space requirements
  • The relationship of swap with the TMPFS file system
  • Recovery from error messages related to swap space

Solaris virtual memory is a combination of the available random access memory (RAM) and disk space. Portions of the virtual memory are reserved as swap space. Swap space can be defined as a temporary storage location that is used when system’s memory requirements exceed the size of available RAM.  The default page size for Solaris is 8K. Usual size of Solaris swap partition is the size of RAM. In can be less but some application, such as Oracle requires the size swap to be equal to the size of RAM .

But if RAM is bigger then 2GB usually it sufficient to allocate about 25-30% of physical RAM.  

Paging is the transfer of selected memory pages between RAM and the swap areas.

To display the size of a memory page in bytes. The default page size for the Solaris 10 OS is 8192 bytes

# pagesize
8192

# pagesize -a To display all supported page sizes.
8192
65536
524288
4194304
swap command provides a method of adding, deleting, and monitoring the swap areas used by the kernel.
Swap area changes made from the command line are not permanent and are lost after a reboot. To create permanent additions to the swap space, create an entry in the /etc/vfstab file. The entry in the /etc/vfstab file is added to the swap space at each reboot.

1. List a summary of the system’s virtual swap space.
# swap -s
total: 41776k bytes allocated + 5312k reserved = 47088k used, 881536k
available

2. List the details of the system’s physical swap areas.
# swap -l
swapfile dev swaplo blocks free
/dev/dsk/c0t0d0s1 136,9 16 1048304 1048304
Adding Swap Slices
To add a swap slice, complete the following steps:
1. Edit the /etc/vfstab file to add information describing the swap slice.
# vi /etc/vfstab
#device device mount FS fsck mount mount
#to mount to fsck point type pass at boot options

2. Add the following line to create the swap slice.
/dev/dsk/c1t3d0s1 – – swap – no –
3. Use the swap -a command to add additional swap area.
# swap -a /dev/dsk/c1t3d0s1
Adding Swap Files
To add a swap file, complete the following steps:
1. Identify a file system that has adequate space to create an additional swap file, preferably on another drive.
2. Make a directory to hold the swap file.
# mkdir -p /usr/local/swap
3. Create a 20-Mbyte swap file named swapfile in the
/usr/local/swap directory.
# mkfile 20m /usr/local/swap/swapfile

4. Add the swap file to the system’s swap space.
# swap -a /usr/local/swap/swapfile
5. List the details of the modified system swap space.
# swap -l
swapfile dev swaplo blocks free
/dev/dsk/c0t0d0s1 136,9 16 1048304 1048304
/usr/local/swap/swapfile – 16 40944 40944

6. List a summary of the modified system swap space.
# swap -s
total: 41672k bytes allocated + 5416k reserved = 47088k used, 901200k
available
7. To use a swap file when the system is subsequently rebooted, add an
entry for the swap file in the /etc/vfstab file.
# vi /etc/vfstab
#device device mount FS fsck mount mount
#to mount to fsck point type pass at boot options

/usr/local/swap/swapfile – – swap – no –
Removing Swap Slices
1. Delete a swap slice from the current swap configuration.
# swap -d /dev/dsk/c1t3d0s1
2. To prevent the swap slice from being configured as part of the swap configuration during a reboot or change of run level, edit the
/etc/vfstab file, and remove the swap slice entry from the file.

Removing Swap Files

1. Delete a swap file from the current swap configuration.
# swap -d /usr/local/swap/swapfile
2. Remove the file to free the disk space that it is occupying.
# rm /usr/local/swap/swapfile
3. To prevent the swap file from being configured as part of the swap configuration during a reboot or change of run level, edit the
/etc/vfstab file, and remove the swap file entry


FS Tuning

SWAPFS: A FS used by the kernel for swapping. Swap space is used as a vertual memory storage area when the system does not have enough physical memory to handle current process.

PROCFS: The process file system resides in memory. It contains a list of active processes, by process number in the /proc directory.Ps command is used to get the information of the /proc directory.

TMPFS: Temporary file system uses in local memory for file system reads/writes because it uses physical memory not in the disk. TMPFS is faster than to files in a UFS.THis is not permanent, they are deleted when the file system is unmounted or the system is shutdown or rebooted. This is the default FS type for /tmp directory in the SUNOS system software.When memory is insufficient to hold everything in the temporary file system, the TMPFS uses swap space as a temporary backing store, as long as adequate swap space is present
Subdirectory Description
/dev/fd File descriptors
/dev/md Logical volume management metadisk devices
/dev/pts Pseudo terminal devices
/dev/rdsk Raw disk devices
/dev/rmt Raw magnetic tape devices
/dev/term Serial devices

/etc/inet Configuration files for network services
/etc/nfs Configuration file for NFS server logging
/etc/security Control files for Role Based Access Control and security privileges
/etc/skel Default shell initfiles for new user accounts
/etc/svc The Service Management Facility database and log files
/etc/zones Initialization and reference files for the Solaris 10 OS Zones facility
/var/svc Service Management Facility control files and logs.

inodes contain two parts. First, inodes contain information about the file, including its owner, its permissions, and its size. Second,
inodes contain pointers to data blocks associated with the file content.

Data blocks are units of disk space that are used to store data
A symbolic link is a file that points to another file.
# ln -s file1 file2
A hard link is the association between a file name and an inode.

# ln file1 file2
A file system is a collection of files and directories that make up a structured set of information

Types of file systems:
Disk-based file systems —————-> ufs,hsfs(High Sierra file system),pcfs(PC file system),udfs(Universal Disk Format file system)
Distributed file systems —————-> NFS(network file system)
Pseudo file systems —————-> tmpfs(temporary file system),swapfs(swap file system),fdfs(file descriptor file
system),procfs(process file system),mntfs(mount file system),objfs(kernel object file system)

# fstyp -v /dev/dsk/c0t1d0s6 |head
(output omitted for brevity)
minfree 10% maxbpg 2048 optim time
# newfs -m 2 /dev/dsk/c0t1d0s6
newfs: construct a new file system /dev/rdsk/c0t1d0s6: (y/n)? y
(output omitted for brevity)
# fstyp -v /dev/dsk/c0t1d0s6 |head
(output omitted for brevity
minfree 2% maxbpg 2048 optim time
To change the minimum percentage value of free space on an existing file system, you can use the tunefs -m %free command.
The following command changes the minimum percentage of free space on the /dev/rdsk/c0t0d0s0 device to 1 percent.
# tunefs -m 1 /dev/rdsk/c0t0d0s0
minimum percentage of free space changes from 10% to 1%