11#! /bin/bash
22set -e
33
4- echo " ====== LUMINOS MASTER BUILD SCRIPT (v6.5 - No-Joliet Fix ) ======"
4+ echo " ====== LUMINOS MASTER BUILD SCRIPT (v6.6 - Split SquashFS Layers ) ======"
55if [ " $( id -u) " -ne 0 ]; then echo " ERROR: This script must be run as root." ; exit 1; fi
66
77# --- 1. Define Directories & Vars ---
@@ -51,11 +51,10 @@ POSSIBLE_LOCATIONS=(
5151
5252MODEL_FOUND=false
5353
54- # Strategy A: SEARCH existing models
54+ # Search existing models
5555echo " --> Searching for existing models..."
5656for LOC in " ${POSSIBLE_LOCATIONS[@]} " ; do
5757 if [ -d " $LOC " ]; then
58- echo " Checking $LOC ..."
5958 SIZE_CHECK=$( du -s " $LOC " | cut -f1)
6059 if [ " $SIZE_CHECK " -gt 1000000 ]; then
6160 echo " SUCCESS: Found valid models at $LOC ! Copying..."
@@ -66,41 +65,23 @@ for LOC in "${POSSIBLE_LOCATIONS[@]}"; do
6665 fi
6766done
6867
69- # Strategy B: DOWNLOAD if not found
68+ # Download if not found
7069if [ " $MODEL_FOUND " = false ]; then
7170 echo " --> Model not found locally. Downloading..."
72-
73- echo " --> Downloading Ollama binary..."
7471 curl -fL " https://github.com/ollama/ollama/releases/download/v0.1.32/ollama-linux-amd64" -o " ${AI_BUILD_DIR} /ollama"
7572 chmod +x " ${AI_BUILD_DIR} /ollama"
7673 export HOME=" ${AI_BUILD_DIR} "
77-
78- echo " --> Starting temporary Ollama server..."
7974 " ${AI_BUILD_DIR} /ollama" serve > " ${AI_BUILD_DIR} /server.log" 2>&1 &
8075 OLLAMA_PID=$!
8176 echo " Waiting 10s for server..."
8277 sleep 10
83-
84- echo " --> Pulling base model (llama3)..."
8578 " ${AI_BUILD_DIR} /ollama" pull llama3
86-
87- echo " --> Stopping server..."
8879 kill ${OLLAMA_PID} || true
89-
9080 if [ -d " ${AI_BUILD_DIR} /.ollama/models" ]; then
9181 cp -r " ${AI_BUILD_DIR} /.ollama/models/." " ${TARGET_MODEL_DIR} /"
9282 fi
9383fi
9484
95- SIZE_CHECK=$( du -s " ${TARGET_MODEL_DIR} " | cut -f1)
96- if [ " $SIZE_CHECK " -lt 1000000 ]; then
97- echo " ERROR: Model preparation failed. Target directory is too small ($SIZE_CHECK KB)."
98- exit 1
99- else
100- echo " SUCCESS: AI Models prepared (${SIZE_CHECK} KB)."
101- fi
102-
103-
10485# --- 5. Bootstrap Base System ---
10586echo " --> Bootstrapping Debian base..."
10687debootstrap \
@@ -129,15 +110,13 @@ echo "--> Copying assets..."
129110mkdir -p " ${CHROOT_DIR} /usr/share/wallpapers/luminos"
130111cp " ${BASE_DIR} /assets/" * " ${CHROOT_DIR} /usr/share/wallpapers/luminos/"
131112
132- echo " --> Injecting AI files into system ..."
113+ echo " --> Injecting AI Binary (Models come later via SquashFS) ..."
133114if [ ! -f " ${AI_BUILD_DIR} /ollama" ]; then
134115 curl -fL " https://github.com/ollama/ollama/releases/download/v0.1.32/ollama-linux-amd64" -o " ${AI_BUILD_DIR} /ollama"
135116 chmod +x " ${AI_BUILD_DIR} /ollama"
136117fi
137118cp " ${AI_BUILD_DIR} /ollama" " ${CHROOT_DIR} /usr/local/bin/"
138- mkdir -p " ${CHROOT_DIR} /usr/share/ollama/.ollama"
139- cp -r " ${TARGET_MODEL_DIR} " " ${CHROOT_DIR} /usr/share/ollama/.ollama/"
140- echo " --> AI Injection Complete."
119+ # NOTE: We do NOT copy models into CHROOT here. We will build a separate SquashFS for them.
141120
142121
143122# --- 7. Run Customization Scripts ---
@@ -173,9 +152,22 @@ umount "${CHROOT_DIR}/proc"
173152umount " ${CHROOT_DIR} /dev/pts"
174153umount " ${CHROOT_DIR} /dev"
175154
176- # --- 8. Build the ISO ---
177- echo " --> Compressing filesystem (SquashFS)..."
178- mksquashfs " ${CHROOT_DIR} " " ${ISO_DIR} /live/filesystem.squashfs" -e boot -comp zstd
155+ # --- 8. Build the ISO (Split Layers) ---
156+
157+ # Layer 1: The Main OS (excludes /usr/share/ollama/.ollama where models would be)
158+ echo " --> Compressing Layer 1: Main OS..."
159+ mksquashfs " ${CHROOT_DIR} " " ${ISO_DIR} /live/01-filesystem.squashfs" -e boot -e usr/share/ollama/.ollama -comp zstd
160+
161+ # Layer 2: The AI Models
162+ echo " --> Preparing Layer 2: AI Models..."
163+ # We create a temporary structure to mimic the root filesystem for the second layer
164+ AI_LAYER_DIR=" ${WORK_DIR} /ai_layer_root"
165+ mkdir -p " ${AI_LAYER_DIR} /usr/share/ollama/.ollama"
166+ # Copy models into this structure
167+ cp -r " ${TARGET_MODEL_DIR} " " ${AI_LAYER_DIR} /usr/share/ollama/.ollama/"
168+
169+ echo " --> Compressing Layer 2: AI Models..."
170+ mksquashfs " ${AI_LAYER_DIR} " " ${ISO_DIR} /live/02-ai-models.squashfs" -comp zstd
179171
180172echo " --> Preparing Bootloader (GRUB)..."
181173cp " ${CHROOT_DIR} /boot" /vmlinuz* " ${ISO_DIR} /live/vmlinuz"
@@ -190,9 +182,9 @@ menuentry "LuminOS v0.2.1 Live" {
190182}
191183EOF
192184
193- echo " --> Generating ISO image (Level 3 + No Joliet) ..."
194- # FIX: Disable Joliet (-joliet off) to bypass 4GB file limit
195- grub-mkrescue -o " ${BASE_DIR} /${ISO_NAME} " " ${ISO_DIR} " -- -joliet off -compliance iso_9660_level=3
185+ echo " --> Generating ISO image..."
186+ # No special flags needed now, as individual files are < 4GB!
187+ grub-mkrescue -o " ${BASE_DIR} /${ISO_NAME} " " ${ISO_DIR} "
196188
197189echo " --> Cleaning up work directory..."
198190sudo rm -rf " ${WORK_DIR} "
0 commit comments