Created
June 24, 2016 11:08
-
-
Save jpic/362fd277e6b836354fa0163dd1f9197b to your computer and use it in GitHub Desktop.
Creating a busybox image for lxd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
image=$1 | |
if [ -f $image ]; then | |
exit 0 | |
fi | |
path=$(mktemp --directory lxdapi.busybox.XXXXXXXX) | |
arch=$(uname --machine) | |
mkdir -p $path/rootfs/{bin,dev,etc,mnt,proc,root,sys,tmp} | |
# Add an /etc/inittab; this is to work around: | |
# http://lists.busybox.net/pipermail/busybox/2015-November/083618.html | |
# Basically, since there are some hardcoded defaults that misbehave, we | |
# just pass an empty inittab so those aren't applied, and then busybox | |
# doesn't spin forever. | |
touch /rootfs/etc/inittab | |
cat > $path/metadata.yaml <<EOF | |
architecture: $arch | |
creation_date: $(date +%s) | |
properties: | |
os: Busybox | |
architecture: $arch | |
description: Busybox $arch | |
name: Busybox-$arch | |
EOF | |
cat > $path/metadata.yaml <<EOF | |
{ | |
"architecture": "x86_64", | |
"creation_date": 1463647974, | |
"properties": { | |
"architecture": "x86_64", | |
"description": "Busybox x86_64", | |
"name": "busybox-x86_64", | |
"obfuscate": "<function uuid4 at 0x7f7e75833488>", | |
"os": "Busybox" | |
} | |
} | |
EOF | |
cp $(which busybox) $path/rootfs/bin | |
$path/rootfs/bin/busybox --install -s $path/rootfs/bin | |
pushd $path | |
tar cvJf ../$image . | |
popd | |
rm -rf $path |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment