

Memory efficient Ubuntu VMs - attilagyorffy
https://coderwall.com/p/a56j3w

======
txutxu
How much ram do you win, blacklisting those modules ?

All the kernel modules of my desktop sum a few KB. Only in 1 system I see
"nvidia" is a big module, but it doesn't use to be loaded in virtual machines.

About the blacklisting method... I use to never touch the distribution files
inside /etc/modprobe.d (to ease upgrades, differences across hosts, etc).

I think it could be better to use something like /etc/modprobe.d/local.conf or
hostname.conf

And note, that the "blacklist" directive, by side effects, may avoid module
autoloading at boot time, but the real way to disable a module (forever) is to
use this instead of "blacklist":

    
    
        install modname /bin/true
    

For more information, see blacklist in: man 5 modprobe.d

I did expect to see more tips about "userspace" configurations, where it's
more easy to win MB instead of KB.

At kernel level... after change the kernel for one more light, and tune which
modules are loaded... if we go for details... still you could see which params
are available for loaded modules (some params may affect ram usage) and which
sysctl values we can tune in the kernel (buffers, limits, etc) to affect ram
usage.

------
marios
Modules are loaded as they are needed. I think it's cleaner to configure your
VM to _not_ have a sound card, rather than blacklisting all those snd*
modules.

------
Daviey
It would be really good to see a comparison between this, and re-using the
Ubuntu Cloud images, which also provide easier initialization.

[http://ubuntu-smoser.blogspot.co.uk/2013/02/using-ubuntu-
clo...](http://ubuntu-smoser.blogspot.co.uk/2013/02/using-ubuntu-cloud-images-
without-cloud.html)

~~~
attilagyorffy
Great idea! I personally haven't had any experience with the cloud images so
far but now that I looked at them I really like your idea. +1

------
zerop
Wouldnt removing modules affect performance because some modules might be
loaded for performance or memory purposes. Can there be adverse effects as
well of doing this. If lightweight is only need, why not use the lightweight
distributions like Tinycore linux.

~~~
attilagyorffy
I personally haven't had significant performance regressions. I tend to
disable only the modules that I am sure are not going to be necessary.

Also, Tinycore linux might be great but I would like to use Ubuntu for
convenience and keep my existing additional scripts and provisioning profiles
compatible.

I'll have a look at Tinycore Linux though, thanks for mentioning.

------
harrytuttle
I tend to use base debian for VMs. It's much smaller than base Ubuntu from
both a kernel and userspace perspective.

~~~
attilagyorffy
I use Ubuntu for convenience and because that's the distro that I am the most
familiar with. I know that Ubuntu is a Debian derivative but I tend to use
Ubuntu because of the wide range of community resources.

------
_sabe_
Great tips! Thanks! :)

