Raspberry Pi 2 KVM bridge networking

1. Combining tutorials in Enabling KVM virtualization for Raspberry Pi 2 and KVM on the Raspberry Pi2 enabled KVM on RPi 2.

2. sudo apt-get install bridge-utils uml-utilities

3. Using example script in Networking in QEMU

4. So the script looks like (I take no credit for this):

#!/bin/sh

# Disable the QEMU sound driver
export QEMU_AUDIO_DRV=none

# Basic system setup an ARM vexpress with 1 CPU, 256M of RAM
smp=1
cpu=host
ram=256
machine=vexpress-a15
# Where are the kernel and root images stored
dir=/home/pi/vms/linaro

bridge=br0
tap=$(sudo tunctl -u $(whoami) -b)
sudo ip link set $tap up
sleep 1s
sudo brctl addif $bridge $tap

# Source: https://snapshots.linaro.org/ubuntu/images/kvm/latest/zImage-armv7
kernel=$dir/zImage-armv7
# Source: https://snapshots.linaro.org/ubuntu/images/kvm/latest/vexpress-v2p-ca15-tc1.dtb
dtb=$dir/vexpress-v2p-ca15-tc1.dtb
# Source: http://snapshots.linaro.org/ubuntu/images/kvm-guest/36/armhf/kvm-armhf.qcow2.xz
rootfs=$dir/kvm-armhf.qcow2
# Virtual machine Linux command line
cmdline=”root=/dev/vda2 rw mem=${ram}M console=ttyAMA0 rootwait rootfstype=ext4″

sudo qemu-system-arm -enable-kvm -smp $smp -m $ram -M $machine -cpu host \
-kernel $kernel -dtb $dtb -append “$cmdline” \
-drive if=none,id=rootfs,file=$rootfs \
-device virtio-blk-device,drive=rootfs \
-net nic,vlan=0,macaddr=00:16:35:AF:94:4B \
-net tap,vlan=0,ifname=$tap,script=no,downscript=no \
-monitor null -serial stdio -nographic

sudo brctl delif $bridge $tap
sudo ip link set $tap down
sudo tunctl -d $tap

Reverse SSH Tunneling

Original technical article is here.

LJMU has very limited support for *nix machines. Only with MS’s remote terminal service you can connect to your office machine. However, if you have a remote server (I have an amazon VM running 24/7) or a home machine with public IP, you can set up a reverse SSH tunneling so that you can always SSH into your LJMU’s machine via this tunnel.

Assuming the following two machines:

A: amazon-vm-user@amazon-vm-ip
B: ljmu-user@ljmu-ip (not accessible from public network)

Continue reading

「何謂啟蒙」?

Malstill's avatarMalstil

西元1784年,康德於《柏林月刊》發表了一篇名為〈答「何謂啟蒙」?〉的文章。在這篇文章裡,他為「啟蒙」提出了一個堪稱經典、直到如今仍為人所樂於引用的定義:所謂的啟蒙,乃是「人之超脫於他自己招致的未成年狀態」,而所謂的未成年狀態,指的則是「無他人的指導即無法使用自己的知性的那種無能」。在這樣的定義之下,康德認為最重要的事便是勇於求知,有鑑於此,他用另外一句話來總結他心目中啟蒙的信念:「鼓起勇氣去使用你自己的知性吧」,康德說:「這便是啟蒙的格言」

View original post 38 more words

mysql + ubuntu + docker

Installed mysql in a docker container inside a ubuntu 12.04 LTS virtual machine and got “ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (2)”. This was due to mysql failed to start in the first place. To solve this problem, simply run “mysqld_safe” once to generate mysqld.sock.

Raspberry Pi + Docker + lighttpd

Quick notes for myself on docker + lighttpd for Raspberry Pi.

1. Install docker on Raspberry Pi: http://resin.io/blog/docker-on-raspberry-pi-in-4-simple-steps/

2. Create a raspbian image for Pi:

./mkimage-debian.sh raspbian wheezy http://archive.raspbian.org/raspbian

3. Learn to use docker:

http://coreos.com/docs/launching-containers/building/getting-started-with-docker/

4. Run a container and attach it to a tty:

sudo docker -t -i run [docker image] /bin/bash

5. Do these things:

i. Update /etc/apt/sources.list to  “deb http://mirrordirector.raspbian.org/raspbian/ wheezy main contrib non-free rpi”, default one is out-of-time

ii. apt-get update

iii. apt-get install lighttpd

6. Commit changes to create a new image:

e.g. sudo docker commit rpi/web

7. Run the web server and map it to host port:

e.g. sudo docker run -d -p 80:80 rpi/web /usr/sbin/lighttpd -f /etc/lighttpd/lighttpd.conf -D

8. All done.