
Ubuntu low-memory install for VMs - porker
http://erratasec.blogspot.co.uk/2013/03/ubuntu-low-mem-install-for-vms.html
======
Wilya
If you allocate more memory, programs will use it. Web browsers are notorious
for abusing this, but it applies in lots of other places, including system
cache.

In other words: if you allocate 1GB of RAM to a system and 256MB to another,
the first will appear to use more RAM. You're reducing memory usage and
performance at the same time. Whether you want that or not depends on what you
want to run.

------
StavrosK
It sounds like most people here don't know about Ubuntu Mini:

<https://help.ubuntu.com/community/Installation/MinimalCD>

It's a 28 Megabyte .iso, installing it gives you a server with around 20-30 MB
of RAM usage. I use it for everything, and then install vim and htop and I'm
good to go. I haven't noticed anything missing, so it's definitely my go-to
install for low-RAM servers or VMs.

~~~
limeblack
Correct me if I am wrong, but isn't that slightly mis-representative? 28 MB is
just the CD size the total size is likely much larger because it downloads
much of the distribution from the servers.

~~~
mydoghasworms
According to the page, it downloads packages during installation, so yes,you
will probably end up with a big installation once you have everything you
want, but at least you don't have to download a big ISO containing software
you don't need.

------
drasch
Memory analysis isn't right on this. real difference is:

561M - 487M(cached) - 23M(buffers) = 51M

vs.

50M - 21M(cached) - 6M(buffers) = 23M

2x difference (4M of which is vmtoolsd)

~~~
FooBarWidget
Yes, this is how you're supposed to read memory usage in 'top' and 'free'. One
must substract caches and buffers from the 'free memory' value. A lot of
people read the values wrong and think that they're running out of memory.

~~~
redblacktree
Obviously there is the man page, but could you explain that a little more
fully? (or link to something that does)

I think I may have been misreading the numbers, but I don't quite follow your
recommended approach.

~~~
heiska
<http://www.linuxatemyram.com> explains it.

~~~
redblacktree
Thanks! Exactly what I needed and entertaining too!

------
trotsky
He made the two vms with different amounts of ram: the small one has 256M and
the big one has 1G.

That's what the OS is supposed to do, fille a large portion of the unused and
available memory with disk cache.

My ubuntu install uses almost 8 gigs in cache, what a pig!

BTW - if he installed open-vm-tools with the balloon driver it would recover
all that disk cache ram as soon as the hypervisor was under any amount of
memory pressure.

~~~
gillianseed
Agreed, keeping programs (once they've been exited) and data in cache is a
good thing as it means that you don't have to read them from disk again in
subsequent runs/accesses.

And given that a cache is a mirror of existing data (as opposed to buffers
which are temporary storage space), the cache can be instantly flushed by the
system if you need that ram for anything else.

This means that it's good if the memory resources the operating system needs
to function are low, since it then has more memory for caching.

This flies in the face of the often heard comment -'it doesn't matter if
operating system X is a ram hog, I want my memory to be used'.

I also want my memory to be used, but by the applications I run, not the base
operating system. If the operating system is lean, the more memory is
available to the applications you launch, aswell as the system being able to
keep as much data as possible cached to prevent slow disk reads.

------
lucb1e
Okay, so what's the downside? Half the disk usage and 10x less memory,
something is left out. What is?

Very good tip though, I always overlooked the F4 modes and never knew there
was a minimal mode.

~~~
ams6110
The downside is that nothing is installed by default. You have basically the
bare minimum to boot and run.

Need Apache? you will need to install it. Need to send email? You will need to
set that up. Need python? Ditto. And hope you like working at the command line
because you have no X. Etc.

It's a nice way to get a system that does just what you need it to do and
nothing more, but "minimal" installs are rarely useful all by themselves; they
are a starting point.

~~~
drdaeman
IIRC, Ubuntu _Server_ does not install X11 and it does not install Apache
(unless you chose "Web Server" role or tick "Apache" checkbox in "Custom" role
at install time) or any MTA or MDA.

~~~
porker
That's correct

------
wereHamster
A debootstrap'ped ubuntu quantal is just 260M. That's much less than the 680M
that are used by the minimal installation.

~~~
trapezor
The cloud images are like 200mb, too: <http://cloud-
images.ubuntu.com/quantal/current/>

~~~
wereHamster
Is there any documentation available how these images were built?

------
hosay123
As others have mentioned a debootstrapped install can be much thinner, but
even debootstrap will pull in some needless stuff. For example /usr/share/doc,
or support for every internationalization even though your server app always
runs (or should always run?) with C locale – there's 100mb right there.

~~~
denysonique
Gentoo Linux to the rescue.

~~~
IgorPartola
Except with Gentoo, you have to install all the header files for every library
you use, which easily outweighs any benefit you get from not having to install
certain locales, etc. When I saw that my 2GB install of Gentoo was equivalent
to a 500MB install of Ubuntu I abandoned it.

Also, if you are a developer, do you really want to be a one man/woman IT show
just to get your laptop up and running? Gentoo is a great learning distro that
is slightly more abstracted away than Linux From Scratch, but that's where its
usefulness ends. Doing a proper "compile newer version of GCC, then recompile
GCC with it, then recompile GCC again" voodoo is just tiresome after the first
time. Yes you may lose some performance, but chances are your time is worth
way more than what the setup takes.

~~~
markokocic
> Doing a proper "compile newer version of GCC, then recompile GCC with it,
> then recompile GCC again" voodoo is just tiresome after the first time. Yes
> you may lose some performance, but chances are your time is worth way more
> than what the setup takes.

I agree the recompiles take time, but it's not like you are going to sit in
front of the computer and stare at the console output window while emerge is
running.

~~~
IgorPartola
Compare a multi-hour bootstrapping process of Gentoo with the under 10 minute
installation of Ubuntu. When you are trying to quickly bring up a new server
(especially as the old one is failing), this counts.

Also from my years of using Gentoo, you had to babysit a large portion of the
initial installation.

~~~
misnome
Along with having to spend a load of time re-reading the documents because you
aren't installing your system on a weekly basis.

------
epo
A front page story on "Hacker News" recommends installing minimal versions of
Linux to cut down on VM resource usage, and gets votes. What next? Get
computers to behave exactly as you want them to by configuring them according
to your needs?

~~~
marshray
It's a system admin tip that's valuable in proportion to the number of Ubuntu
VM images you have running. For some folks here, that's quite a few.

Note that in Erratasec's case, they need to have a diversity of VMs for real
hacking. Go check out the the Ubertooth One mentioned in the article, it's
badass.

In my case, I was just going to be installing one in the next few days and was
looking for ways to reduce drive space used on my SSD.

------
peterwwillis
This may have much more to do with the install _process_ than how much memory
an _installed_ system needs. For example, old RHEL install images required at
least 512MB or more to install, because it would uncompress a gigantic
bootstrap/initrd into memory instead of running cloop'd or off the disk.

An installed system only needs enough memory for the kernel and whatever apps
you need to run. Install it with a lot of memory, then reduce the memory
footprint to fit your application.

------
hazov
I think you need to test the netinst Debian image, the iso is only 180 mb,
there's even a biz card version which is 50 mb, I generally use this for
testing.

------
taylorlapeyre
Does anybody have a vagrant box with this setup?

~~~
carrja99
I usually just modify the ram arguments for the actual machine.

vb.customize [ 'modifyvm', :id, '--name', node[:hostname], '--memory',
node[:ram].to_s ] We use this to perform cluster testing locally with 4 to 6
128mb nodes. :)

------
mrinterweb
This article makes me believe the author does not understand how memory
allocation on Linux works. It should not be a mystery that a VM with 4x memory
utilizes more available memory.

------
Lycanthrope
There is also Ubuntu Core [0] (my install uses 140MB on disk, 25MB RAM). It
has no installer, so you have to do everything yourself — from partitioning to
boot loader installation.

[0] <https://wiki.ubuntu.com/Core>

------
avenger123
Since we are on the subject. How much memory for a VM would be optimal for a
git server running on 12.04? This would just be for personal use. Can it get
by with 256 MB allocated?

I know there is a lot of "it depends" on this.

~~~
benjarrell
The OS installer will need more, but that should fine.

------
redtuesday
Why not just use the Server version?

~~~
henrikgs
Judging by the pictures (well the text also) he is using the server version

~~~
redtuesday
Ah, thanks, totaly overlooked that. :)

------
amitgupta151
This sounds really great!

------
ParadisoShlee
when it comes to slim bloatfree distros, Id rather just install archlinux.
because there isn't a smaller footprint than core.

