OpenVZ Forum


Home » Mailing lists » Users » fake swap != 0 in VE?
Re: fake swap != 0 in VE? (solved) [message #27264 is a reply to message #27232] Wed, 13 February 2008 09:50 Go to previous messageGo to previous message
Thomas Sattler is currently offline  Thomas Sattler
Messages: 9
Registered: November 2007
Junior Member
> Why not
> mount --bind fakememinfo /proc/meminfo
> inside the VE? Would be easiest, but the
> contents will not match real meminfo
> because they do not get updated.

I didn't expect this to work ...
... But it does. :-)

I attached a little script to be run as root
inside a VE to fake swap. 512MB are default,
you can change it on the commandline:

Output is, in the example above, cut at "free"
to prevent linewrap:

# free -m
              total       used       free
Mem:          4096        104       3991
-/+ buffers/cache:        104       3991
Swap:            0          0          0

# openvz_fake_swap
              total       used       free
Mem:          4096        104       3991
-/+ buffers/cache:        104       3991
Swap:          512          0        512

# openvz_fake_swap 4096
              total       used       free
Mem:          4096        104       3991
-/+ buffers/cache:        104       3991
Swap:         4096          0       4096

Thanks a lot!
Thomas


#!/bin/bash

SWAP="${1:-512}"

NEW="$[SWAP*1024]"; TEMP="${NEW//?/ }"; OLD="${TEMP:1}0"

umount /proc/meminfo 2> /dev/null
sed "/^Swap\(Total\|Free\):/s,$OLD,$NEW," /proc/meminfo > /etc/fake_meminfo
mount --bind /etc/fake_meminfo /proc/meminfo

free -m
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: openvz in domu (xen)
Next Topic: Network configuration
Goto Forum:
  


Current Time: Thu Apr 18 13:24:13 GMT 2024

Total time taken to generate the page: 0.01587 seconds