James Barrett on 19 Mar 2008 09:16:44 -0700


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] Linux distribution for virtuous machines


On Wed, Mar 19, 2008 at 10:09:39AM -0400, Gabriel Sean Farrell wrote:
> On Tue, Mar 18, 2008 at 09:17:15PM -0400, JP Vossen wrote:
> > Have you tried doing a *minimal* Debian install?  Unlike Red Hat, Debian 
> > understand what "minimal" means.  The way I do it is when you get to the 
> > tool that selects packages (I forget which incarnation of which tool is 
> > used in the installer), just exit it.  Very little is installed, not 
> > even SSH!  From there I simply aptitude install whatever I need.  That 
> > gives you all of the stability, and l33tness of Debian, along with it's, 
> > errr, timeliness <ducks>.  IIRC a minimal Etch was < 300M.
> 
> I would also recommend this method.  After the base system is installed,
> deselect any "tasks".  Once the machine has rebooted, install further
> packages as needed.  This is the minimum amount of hassle for a minimal
> system.

The following is the procedure I used when creating my latest Etch 
virtual machine within KVM:

qemu-img create -f qcow2 debian-etch-base-4.qcow2 4G
kvm -hda ./debian-etch-base-4.qcow2 -cdrom \
    /path/to/debian-40r3-i386-netinst.iso \
    -boot d -m 256

I had to choose "expert noapic" or something similar at the live boot 
prompt.  I tried without it first and got a kernel panic before it even 
booted the installer.

One way to keep your disk images small is to neglect to create a SWAP 
partition.  This might cause some out-of-memory errors if you do 
anything substantially hefty within the VM, but it will drastically cut 
down the size of the disk image.  (I think it might be prudent to create 
a qcow2 image and integrate it as a separate disk in your VM)*

Like was previously stated, when the task selection screen pops up, make 
sure NOTHING is selected.  IIRC, it will default to select "Desktop 
System" and "Standard System", but you want to make sure that nothing is 
selected, IOW that there is not a star next to any of the items in this 
list.

After rebooting, I changed /etc/network/interfaces to something like the 
following: 
-=-=-=-=-=-=-=-=-
# loopback 
auto lo
iface lo inet loopback
# make many eth+ listings
allow-hotplug eth0
iface eth0 inet dhcp

allow-hotplug eth1
iface eth1 inet dhcp

allow-hotplug eth2
iface eth2 inet dhcp

allow-hotplug eth3
iface eth3 inet dhcp

-=-=-=-=-=-=-=-=-

and so on...  Use this disk image as a master, and copy it whenever you 
need a new VM.  It will hopefully be in the 250-300MB range.


* How to create a separate swap partition disk image:

qemu-img create -f qcow2 swap0.qcow2 256M
qemu-img create -f qcow2 swap1.qcow2 256M

(qcow2 is not entirely necessary for this)

... and integrate them into your VM like so:

kvm -hda ./debian-etch-base-4.qcow2 -hdb swap0.qcow2 \
    -boot c -m 256

Create a partition table on /dev/hdb and format it as swap, then edit 
fstab accordingly, execute "swapon -a" and youre good to go.

The "-boot c" will boot to the hda image.  Of course you don't want to 
run two VM's that both use the same swap image, that would be quite 
foolish.  That is why you have two.  

The advantage of this setup is that you have one master copy of your 
virtual machine, save disk space, and only use swap space when 
absolutely necessary.  Instead of having multiple swap partitions on 
each copy of your VM, going to waste, you only have a few which get used 
when you need them.  The multiple eth+ shananigans is just to ensure 
that networking comes up seamlessly when you start your vm's with new 
mac addresses.

And do not forget the qemu "-snapshot" command-line argument, it is 
truly a gem.

--
James Barrett

Attachment: signature.asc
Description: Digital signature

___________________________________________________________________________
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug