How to allocate swap space?

Hi all,

I would like to know how i can mount swap on /tmp at boot time,
I mean even before the actual script that does the mounting kicks in?
i tried this
mount -F tmpfs swap /tmp
(nothing happens it just hangs during the booting)

I also tried this
/usr/lib/fs/tmpfs/mount swap /tmp
(says mount not allowed for this FSType)

Thanks

You didn't mention which OS you are working on, but on the systems i know you cannot "mount" a swapspace at all! To "mount" means "to make part of the filesystem hierarchy" and swap space is neither part of this hierarchy nor intended to be. To mount anything there would have to be a filesystem on it but a swapspace is a raw device. There is now FS on it at all.

There is a feature in Linux where swapspace can be allocated in the filesystem by creating a "swap file" (like it is the case in Windoze systems), but this is somewhat a stretch to the concept of swap: Basically it means to first create a file to set aside space, emulate a sort-of logical volume (~= partition) on it (similar to the "drives" files in VMware) and then use this pseudo-partition as a swapspace. Still, this is EMULATION all over and doesn't change the original concept: swap space is not to be mounted.

The reason why "mount -F" will hang at boot time is simple: you force the mount so the system will not continue if the mount fails. As this mounting attempt must fail it will definitely hang.

I hope this helps.

bakunin

I am using opensolaris.
Can you help me figure it out now?
By mounting i mean..
trying to mount swap on /tmp at a earlier stage than its default script.
The whole point is that i need 2 lib files to reside in /tmp at a very early stage in the boot..
This is not happening because these files have combined size of 600mb...
This amount of ram is not allocated when the script where i want to copy 2 files to the ram is executed...

so i thought of explicitly mounting swap so that i get the whole ram at this point iteself(i'm having 2gb ram).

Can you please help!

Example:
How to Add More Swap Space without Repartitioning the Disk

To add more swap space, perform the following steps:

Become superuser.

Create a directory for the swap file, if needed-for example:

mkdir /moreswap

Create the swap file by using the mkfile command, which has the following syntax:

mkfile <number> [k|b|m] <filename>

The <number> specifies the file size in KB, bytes, or MB specified by k, b, or m. For example, to create 500MB swap space, issue the following command:

mkfile 500m /moreswap/swapFile

Activate the swap file by carrying on the same example:

# /usr/sbin/swap -a /moreswap/swapFile

You must use the absolute path name to specify the swap file. The swap file is now added, and activated. It is available until the file system is unmounted, the system is rebooted, or the swap file is removed. The swap file will be automatically activated each time the system is booted, if you perform the next step.

Add the following entry for the swap file to the /etc/vfstab file, again using the running example:

/moreswap/swapFile - - swap - no -

Issue the following command to verify that the swap file has actually been added:

/usr/sbin/swap -l