a minimized terminal live iso
This commit is contained in:
commit
d237e32c3d
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
build-*/
|
||||
*.iso
|
97
mkiso-debian.sh
Normal file
97
mkiso-debian.sh
Normal file
@ -0,0 +1,97 @@
|
||||
#!/bin/bash
|
||||
|
||||
function mount_rootfs() {
|
||||
mkdir -p chroot/dev chroot/dev/pts chroot/proc chroot/sys chroot/run
|
||||
sudo mount --bind /dev chroot/dev
|
||||
sudo mount --bind /dev/pts chroot/dev/pts
|
||||
sudo mount --bind /proc chroot/proc
|
||||
sudo mount --bind /sys chroot/sys
|
||||
sudo mount --bind /run chroot/run
|
||||
}
|
||||
|
||||
function unmount_rootfs() {
|
||||
sudo umount chroot/dev/pts
|
||||
sudo umount chroot/dev
|
||||
sudo umount chroot/proc
|
||||
sudo umount chroot/sys
|
||||
sudo umount chroot/run
|
||||
}
|
||||
|
||||
function chroot_cmd() {
|
||||
sudo env DEBIAN_FRONTEND=noninteractive chroot chroot "$@"
|
||||
}
|
||||
|
||||
function chroot_apt() {
|
||||
chroot_cmd apt "$@"
|
||||
}
|
||||
|
||||
function install_iso_build_deps() {
|
||||
sudo apt install -y debootstrap squashfs-tools syslinux xorriso p7zip-full
|
||||
}
|
||||
|
||||
function debootstrap_base() {
|
||||
sudo debootstrap --arch=amd64 testing chroot https://mirrors.tuna.tsinghua.edu.cn/debian/
|
||||
}
|
||||
|
||||
function update_sourcelists() {
|
||||
echo "deb https://mirrors.tuna.tsinghua.edu.cn/debian/ testing main contrib non-free non-free-firmware" | sudo tee chroot/etc/apt/sources.list
|
||||
echo "deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ testing main contrib non-free non-free-firmware" | sudo tee -a chroot/etc/apt/sources.list
|
||||
}
|
||||
|
||||
function chroot_install_base_packages() {
|
||||
chroot_apt update
|
||||
chroot_apt upgrade -y
|
||||
chroot_apt install -y zsh
|
||||
chroot_apt install -y live-boot live-config-systemd --no-install-recommends
|
||||
# chroot_apt install -y lxqt-core sddm-theme-debian-elarun
|
||||
chroot_apt install -y linux-image-amd64
|
||||
}
|
||||
|
||||
function chroot_create_live_user() {
|
||||
chroot_cmd useradd -m -s /bin/bash live
|
||||
echo "live:live" | chroot_cmd chpasswd
|
||||
}
|
||||
|
||||
function make_bootable() {
|
||||
cp "$(ls -1t chroot/boot/vmlinuz-* | head -n 1)" isoroot/vmlinuz
|
||||
cp "$(ls -1t chroot/boot/initrd.img-* | head -n 1)" isoroot/initrd
|
||||
mkdir isoroot/isolinux
|
||||
cp /usr/lib/ISOLINUX/isolinux.bin isoroot/isolinux
|
||||
cp /usr/lib/syslinux/modules/bios/ldlinux.c32 isoroot/isolinux
|
||||
cp ../isolinux.cfg isoroot/isolinux/isolinux.cfg
|
||||
cat > isoroot/isolinux/isolinux.cfg <<EOL
|
||||
DEFAULT live
|
||||
LABEL live
|
||||
MENU LABEL ^Boot Live System
|
||||
KERNEL /vmlinuz
|
||||
APPEND initrd=/initrd boot=live components
|
||||
EOL
|
||||
|
||||
}
|
||||
|
||||
function create_iso() {
|
||||
xorriso -as mkisofs -o ../debian-live.iso -isohybrid-mbr /usr/lib/ISOLINUX/isohdpfx.bin \
|
||||
-c isolinux/boot.cat -b isolinux/isolinux.bin -no-emul-boot \
|
||||
-exclude chroot \
|
||||
-boot-load-size 4 -boot-info-table \
|
||||
./isoroot/
|
||||
7z l ../debian-live.iso
|
||||
}
|
||||
|
||||
function main() {
|
||||
set -e
|
||||
install_iso_build_deps
|
||||
|
||||
mkdir chroot
|
||||
debootstrap_base
|
||||
update_sourcelists
|
||||
mount_rootfs
|
||||
chroot_install_base_packages
|
||||
chroot_create_live_user
|
||||
unmount_rootfs
|
||||
|
||||
mkdir -p isoroot/live
|
||||
sudo mksquashfs chroot/ isoroot/live/filesystem.squashfs -comp xz -e boot
|
||||
make_bootable
|
||||
create_iso
|
||||
}
|
Loading…
Reference in New Issue
Block a user