Solved

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

Posted on 2011-09-20
14
1,696 Views
Last Modified: 2013-12-28
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
Comment
Question by:cismoney
14 Comments
 

Author Comment

by:cismoney
ID: 36566211
the file system type is ufs
0
 

Author Comment

by:cismoney
ID: 36566214
i also tried

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


and

mkfile 100m /swap_folder/swapfile    (100 megabyte swap file)
0
 
LVL 2

Expert Comment

by:achellstrom
ID: 36566368
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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 

Author Comment

by:cismoney
ID: 36566388
i use solaris 10. i also tried without the -n option , i had the same problem
0
 
LVL 2

Expert Comment

by:achellstrom
ID: 36566859
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
 
LVL 2

Expert Comment

by:achellstrom
ID: 36566874
Try running fsck on the filesystem you are attempting to build the extra swap on.
0
 

Author Comment

by:cismoney
ID: 36567514
the partition where i am trying to create the swap is a partition on a storage
0
 
LVL 2

Expert Comment

by:achellstrom
ID: 36567929
what type of stoarage a thumb drive, disk drive, fiber attached san storage, sas drive, ssd drive, sata, other?
0
 
LVL 5

Expert Comment

by:balasundaram_s
ID: 36568119
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
 
LVL 2

Expert Comment

by:achellstrom
ID: 36568189
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
 
LVL 22

Assisted Solution

by:blu
blu earned 250 total points
ID: 36568974
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
 
LVL 2

Accepted Solution

by:
achellstrom earned 250 total points
ID: 36569624
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
 
LVL 38

Expert Comment

by:yuzh
ID: 36570977
Please check to make sure that it is not on a ZFS filesystem.

or try without -nv options
mkfile 100m /swap_folder/swapfile    
0
 
LVL 5

Expert Comment

by:hossamshaaban
ID: 36573045
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

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

When you do backups in the Solaris Operating System, the file system must be inactive. Otherwise, the output may be inconsistent. A file system is inactive when it's unmounted or it's write-locked by the operating system. Although the fssnap utility…
Let's say you need to move the data of a file system from one partition to another. This generally involves dismounting the file system, backing it up to tapes, and restoring it to a new partition. You may also copy the file system from one place to…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question