1825719 Members
2878 Online
109686 Solutions
New Discussion

swap info

 
SOLVED
Go to solution
marc seguin
Regular Advisor

swap info

How to get the size of swap on your system, when you are a common user ?
The 'swapinfo' command needs privileged rights !
9 REPLIES 9
Stefan Farrelly
Honored Contributor

Re: swap info


The permissions on /usr/sbin/swapinfo are 544 but I dont see any reason why you couldnt make them 555. Its a binary so its safe, and its not suid to root so no security risk there.

Otherwise you could grep swap /etc/fstab - this should list the swap lvols (as long as /etc/fstab is uptodate), and then you can lvdisplay the size of these lvols - and add in the default swap on /dev/vg00/lvol2 (not usually listed in /etc/fstab).
Im from Palmerston North, New Zealand, but somehow ended up in London...
G. Vrijhoeven
Honored Contributor
Solution

Re: swap info

Hi MS

Ok.... what you can do is :
cat /etc/fstab | grep swap
you will get your swap logical volumes and volume group returned.

Now you cat use vgdisplay -v /dev/vg?? | more
and check the sizes of you logical volumes.

hope this will help.

Gideon
Wim Rombauts
Honored Contributor

Re: swap info

Look at /var/adm/syslog/syslog.log and search for a line containing "Swap device".
Size is given in blocks on the next line.

If you have additional swap, look at /etc/fstab to see how it is configured.
Santosh Nair_1
Honored Contributor

Re: swap info

Also, if you have glance installed on your system you can find out how much swap is on the system by hitting w (not using GUI) or selecting swap space from the GUI. This will tell you how much swap space you have and how many device/filesystem swaps you have.

Some additional ranting...I don't understand why HP doesn't open up the permissions for some executables such as swapinfo and fuser, both of which can be safely run as non-root accounts. Just doesn't make sense?

-Santosh
Life is what's happening while you're busy making other plans
Sanjay_6
Honored Contributor

Re: swap info

Hi Marc,

"swapinfo" is your best bet, if you don't have glance installed on your system. If you have glance, once you run "glance" and then press "?" to bring the help menu up and you can see the different keys associated with different menus in glanceplus.

Change the permission of "swapinfo" if required.

If you don't have additional swap configured, then "lvdisplay /dev/vg00/lvol2" will show you the amount of swap on your system.

Check for any filesystem swap you might have. The entry for that would be in /etc/fstab.

Hope this helps.

thanks
marc seguin
Regular Advisor

Re: swap info

Stefan : yes, it works when modifying the execution permissions.
but I am not super-user on the system I want to check...
And I was looking for the default swap.

Thanks, Gideon. Why didn't I think about that ?

Wim : It works if you don't resize the swap. If you do, I don't know if you can trace it in the log file.

No glance for me...

marc.
Wim Rombauts
Honored Contributor

Re: swap info

Marc, to my knowledge, you can't increase primary swap without restarting the system. You surely can't decrease it.
Actual device swap can only be detected in /etc/mnttab, because /etc/fstab only contains device swap or filesystem swap that will be enabled on boot.
I don't know how you can see filesystem swap that will not be re-enabled on boot.
James R. Ferguson
Acclaimed Contributor

Re: swap info

Hi Marc:

My first choice is to side with Stefan. I don't see any harm in adding execute permission to 'swapinfo'.

Here's a quick script that reports and totals the declared device swap. Remember that it doesn't count pseudo swap (it can't). Remember too, that primary device swap isn't declared in /etc/fstab -- to do so would generate an error at boot time when it's activation is attempted twice.

Here's the script:

#!/usr/bin/sh
typeset -i SZ=0
typeset -i MB=0
DEV=`awk '$3~/swap/ {print $1}' /etc/fstab`
for LV in /dev/vg00/lvol2 $DEV
do
SZ=`/usr/sbin/lvdisplay $LV|awk '/LV Size/ {print $4}'`
let MB=$MB+$SZ
echo "$LV = $SZ"
done
echo "Total Size (MB) = $MB"
exit 0
#.end.

Output might look like:

/dev/vg00/lvol2 = 512
/dev/vg00/lvol9 = 1024
Total Size (MB) = 1536

Regards!

...JRF...
Ian Chard_1
New Member

Re: swap info

You could also do

cd /tmp
cp /usr/sbin/swapinfo .
chmod 755 swapinfo
./swapinfo

- Ian