Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1797
  • Last Modified:

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


0
cismoney
Asked:
cismoney
2 Solutions
 
cismoneyAuthor Commented:
the file system type is ufs
0
 
cismoneyAuthor Commented:
i also tried

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


and

mkfile 100m /swap_folder/swapfile    (100 megabyte swap file)
0
 
achellstromCommented:
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.

0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
cismoneyAuthor Commented:
i use solaris 10. i also tried without the -n option , i had the same problem
0
 
achellstromCommented:
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
0
 
achellstromCommented:
Try running fsck on the filesystem you are attempting to build the extra swap on.
0
 
cismoneyAuthor Commented:
the partition where i am trying to create the swap is a partition on a storage
0
 
achellstromCommented:
what type of stoarage a thumb drive, disk drive, fiber attached san storage, sas drive, ssd drive, sata, other?
0
 
balasundaram_sCommented:
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.
0
 
achellstromCommented:
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.
0
 
Brian UtterbackPrinciple 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.
0
 
achellstromCommented:
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.
0
 
yuzhCommented:
Please check to make sure that it is not on a ZFS filesystem.

or try without -nv options
mkfile 100m /swap_folder/swapfile    
0
 
hossamshaabanCommented:
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.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now