Welcome! Log In Create A New Profile


Howto: Boot your GoFlex/Dockstar rootfs into QEMU (sort of)

Posted by Vlad 
Howto: Boot your GoFlex/Dockstar rootfs into QEMU (sort of)
October 02, 2011 03:44PM
Sometimes, it might be useful to be able to boot you GoFlex/Dockstar rootfs in a virtual machine.
Unfortunately, as of now qemu doesn't support emulating Marvell Kirkwood CPU's. Nevertheless you can
still boot your rootfs in a virtual environment, using a versatile arm kernel. The emulated hardware will, however, be different. Also, there's no uboot emulation.

I'm assuming that you're using a Ubuntu system, but probably every Debian based distro should be fine.
Connect your flash drive containing the rootfs to your Ubuntu box and mount it under /media/rootfs.

Open a terminal and run

sudo -s
wget http://people.debian.org/~aurel32/qemu/armel/initrd.img-2.6.32-5-versatile
wget http://people.debian.org/~aurel32/qemu/armel/vmlinuz-2.6.32-5-versatile
wget http://security.debian.org/debian-security/pool/updates/main/l/linux-2.6/linux-image-2.6.32-5-versatile_2.6.32-35squeeze2_armel.deb
apt-get install qemu-system libcap2-bin bridge-utils
setcap cap_net_admin=ei /usr/bin/qemu
nano /etc/network/interfaces
add this to the end of the file
auto eth0
iface eth0 inet dhcp

auto br0
iface br0 inet dhcp
        bridge_ports eth0
        bridge_stp off
        bridge_fd 0
        bridge_maxwait 0
now run
ifdown eth0
ifup br0
modprobe tun
nano /etc/qemu-ifup
replace the content of the file with this
echo "Executing /etc/qemu-ifup"
echo "Bringing up $1 for bridged mode..."
/sbin/ifconfig $1 promisc up
echo "Adding $1 to br0..."
/usr/sbin/brctl addif br0 $1
sleep 2
now run
dd if=/dev/zero of=kirkwood_rootfs.img bs=1MB count=2000
mkfs.ext3 -F kirkwood_rootfs.img
mount -o loop kirkwood_rootfs.img /mnt
cp -a /media/rootfs/* /mnt
nano /mnt/sbin/autologin.sh
paste this
exec /bin/login -f root
now run
chmod +x /mnt/sbin/autologin.sh
echo 'c1:2345:respawn:/sbin/agetty -l /sbin/autologin.sh -n 38400 tty1 linux' >> /mnt/etc/inittab
cp linux-image-2.6.32-5-versatile_2.6.32-35squeeze2_armel.deb /mnt/root
rm /mnt/etc/udev/rules.d/70-persistent-net.rules
umount /mnt
Finally, start QEMU
qemu-system-arm -M versatilepb -m 128M -kernel vmlinuz-2.6.32-5-versatile -initrd initrd.img-2.6.32-5-versatile -hda kirkwood_rootfs.img -append "root=/dev/sda" -net nic,macaddr=00:16:3e:00:00:01 -net tap
You will be automatically logged in as root, but network will not work. In QEMU do this
dpkg -i linux-image-2.6.32-5-versatile_2.6.32-35squeeze2_armel.deb
After the reboot your virtual machine should also have internet access.



Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.