Hacker News new | past | comments | ask | show | jobs | submit login
Ubuntu low-memory install for VMs (erratasec.blogspot.co.uk)
139 points by porker on April 9, 2013 | hide | past | favorite | 59 comments



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.


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.


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.


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.


No, you're right, the actual installation is a few hundred megabytes, if I remember correctly. I did say that 28 MB is the size of the iso, though.


I use this as a starting point for every laptop/desktop I've used in the past few years. Instant boot, no mystery services, yet access to the same great Ubuntu repos.


interesting - can one create an iso from this with only my packages? I want to use it to install across an entire office.


Have you looked at Suse Studio? http://susestudio.com/ Frankly, as an Ubuntu/Debian-derivative user, I'm a bit jealous. I wish there were something like this based on Debian (or Ubuntu for that matter). You can tailor a system to your needs and then download or share your custom ISO.


Why not just use Arch?


I am in the same situation as parent so I'll give you my reasons for not using Arch:

- Tried arch for some weeks, I liked it but had to reinstall twice after some pacman -Sy managed to break something and I couldnt't upgrade/install anything anymore ;

- I love the nice ubuntu fonts and aliasing/hinting ;

- I installed it again in the beginning of this year (netinstall) and although I was installing from the web I had no connection (not even eternet) upon rebooting even though I followed the wiki step-by-step (I tried it twice as well).

I wish there was some arch version that would have a debian like cycle release.

(I also dabbled with parabolla)


I've never had a problem with pacman breaking things on install/updated except for when I attempt to use unstable repositories.

You can get the exact same font aliasing/hinting, you just need to change the hinting settings (if you're using gnome, install gnome-tweak-tool, if you're using xfce it's in the font settings menu, I don't know about other DEs).

Arch wouldn't really be arch if it had a release cycle. Part of the simplicity of it is that it's a rolling release.


> I've never had a problem with pacman breaking things on install/updated except for when I attempt to use unstable repositories.

I wasn't using any unstable or experimental repo., only the standard basic one. I read on HN some weeks ago that there had been problems last year and there were related to some changes in the system and that that year wasn't a good one to get started with arch but I didn't follow on that.

> You can get the exact same font aliasing/hinting, you just need to change the hinting settings (if you're using gnome, install gnome-tweak-tool, if you're using xfce it's in the font settings menu, I don't know about other DEs).

https://wiki.archlinux.org/index.php/Font_Configuration I have my doubts I just need to change the hinting :] Ubuntu's defaults are really good (for me).

I am using awesome. I don't see the point of using gnome or kde with a distro that has simplicity in mind (but that's my take on it).


I'm really curious about Arch. What gap in the market does it fill? What advantages does it have over Debian or Ubuntu? It's certainly mentioned a lot on HN...


Arch's philosophy: https://wiki.archlinux.org/index.php/The_Arch_Way

I guess the most notable difference between Arch and Unbuntu is Arch's quest for simplicity as a system, where Ubuntu tries to be simple for the "common man" by abstracting implementation details, adding to overall complexity of the system.


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)


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.


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.



Thanks! Exactly what I needed and entertaining too!


I'm wondering how a blog labeling itself "Advanced persistent cybersecurity" does not know this.


Because, as the OP says, he spends more time programming than doing SysOps.


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.


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.


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.


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.


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.


That's correct


That's what package managers are for. 'sudo apt-get ...'. Done.


Then what does it take 600MB for? That's as big as WinXP with a full GUI and all MS' bloatware.


A minimal install is going to require you to install dozens of related packages just to accomplish simple tasks. It's basically a blank slate, with nothing you might want aside from the OS and terminal.

It's a great starting place if you know exactly what you want to do with that VM and how to configure it; it's kind of a pain if you're using it as a general purpose server.


It's easy to make the argument that you shouldn't have anything installed on a server that you don't specifically need - each additional service/program is just another attack vector.


All my infrastructure build materials are run against a VM built from Debian netinst. The benefit of this is that I won't be dependent upon some happy default in the Debian full install that may disappear or change at a later date. The dependency stack is fully exposed all the way down to the bare OS.

If that sounds like more work, that's because it is, but the next time something breaks, it's more immediately obvious that a an underlying package has changed.


You get a very clean starting point, allowing you to note the exact software a server is dependant on. It's more secure to only have the bare minimum software installed.


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


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


Is there any documentation available how these images were built?


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.



Gentoo Linux to the rescue.


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.


> 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.


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.


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


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?


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.


to quote reddit: "because I haven't seen it before"


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.


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.


Does anybody have a vagrant box with this setup?


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. :)


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.


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


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.


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


Why not just use the Server version?


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


Ah, thanks, totaly overlooked that. :)


This sounds really great!


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




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: