Skip to content

Instantly share code, notes, and snippets.

@jdmichaud
Last active December 1, 2017 19:36
Show Gist options
  • Save jdmichaud/b9b277c75216816ea663bbee7ad04e46 to your computer and use it in GitHub Desktop.
Save jdmichaud/b9b277c75216816ea663bbee7ad04e46 to your computer and use it in GitHub Desktop.
Buildroot on qemu
curl -sOL https://buildroot.org/downloads/buildroot-2017.08.tar.gz
tar xf buildroot-2017.08.tar.gz
cd buildroot-2017.08/
make nconfig
# This is to point getty to the serial console instead of tty1
cat > /tmp/fixinittab.sh << 'EOF'
#!/bin/sh
sed -ie 's/tty1/ttyS0/g' ${TARGET_DIR}/etc/inittab
EOF
chmod +x /tmp/fixinittab.sh
# Configure your kernel to enable cgroups
make linux-nconfig
# > General Setup > Control Group Support (all sub options)
# Configure your system
make nconfig
# > Target package > System tools > docker-engine (all sub options)
# > Target package > System tools > cgroups-mount
make source
make
qemu-system-x86_64 \
-kernel output/images/bzImage \
-hda output/images/rootfs.ext2 \
-m 128 \
-boot c \
-append "console=ttyS0 root=/dev/sda rw" \
-no-reboot \
-nographic \
-net nic,model=virtio -net user \
-redir tcp:2222::22
# If you have added the dropbear package, the last statement redirect
# your host 2222 port to the guest port 22 so you can connect by:
ssh root@localhost -p 2222
# Don't forget to set a password for root using the `passwd` command or else
# the ssh server will refuse the connection by default
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment