User:Ncopa/migrate-vserver-to-lxc: Difference between revisions

From Alpine Linux
(initial)
 
(add network config)
Line 2: Line 2:


Its fairly straightforward. Basically, the only thing that differs is:
Its fairly straightforward. Basically, the only thing that differs is:
* /etc/inittab
* {{path|/etc/inittab}}
* /etc/network/interfaces
* {{path|/etc/network/interfaces}}


On vserver the host sets up the network, on LXC the container needs to do it itself.
On vserver the host sets up the network, on LXC the container needs to do it itself.
Line 21: Line 21:
Use rsync to mirror the vserver. We do this before we shut down the vserver guest to keep downtime as low as possible. In this example we rsync from the vserver host:
Use rsync to mirror the vserver. We do this before we shut down the vserver guest to keep downtime as low as possible. In this example we rsync from the vserver host:
{{cmd|rsync --partial --delete --numeric-ids -rva /vservers/build-edge/* bld1.alpinelinux.org:/var/lib/lxc/build-ege-x86/rootfs/}}
{{cmd|rsync --partial --delete --numeric-ids -rva /vservers/build-edge/* bld1.alpinelinux.org:/var/lib/lxc/build-ege-x86/rootfs/}}
=== Configure networking ===
While data is copying we can use the time to configure the network. Edit {{path|/var/lib/lxc/build-edge-x86/config}} and set up the network devices. In this example we do:
{{cat|/var/lib/lxc/build-edge-x86/config|<nowiki>...
lxc.network.type = veth
lxc.network.link = br0
lxc.network.name = eth0
lxc.network.type = veth
lxc.network.link = lxbr0
lxc.network.name = eth1
...</nowiki>
}}
We can also create a {{path|interfaces}} file that we will copy into the container after old vserver is shutdown.
{{cat|/var/lib/lxc/build-edge-x86/interfaces|<nowiki>auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
        address 91.220.88.23
        netmask 255.255.255.128
        gateway 91.220.88.1
auto eth1
iface eth1 inet static
        address 192.168.8.4
        netmask 255.255.255.0
</nowiki>}}

Revision as of 07:18, 18 October 2013

Some notes on how to migrate an Alpine Linux vserver to an lxcontainer.

Its fairly straightforward. Basically, the only thing that differs is:

  • /etc/inittab
  • /etc/network/interfaces

On vserver the host sets up the network, on LXC the container needs to do it itself.

Migration steps

Here follows some step by step. build-edge-x86 is used as example.

Create container

Create the new container on the LXC host

lxc-create -n build-edge-x86 -t alpine -- --release edge --arch x86

Backup inittab

Make a copy of the inittab to a location outside the container rootfs.

cp /var/lib/lxc/build-edge-x86/rootfs/etc/inittab /var/lib/lxc/build-edge-x86/

Copy data

Use rsync to mirror the vserver. We do this before we shut down the vserver guest to keep downtime as low as possible. In this example we rsync from the vserver host:

rsync --partial --delete --numeric-ids -rva /vservers/build-edge/* bld1.alpinelinux.org:/var/lib/lxc/build-ege-x86/rootfs/

Configure networking

While data is copying we can use the time to configure the network. Edit /var/lib/lxc/build-edge-x86/config and set up the network devices. In this example we do:

Contents of /var/lib/lxc/build-edge-x86/config

... lxc.network.type = veth lxc.network.link = br0 lxc.network.name = eth0 lxc.network.type = veth lxc.network.link = lxbr0 lxc.network.name = eth1 ...

We can also create a interfaces file that we will copy into the container after old vserver is shutdown.

Contents of /var/lib/lxc/build-edge-x86/interfaces

auto lo iface lo inet loopback auto eth0 iface eth0 inet static address 91.220.88.23 netmask 255.255.255.128 gateway 91.220.88.1 auto eth1 iface eth1 inet static address 192.168.8.4 netmask 255.255.255.0