Operating System - HP-UX
1840181 Members
2768 Online
110162 Solutions
New Discussion

Can HPUX use a file for swap space?

 
SOLVED
Go to solution

Can HPUX use a file for swap space?

In Solaris, I can create a file in a filesystem and it can be used for swap (mkfile -s 10G /dir/myswap ; swap -a /dir/myswap). Is there equivalent functionality in HP-UX 11.11?

Thank you!
9 REPLIES 9
James R. Ferguson
Acclaimed Contributor

Re: Can HPUX use a file for swap space?

Hi Karen:

Yes, you can use a filesystem for swap space. See the manpages for 'swapon(1M)':

http://docs.hp.com/en/B2355-60127/swapon.1M.html

Regards!

...JRF...
IT_2007
Honored Contributor

Re: Can HPUX use a file for swap space?

No you can't use a file as swap file system in HP-UX. You need to create logical volume and then make it as swap.

lvol2 in vg00 is primary swap by default when you install HP-UX system. If you want to create a secondary swap then create another logical volume on any other volume group (local disk preferred) other than vg00 and make it as swap.
Peter Godron
Honored Contributor

Re: Can HPUX use a file for swap space?

Karen,
I think you can only use a filesystem, not an individual file for this.
Ivan Ferreira
Honored Contributor

Re: Can HPUX use a file for swap space?

According to the man page you can:

The first two examples enable paging to the file system containing the /paging directory. The maximum number of file system blocks available to the paging system is set to 5000, the number of file system blocks reserved for file system use only is set to 10000, and the priority is set to 2. The number of file system blocks initially taken by the paging system defaults to 0 in the first example, and is set to 0 in the second example. On a file system with the default 8kB block size, these examples allocate approximately 40MB of file system paging.

/usr/sbin/swapon -l 5000 -r 10000 -p 2 /paging
/usr/sbin/swapon /paging 0 5000 10000 2
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
Ralph Grothe
Honored Contributor
Solution

Re: Can HPUX use a file for swap space?

As far as I have found out offering a swap greedy application (SAP in my case) filesystem swap can in fact be less wasteful than providing the same amount of device swap.

This is because the predominant usage of swap space is for reservation.
Since device swap is always used first (no matter what priority you assign your filesystem swap) for pageouts (and hopefully never swapouts) I think it's an acceptible compromise to split half of the swap requirement to inferior filesystem swap.

The SAP requirement was 20 GB of swap.
So I gave it 10 GB of primary device swap.
Note that (unlike with Solaris and Linux where most of the times you can reclaim unused swap by "swap -d" or "swapoff" online) under HP-UX you can never release "swapon-ed" space until you reboot!
Thus, a swap device is instantly fully unavailable for other purposes.
Whereas filesystem swap is only taken on demand.

As you can see the system has so far reserved abt. 7 GB from the filesystem swap, and may take up to 10 GB as set by the lim attribute.
Thus, as long as your system's swap requirements remain low you can still use it as ordinary filsystem space.

Afaik, you can only designate a filesystem for filesystem swap under HP-UX (hence the name, I suppose).
The swapon command automatically creates a subdir named paging in that filesystem that it fills with swap file chunks corresponding to actual swap requirements (viz. reservation).
Whereas under Linux you can assign any file chunk as swap space.

$ /usr/sbin/swapinfo -tam
Mb Mb Mb PCT START/ Mb
TYPE AVAIL USED FREE USED LIMIT RESERVE PRI NAME
dev 10240 43 10197 0% 0 - 1 /dev/vg00/lvol2
localfs 10240 0 10240 0% 10240 0 10 /var/adm/crash/paging
reserve - 17497 -17497
memory 14146 2445 11701 17%
total 34626 19985 14641 58% - 0 -

$ grep swap /etc/fstab
... /var/adm/crash swapfs pri=10,min=0,lim=1310720 0 0

$ echo $((10240*1024/8))
1310720


Note, that the swapon command had an fstab issue that was fixed with this patch (which is part of the latest GOLDBASE11i bundle

$ /usr/sbin/swlist GOLD\*|grep swapon
GOLDBASE11i.PHCO_27010 1.0 swapon(1M) patch
$ /usr/sbin/swlist -l fileset -a readme GOLDBASE11i.PHCO_27010|more




Madness, thy name is system administration
Jaime Bolanos Rojas.
Honored Contributor

Re: Can HPUX use a file for swap space?

Karen,

Agreed with everybody else, you can create a logical volume and use it as file swap, but not get a file and use it as a file system.

Regards,

Jaime.
Work hard when the need comes out.
Sp4admin
Trusted Contributor

Re: Can HPUX use a file for swap space?

Hi Karen,

By default HP will use /dev/vg00/lvol2 as primary swap logical volume. I think you can only use a locial volume to increase the size. I don't think you cam use just a file. You can create another logical volume like /dev/vg03/lvol3 if not being used.

sp,

Re: Can HPUX use a file for swap space?

Thank you for all your replies. I'm in the process of creating a new volume to use as swap.

Re: Can HPUX use a file for swap space?

Thanks!