Last active
October 1, 2025 08:43
-
-
Save alirezaarzehgar/8d2cb5e4f1855653115ebb5eeaff4a8c to your computer and use it in GitHub Desktop.
Create Super Minimal Linux Live Distro!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| URL="https://www.busybox.net/downloads/binaries/1.31.0-defconfig-multiarch-musl/busybox-x86_64" | |
| OS_NAME=AliOS.img | |
| [ -d /tmp/root ] && rm /tmp/root/boot | |
| # Install Busybox | |
| mkdir -p /tmp/root/{bin,dev,etc,lib,mnt,proc,sbin,sys,tmp,var,boot/grub} | |
| cd /tmp/root || exit | |
| wget ${URL} --no-clobber -O bin/busybox | |
| chmod +x bin/busybox | |
| # Create Initramfs | |
| echo "#!/bin/busybox sh | |
| /bin/busybox --install -s /bin | |
| clear | |
| mount -t devtmpfs devtmpfs /dev | |
| mount -t proc proc /proc | |
| mount -t sysfs sysfs /sys | |
| mount -t tmpfs tmpfs /tmp | |
| setsid cttyhack sh | |
| exec /bin/sh" >init | |
| chmod +x init | |
| find . | cpio -ov --format=newc | gzip -9 >boot/initramfs | |
| echo "linux /boot/vmlinuz ro quiet | |
| initrd /boot/initramfs | |
| boot" >boot/grub/grub.cfg | |
| cp -f /boot/vmlinuz-"$(uname -r)" boot/vmlinuz | |
| cd - | |
| grub-mkrescue -o ${OS_NAME} /tmp/root |
واسه اینکه این خطای زیر رو نخورید:
grub-mkrescue: error: mformat invocation failed
باید بسته mtools رو نصب داشته باشید.
کلا بسته های زیر رو نصب داشته باشید:
- xorriso qemu-system-x86 grub-pc-bin
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
عالی !