Solved

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

Posted on 2011-09-20
14
1,662 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
 

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Skill Development 15 162
Can I delete authorized_keys in FreeBSD 1 76
what is the difference between "sudo su" and "su - root" 6 102
Unix Script: Loop over all days of a month 17 87
Using libpcap/Jpcap to capture and send packets on Solaris version (10/11) Library used: 1.      Libpcap (http://www.tcpdump.org) Version 1.2 2.      Jpcap(http://netresearch.ics.uci.edu/kfujii/Jpcap/doc/index.html) Version 0.6 Prerequisite: 1.      GCC …
Why Shell Scripting? Shell scripting is a powerful method of accessing UNIX systems and it is very flexible. Shell scripts are required when we want to execute a sequence of commands in Unix flavored operating systems. “Shell” is the command line i…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…

939 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now