Linux – memory and where is it

To find out what memory you have onboard and also where it is, here is a neat command

lshw -class memory

Here is my output

       description: BIOS
       vendor: Acer
       physical id: 0
       version: V2.04 (01/15/07)
       size: 103KiB
       capabilities: isa pci pcmcia pnp apm upgrade shadowing escd cdboot acpi usb agp biosbootspecification
       description: L1 cache
       physical id: 5
       slot: L1 Cache
       size: 16KiB
       capacity: 16KiB
       capabilities: asynchronous internal write-back
       description: L2 cache
       physical id: 6
       slot: L2 Cache
       size: 4MiB
       capabilities: burst external write-back
       description: System Memory
       physical id: 12
       slot: System board or motherboard
       size: 2GiB
          description: SODIMM Synchronous
          physical id: 0
          slot: M1
          size: 1GiB
          width: 32 bits
          description: SODIMM Synchronous
          physical id: 1
          slot: M2
          size: 1GiB
          width: 32 bits

I basically have 2GiB of memory and also L1 cache (on die cache on the cpu) of 16KiB and 4MiB L2 Cache.

Here is a wiki page that details what L1 and L2 cache are CPU cache, basically L1 means on CPU die, and L2 means slightly further away from the L1 cache. If there is a memory call L1 is the first hit, then L2 and then the memory and then swap space (harddrive), the lower down the line means slower result time.

Virtual Box

After looking over the virtualization with different setups, KVM and VirtualBox I decided to use the virtualbox method because it just appeared to be nicer and with a nice GUI per machine just felt nice.

With the additions of the Guest Additions to allow for sharing of folders from the host machine to the virtual one and also the mouse was no longer taken within the virtual machine, I just liked it and to setup a bridge for the virtual machine to use for the networking I created a small script that does the job of deleting the KVM inserting modules into K/Ubuntu.

Here it is

# to remove any kernel modules for kvm and then bring up the bridge for eth0
TMP=`lsmod | grep kvm`
RESULT=`echo $TMP | cut -d \  -f 1,4`
if [ -n "$RESULT" ]; then
        for i in 1 2
                rmmod `echo $RESULT | cut -d \  -f $i`
        echo "No kernel modules"
# setup the eth0 for working with the bridge
ifconfig eth0
#ifconfig br0 down
#setup the bridge and bring it up
brctl addbr br0
brctl addif br0 eth0
ifconfig br0 up