This is what I've tried:
sudo zsh -c 'echo offline >/sys/devices/system/memory/memory109/state'`
and got the following error:
zsh:echo:1: write error: device or resource busy
Do I perhaps need to make sure that the memory module that I am about to take offline is empty first?
And if so, how could I do that?
I'm running an Ubuntu based distro virtualized as a guest by VMWare.
I'm hoping to reduce the memory usage of the guest system, freeing up more to be available to the host without having to restart the guest.
In case any of that may matter.
Encouraged by @Gilles' comments and link saying that in theory it should be possible, I got the idea that maybe
memory109 contained some unmovable pages. So I decided to try it on some other modules(?) too.
At first I tried a few others by hand. But since those were unsuccessful, I thought I would try all of them:
for i in /sys/devices/system/memory/memory*/state; do echo -n "Trying "$i" \t"; sudo zsh -c "echo offline > $i"; done
Caution: Be careful with the above script as it may succeed on your machine which could offline most if not all of your memory leaving your system starved and hanging.
This is what I got for most:
... Trying /sys/devices/system/memory/memory44/state zsh:echo:1: write error: device or resource busy Trying /sys/devices/system/memory/memory45/state zsh:echo:1: write error: device or resource busy Trying /sys/devices/system/memory/memory46/state zsh:echo:1: write error: device or resource busy ...
With only two exceptions:
Trying /sys/devices/system/memory/memory0/state zsh:echo:1: write error: invalid argument ... Trying /sys/devices/system/memory/memory86/state zsh:echo:1: write error: invalid argument ...
Any ideas why this may not work?