SWAP FILE ERROR ON SOLARIS " may contain holes - can't swap on it"

hi, i just tried to create a swap file on a storage volume because i don't have enough space on my server. but i get error
"/swap_folder/swapfile" may contain holes - can't swap on it

the os is solaris. I took the procedure on the oracle website.

# mkdir /swap_folder

create swap file 
# mkfile -nv 100m /swap_folder/swapfile    (100 megabyte swap file)

activate swap:
# swap -a /swap_edw/swapfile

edit vfstab:
# vi /etc/vfstab

Open in new window

Williams225System AdministatorAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

achellstromConnect With a Mentor Commented:
The error cismoney is reporting relates to the fact that the kernel has determined that the number of blocks being reported is less than the file system has when it looks at actual blocks and indirect blocks. When it looks at the indirect blocks on the system it is finding that they don’t match what the inode is reporting. This means the file system thinks it is one size, but when it looks at its map to make sure it is really that size it is failing.  This is the ‘hole’.  Swap cannot have these holes because the kernel is relying on the swap file to quickly move pages back and forth without allocating a particular sector for the file.  The hole shows as having no sectors have been allocated for that location of the swapfile, so it’s disadvantageous for the kernel to attempt to use them. A hole can occur for many reasons. Perhaps the permissions are wrong on the attached storage, maybe the storage device crashed and the file system needs to have fsck run on it.  Some storage devices are more prone to this behavior like flash drives, nfs mounted drives, etc.  SCSI, Fiber, and direct attached are better locations for swapfiles if you have space available. It doesn’t sound like that is the case for cismoney.  I would check permissions on the file system and/or run fsck on the file system.
Williams225System AdministatorAuthor Commented:
the file system type is ufs
Williams225System AdministatorAuthor Commented:
i also tried

mkfile -nv 100m /swap_folder/swapfile    (100 megabyte swap file)


mkfile 100m /swap_folder/swapfile    (100 megabyte swap file)
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

What version of Solaris are you running? The -n option was supported on SunOS 4, but on SunOS 5 (Solaris 2) -n works only when the file is to be used by NFS. Local swap files cannot be created with the -n option.

Williams225System AdministatorAuthor Commented:
i use solaris 10. i also tried without the -n option , i had the same problem
This is pointing to a problem with the underlying file system.  Can you copy the exact input and what is being outputed, so I can see exactly what you are seeing?  What is the output of df -h
Try running fsck on the filesystem you are attempting to build the extra swap on.
Williams225System AdministatorAuthor Commented:
the partition where i am trying to create the swap is a partition on a storage
what type of stoarage a thumb drive, disk drive, fiber attached san storage, sas drive, ssd drive, sata, other?
swapfile has to be contiguous.  In this case, the underlying filesystem does not have 100MB of contiguous free space.  
Try creating a swap file on another filesystem with more free space.
That is a good point what size is the underlying file system. Although 100MB is not very large.  If the inode information is incorrect it would likely cause this problem.
Brian UtterbackConnect With a Mentor Principle Software EngineerCommented:
The storage for a swapfile on Solaris does not have to be contiguous. What made you think that? It is better if it is, but it doesn't have to be. What it has to be is allocated. If the command says that it might have holes, it is saying that the size of the file in pages does not match the actual pages allocated for the file.  

Whether or not the -n parameter works has nothing to do with NFS. But that is irrelevant, because the -n parameter is exactly what you don't want to
use.  It creates the file and allocates no pages at all.

You should follow the procedure given in the original question, but do not use any flags on the mkfile command, just the size and file name. After that is
done, run this command:

ls -ls /swap_edw/swapfile

You want the size in bytes reported by this command to be pretty close to 512 times the size in blocks reported in the first column.

Of course, before you run the mkfile command be sure that the filesystem has enough free space. And do not use /tmp or any other swapfs type file system.
Please check to make sure that it is not on a ZFS filesystem.

or try without -nv options
mkfile 100m /swap_folder/swapfile    
i think you enter the wrong path in the sawp -a command as you create new file "/swap_folder/swapfile" and you pass a file "/swap_edw/swapfile" to swap -a command, plz check again and feedback me.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.