Monday, March 25, 2013

Ubuntu low-mem install for VMs

For those of you who play with virtual-machines like VMware, the Ubuntu server .iso contains an option for dramatically reducing the amount of memory needed. Using this option reduces the default installation's memory usage down to 66-megabytes. This is probably basic information for most of you, but I didn't know it, so I'm writing it up here.

Using VMware Workstation, the first trick is to avoid the automatic install. This is a great user-friendly feature that bypasses a bunch of normal configuration steps, but sadly, bypasses the point where you want to select the low-memory option. Thus, you need to skip specifying the .iso file when you create the VM.

After creating the VM, now go back and edit the CD-ROM settings to point the .iso and power on. You'll get the following standard splash screen for Ubuntu installs:

This just selects your language. Hit return to go to the main menu. Notice the "F4 Modes" down at the bottom of the screen. Type the F4 key, and it'll pop up a little textbox allowing you to select which kind of install you want:

Instead of "Normal" select "Install a minimal virtual machine". As far as I can tell, this has little to do with being a virtual machine. Instead, what this option means is "use the least RAM possible", as well as " reduce disk usage".


Below are two screenshots contrasting between "mini" and "full" installation. The mini installation uses 680-megabytes of drive space, whereas the full installation uses 1.1-gigabytes of drive space. In other words, the minimal installation uses roughly half the disk space. I've made them real small to avoid wasting space, so click on them if you want to actually look at them.





The changes in memory usage are more dramatic. Again, I'm including two pictures contrasting the minimal installation and the full installation. The mini installation takes 51-megabytes. The full installation takes 561-megabytes. This is a 10:1 difference! That means you can fit 10 virtual machines on a system like ESXi with the same amount of RAM as it one full machine.



The advantage of this is that you no longer need to put all your eggs into one basket. A common task for cybersec folks is too install lots of crazy software onto a single machine. This quickly breaks down as different software requires different libraries. I just messed up my BackTrack 5 VM because to install the Ubertooth One (bluetooth tool and 2.4-GHz spectrium analyzer), I had to uninstall the default python software and install a different version of python.

With smaller virtual machines, no longer have to worry. I can install a new virtual machine for every task. I can clone a base VM and install Ubertooth One on it and not have to worry that I'm screwing up some other software package.

I'm sure this is old news to a lot of you, but since I spend most my time coding rather than sysadmining, these  basic sort of things are new to me.



10 comments:

George said...

Great post. There was a time with Windows Server 2003 where I could allocate 64MB of RAM to a VM with 96 MB being comfortable. Then Windows Server 2008 jacked up the minimal RAM requirement to 256 with 512 being comfortable. It really makes virtualization difficult when the VMs take so much RAM.

Anonymous said...

Using the normal vSphere client, you can look at each VM "Resource Allocation" and see how much Guest memory is in "Active" use. If you happened to use vCenter (extra cost), you can also see how much memory is Shared between VMs and other information. It turns out that ESX is fairly smart and can re-use the same page multiple times for similar VMs.

Anonymous said...

The memory analysis needs a closer look. Real memory footprint of the larger install is:

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

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

so it's actually a 2x difference.

Ibrahim said...

This makes complete sense. It is hard to run a vm with 512M when the OS is eating up 256.

Thank you for your post

Stan said...

I started a project called SkinnyBox. My goal is to minimize the disk footprint of Ubuntu VMs by sharing the common set of files between them. I am taking a unique approach to thin privisioning that should have more write longevity then the traditional LVM based snapshots. This post about also minimizing the memory footprint has got me very excited. Are you aware of a way to apply this configuration to an already running system?

Anonymous said...

You missed the getty terminals :)

Anonymous said...

You missed the getty terminals :)

pac said...

"As far as I can tell, 'Install a minimal virtual machine' has little to do with being a virtual machine."

It does : along with everything that you noted, this option prevents installation of tons of drivers to support varying types of hardware, as that would be useless on the standardized vm architecture.
(this also means it probably won't work as a physical install.)

martin said...

Thanks for this post! That's quite a nifty feature. I would be interested to know what components you selected on the last page of the install (options being "Basic Ubuntu Server", "SSH server", etc.)

Anonymous said...

@pac does this mean it would just install drivers specific to the hardware detected? I'm not familiar with all VM architecture but don't some systems allow the user to choose the hardware to be emulated? If it was just VM specific drivers, what VM architecture would it be based on?