Skip to content

Instantly share code, notes, and snippets.

@ThinGuy
Created October 16, 2018 14:58
Show Gist options
  • Save ThinGuy/54c785c82f536fb91a6f49ca2f2867ed to your computer and use it in GitHub Desktop.
Save ThinGuy/54c785c82f536fb91a6f49ca2f2867ed to your computer and use it in GitHub Desktop.
Build lxd-p2c on CentOS7
#### Run commands as root, not via sudo ####
sudo su -
yum --enablerepo="base" -y install yum-utils
yum install yum-plugin-copr epel-release -y
yum install wget curl sqlite-devel dnsmasq squashfs-tools libacl-devel python-pthreading glibc-utils glibc-devel glibc-headers glibc-static rsync librsync librsync-devel -y
yum groupinstall "Development Tools" "Development Libraries" -y
wget -O go1.11.1.linux-amd64.tar.gz https://dl.google.com/go/go1.11.1.linux-amd64.tar.gz
tar -C /usr/local -xzf go1.11.1.linux-amd64.tar.gz
export PATH=$PATH:/usr/local/go/bin
#### Building dynamically linked binary (recommended) ####
export GOPATH=/tmp/dynamic/gocode
go get -a -v -x github.com/lxc/lxd/lxd-p2c
### If all succeeds, binary will located @ /tmp/dynamic/gocode/bin/lxd-p2c
ldd /tmp/dynamic/gocode/bin/lxd-p2c
linux-vdso.so.1 => (0x00007ffef88ff000)
libutil.so.1 => /lib64/libutil.so.1 (0x00007f6ecd3bd000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f6ecd1a1000)
libc.so.6 => /lib64/libc.so.6 (0x00007f6eccdd4000)
/lib64/ld-linux-x86-64.so.2 (0x00007f6ecd5c0000)
/tmp/dynamic/gocode/bin/lxd-p2c -h
Description:
Physical to container migration tool
This tool lets you turn any Linux filesystem (including your current one)
into a LXD container on a remote LXD host.
It will setup a clean mount tree made of the root filesystem and any
additional mount you list, then transfer this through LXD's migration
API to create a new container from it.
The same set of options as `lxc launch` are also supported.
Usage:
lxd-p2c <target URL> <container name> <filesystem root> [<filesystem mounts>...] [flags]
Flags:
-c, --config Configuration key and value to set on the container
-h, --help Print help
-n, --network Network to use for the container
--no-profiles Create the container with no profiles applied
-p, --profile Profile to apply to the container
--rsync-args Extra arguments to pass to rsync
-s, --storage Storage pool to use for the container
-t, --type Instance type to use for the container
--version Print version number
#### Build statically linked binary ####
export GOPATH=/tmp/static/gocode
go get -a -v -x -ldflags '-extldflags "-static"' github.com/lxc/lxd/lxd-p2c
### If all succeeds, binary will located @ /tmp/static/gocode/bin/lxd-p2c
ldd /tmp/static/gocode/bin/lxd-p2c
not a dynamic executable
/tmp/static/gocode/bin/lxd-p2c -h
Description:
Physical to container migration tool
This tool lets you turn any Linux filesystem (including your current one)
into a LXD container on a remote LXD host.
It will setup a clean mount tree made of the root filesystem and any
additional mount you list, then transfer this through LXD's migration
API to create a new container from it.
The same set of options as `lxc launch` are also supported.
Usage:
lxd-p2c <target URL> <container name> <filesystem root> [<filesystem mounts>...] [flags]
Flags:
-c, --config Configuration key and value to set on the container
-h, --help Print help
-n, --network Network to use for the container
--no-profiles Create the container with no profiles applied
-p, --profile Profile to apply to the container
--rsync-args Extra arguments to pass to rsync
-s, --storage Storage pool to use for the container
-t, --type Instance type to use for the container
--version Print version number
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment