-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild_live_boot
More file actions
executable file
·58 lines (43 loc) · 1.4 KB
/
build_live_boot
File metadata and controls
executable file
·58 lines (43 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/bash
set -e
# Yêu cầu quyền sudo nếu không phải root
if [[ $EUID -ne 0 ]]; then
echo "⚠️ This script must be run as root (sudo)"
exec sudo "$0" "$@"
exit 1
fi
BUILD_DIR="build/live_boot"
CHROOT="build/chroot"
OUTPUT="releases/mini-os.iso"
# Gỡ mount còn tồn tại
echo "🔄 Gỡ tất cả mount trong $CHROOT nếu còn..."
sudo mount | grep "$CHROOT" | awk '{print $3}' | sort -r | xargs -r sudo umount -lf
# tải những thứ sửa đổi vào chroot
bash start_mod
#cập nhật lại dns
cat > "$CHROOT/etc/resolv.conf" <<EOF
nameserver 8.8.8.8
nameserver 8.8.4.4
EOF
rm -rf $BUILD_DIR
mkdir -p $BUILD_DIR
mkdir -p $BUILD_DIR/live
# Copy kernel và initrd
cp -a $CHROOT/boot/vmlinuz-6.8.0-64-generic $BUILD_DIR/live/vmlinuz
cp -a $CHROOT/boot/initrd.img-6.8.0-64-generic $BUILD_DIR/live/initrd
# update menu GRUB
mkdir -p $BUILD_DIR/boot/grub
cp -a config/grub_live_boot.cfg $BUILD_DIR/boot/grub/grub.cfg
# pack squashfs
# bash clear_cache
echo "🔄 đang nén $BUILD_DIR"
echo "🔄 Dung lượng: $(du -sh $CHROOT)"
rm -rf $BUILD_DIR/live/filesystem.squashfs
mksquashfs $CHROOT $BUILD_DIR/live/filesystem.squashfs
# Build ISO boot
rm -rf $OUTPUT
grub-mkrescue -o $OUTPUT $BUILD_DIR --modules="linux normal iso9660 memdisk search tar ls" --xorriso=/usr/bin/xorriso
# dọn dẹp
echo "🔄 dọn dẹp thư mục $BUILD_DIR"
rm -rf $BUILD_DIR
echo "✅ hoàn thành: $OUTPUT"