Skip to content

Instantly share code, notes, and snippets.

@albertohm
Last active December 17, 2015 05:59
Show Gist options
  • Save albertohm/5561913 to your computer and use it in GitHub Desktop.
Save albertohm/5561913 to your computer and use it in GitHub Desktop.

Create the container using LVM

You can use lxc-create to create and initialize a new lvm partition

lxc-create -n <name> -t ubuntu -B lvm --lvname <name> --vgname <vgname> --fssize 5GB

Mount the container

Create a directory mkdir /media/volumes/<name> and edit the /etc/fstab by adding:

/dev/vg0/<name> /media/volumes/<name> ext4 defaults 0 1

And run mount -a to mount the container.

Configure the container to mount your code partition

Create the directory inside the container

mkdir -p /media/volumes/<name>/mnt/code

Edit the /var/lib/lxc/<name>/configand change:

#lxc.rootfs = /dev/vg0/<name>
lxc.rootfs = /media/volumes/<name>

Then add to /var/lib/lxc/<name>/fstab the following line to automount your code partition inside the container:

/media/volumes/code /media/volumes/<name>/mnt/code none defaults,bind 0 0

Configure the container with ssh

Start the container by typing lxc-start -n <name>

Log into the container (user and pass should be ubuntu) and run a sudo ifconfig to copy your eth0 ip

Now you can logout.

Edit your /etc/hosts and add <ip> <name>. You should be able to do shh ubuntu@<name>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment