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-imgqemu-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_change_source(){}
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.
用YAML配置文件替代build.sh中的手动文件复制和权限设置。
在每个flavor目录下创建files.yml文件:
files:
- src: "config.conf"
dest: "/etc/"
- src: "app.service"
dest: "/etc/systemd/system/"
mode: "644"
- src: ".bashrc"
dest: "/home/user/"
owner: "1000:1000"
mode: "644"
ownership:
- path: "/home/user"
owner: "1000:1000"
recursive: truesrc: 源文件(相对于flavor目录)dest: 目标路径mode: 文件权限(可选)owner: 文件所有者(可选)create_dirs: 自动创建目录(可选)
path: 目录路径owner: 所有者recursive: 递归设置(可选)
参考:
images/ubuntu24.04/ics-server/files.ymlimages/almalinux8.10/eda/files.yml
cd test
./test-filelist.sh