Sunday, November 30, 2014

Bootstrapping LXCs behind an APT proxy

Had some fun getting lxc-create to do its stuff this morning, the /etc/default/lxc config file has half a hint but not a whole one:

# MIRROR to be used by ubuntu template at container creation:
# Leaving it undefined is fine
#MIRROR="http://archive.ubuntu.com/ubuntu"
# or 
#MIRROR="http://<host-ip-addr>:3142/archive.ubuntu.com/ubuntu"

# LXC_AUTO - whether or not to start containers symlinked under
# /etc/lxc/auto
LXC_AUTO="true"

# Leave USE_LXC_BRIDGE as "true" if you want to use lxcbr0 for your
# containers.  Set to "false" if you'll use virbr0 or another existing
# bridge, or mavlan to your host's NIC.
USE_LXC_BRIDGE="true"

# If you change the LXC_BRIDGE to something other than lxcbr0, then
# you will also need to update your /etc/lxc/lxc.conf as well as the
# configuration (/var/lib/lxc/<container>/config) for any containers
# already created using the default config to reflect the new bridge
# name.
# If you have the dnsmasq daemon installed, you'll also have to update
# /etc/dnsmasq.d/lxc and restart the system wide dnsmasq daemon.
LXC_BRIDGE="lxcbr0"
LXC_ADDR="10.0.3.1"
LXC_NETMASK="255.255.255.0"
LXC_NETWORK="10.0.3.0/24"
LXC_DHCP_RANGE="10.0.3.2,10.0.3.254"
LXC_DHCP_MAX="253"

LXC_SHUTDOWN_TIMEOUT=120

The line that it's missing is "you'll also need to set the SECURITY_MIRROR field or else it dies halfway" - so add the following to your /etc/default/lxc and you're good to go:

MIRROR="http://IP-OF-PROXY:3142/archive.ubuntu.com/ubuntu"
SECURITY_MIRROR="http://IP-OF-PROXY:3142/security.ubuntu.com/ubuntu"


Tuesday, November 25, 2014

How to install Ubuntu Server 14.04 on a Mac

We have an old Mac tower in the office that I've been using as a headless server, and last time around I couldn't even get 12.04 server to install - I needed to install 12.04 desktop.

This time around, the Ubuntu server 14.04 install works fine... except it hangs at boot

Looking at the output, it has an issue with plymouth-upstart-bridge, then tries to mount swap, and then it does nothing...

I came across this post that had the answer - booting will work if you boot in recovery mode (grub -> advanced options -> ubuntu recovery) and then resume the boot. The permanent fix is to add "nomodeset" to grub.

Instructions from the beginning


  1. Copy ubuntu 14.04 amd64 server iso onto a USB drive (sudo dd if=ubuntu-14.04-server-amd64.iso of=/dev/sdX bs=1M) (*don't blame me* if you accidentally override your main harddrive)
  2. Plug usb key into server, boot up (if it doesn't boot off USB you may need to hold down ALT to get the magic screen and then choose EFI USB boot)
  3. Run install like you normally would
  4. Find that it hangs on boot
  5. Boot again but in recovery mode (at GRUB choose "advanced options" and boot into recovery mode)
  6. Log in
  7. sudo vim /etc/default/grub
  8. Edit the line GRUB_CMDLINE_LINUX_DEFAULT="" to say GRUB_CMDLINE_LINUX_DEFAULT="nomodeset"
  9. Save file
  10. sudo update-grub
  11. Reboot
  12. *magic it works yay*