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.

Edit 2016-09-29:

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";

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?

  • 3
    According to §6.2 “How to offline memory”, if I understand correctly, you can offline a memory block provided that it doesn't contain any unmovable memory (i.e. some kinds of kernel memory). I don't think there's a way to generically ensure that a memory zone can be offlined, but I have no experience of this. Sep 26, 2016 at 23:06

2 Answers 2


Most likely, your memory blocks cannot be offlined, because they contain unmovable pages. Check the "removable" sysfs attribute.

If you're runing a normal x86-64 system (virtualized or bare metal), it's very likely that there are no removable blocks, because all kernel allocations are unmovable. To restrict the kernel to some portion of ram, pass a "kernelcore=" parameter to it. You should see some removable memory blocks after that, and you can offline them either by writing '0' to the 'online' attribute or by writing 'offline' to the 'state' attribute.

  • Why would that be specific to x86-64?
    – Vikki
    Jan 8, 2022 at 1:32
  • It's not. It's just that I'm not entirely sure whether some minor architecture allocates a non-empty movable zone by default. Feb 17, 2022 at 17:06

I don't think it's possible by kernel's default features. Kernel only supports hot-plug, but unplug. There could be a weirdo way to do this, but technically it sounds bad... there are few problems with this at least.

  • 1
    I don't know if it's possible with the build options used by Ubuntu's default kernel, but it certainly is possible with a mainline kernel, no patches needed. It has been for about a decade. Sep 26, 2016 at 23:01
  • Yup, I know. But he is running Ubuntu. And I said default. So he need to compile kernel for himself. Sep 27, 2016 at 4:57
  • Just did this yesterday with creating config so there was this option. Anyway it is bad in my mind and without right knowledge you will cause kernel panic. Sep 27, 2016 at 5:11
  • I don't think you can cause a kernel panic this way. You could cause the system to run out of memory (having ample swap will reduce that risk) but that only triggers the OOM killer, not a kernel panic. Sep 27, 2016 at 9:22
  • 6
    I've checked, Ubuntu's default kernel configuration does include all the settings needed for memory unplugging. So it absolutely is possible using the kernel's default features on Ubuntu. There's nothing “weirdo” about this. Why do you claim that “there are few problems with this”? Why do you claim that there is a risk of kernel panic? Sep 29, 2016 at 10:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .