This repository contains images for PKU CLab.
# Clone this repository
git clone https://github.com/lcpu-club/clab-images.git
cd clab-images
# build the image
./bin/build-vm <distro> <flavor>
qemu-img
qemu-nbd
You should setup some variables and functions in images/<distro>/common.sh
. You can find an example in images/ubuntu/common.sh
.
DISTRO=<distro>
BASE_IMAGE=<base_image>
function download_source(){}
function resize_image(){}
function os_update(){}
function os_install(){}
function os_cleanup(){}
function mount_image(){}
function unmount_image(){}
Two functions should be defined in images/<distro>/<flavor>/build.sh
. You can find an example in images/ubuntu/pku/build.sh
.
IMAGE_NAME=<image_name>
DISK_SIZE=<disk_size>
PACKAGES=(<package1> <package2> ...)
SERVICES=(<service1> <service2> ...)
function pre(){}
function post(){}
Note, pre will be executed after the installation of packages, and post will be executed before the cleanup.
post
function will compress the image and create a new one. You should specify image type correctly. If the source image is qcow2
, but you specify raw
in post
, the partition table will be lost.
vscode git plugin will scan your working directory and cause the mount point busy. You should close vscode or change the working directory.