Skip to content

Commit 21c790f

Browse files
committed
Add VirtualBox support and prebuilt kernel option
- create-vm-disk.sh: Creates VDI disk for VirtualBox - quick-test.sh: Quick status checker - 05-configure-prebuilt.sh: Uses host kernel instead of compiling
1 parent 428a4b6 commit 21c790f

3 files changed

Lines changed: 169 additions & 0 deletions

File tree

create-vm-disk.sh

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#!/bin/bash
2+
set -e
3+
4+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
5+
source "${SCRIPT_DIR}/config/blazeneuro.conf"
6+
7+
VM_DISK="blazeneuro.vdi"
8+
VM_SIZE="8G"
9+
10+
echo "Creating VirtualBox disk image..."
11+
12+
# Create raw disk image
13+
dd if=/dev/zero of=blazeneuro.img bs=1M count=8192
14+
15+
# Create partitions
16+
parted blazeneuro.img mklabel msdos
17+
parted blazeneuro.img mkpart primary fat32 1MiB 513MiB
18+
parted blazeneuro.img mkpart primary ext4 513MiB 100%
19+
parted blazeneuro.img set 1 boot on
20+
21+
# Setup loop device
22+
LOOP_DEV=$(losetup -f --show blazeneuro.img)
23+
partprobe $LOOP_DEV
24+
25+
# Format partitions
26+
mkfs.fat -F32 ${LOOP_DEV}p1
27+
mkfs.ext4 ${LOOP_DEV}p2
28+
29+
# Mount and copy system
30+
mkdir -p /tmp/blazeneuro-boot /tmp/blazeneuro-root
31+
mount ${LOOP_DEV}p1 /tmp/blazeneuro-boot
32+
mount ${LOOP_DEV}p2 /tmp/blazeneuro-root
33+
34+
# Copy system files
35+
cp -a $LFS/* /tmp/blazeneuro-root/
36+
mkdir -p /tmp/blazeneuro-root/boot
37+
cp /tmp/blazeneuro-root/boot/vmlinuz* /tmp/blazeneuro-boot/
38+
39+
# Install GRUB
40+
grub-install --target=i386-pc --boot-directory=/tmp/blazeneuro-boot ${LOOP_DEV}
41+
42+
# Create GRUB config
43+
cat > /tmp/blazeneuro-boot/grub/grub.cfg << EOF
44+
set default=0
45+
set timeout=5
46+
47+
menuentry "BlazeNeuro Linux" {
48+
linux /vmlinuz-blazeneuro root=/dev/sda2 rw
49+
}
50+
EOF
51+
52+
# Cleanup
53+
umount /tmp/blazeneuro-boot /tmp/blazeneuro-root
54+
losetup -d $LOOP_DEV
55+
56+
# Convert to VDI
57+
VBoxManage convertfromraw blazeneuro.img "$VM_DISK" --format VDI
58+
rm blazeneuro.img
59+
60+
echo "VirtualBox disk created: $VM_DISK"
61+
echo "Create VM with this disk in VirtualBox"

quick-test.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash
2+
3+
echo "BlazeNeuro Quick Test"
4+
echo "===================="
5+
6+
# Check if system is built
7+
if [ ! -d "build" ] || [ -z "$(ls -A build 2>/dev/null)" ]; then
8+
echo "❌ System not built yet"
9+
echo "Run: sudo ./build.sh all"
10+
exit 1
11+
fi
12+
13+
echo "✅ Build directory exists"
14+
15+
# Check USB devices
16+
echo ""
17+
echo "Available USB devices:"
18+
lsblk -d -o NAME,SIZE,TYPE | grep disk
19+
20+
echo ""
21+
echo "To create bootable USB:"
22+
echo "sudo ./build.sh usb /dev/sdX"
23+
24+
echo ""
25+
echo "To create VirtualBox disk:"
26+
echo "sudo ./create-vm-disk.sh"
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
#!/bin/bash
2+
set -e
3+
4+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
5+
source "${SCRIPT_DIR}/config/blazeneuro.conf"
6+
source "${SCRIPT_DIR}/scripts/utils/common.sh"
7+
8+
log "Stage 5: System configuration with prebuilt kernel"
9+
10+
# Mount virtual filesystems
11+
mount -v --bind /dev $LFS/dev
12+
mount -v --bind /dev/pts $LFS/dev/pts
13+
mount -vt proc proc $LFS/proc
14+
mount -vt sysfs sysfs $LFS/sys
15+
mount -vt tmpfs tmpfs $LFS/run
16+
17+
# Create configuration script
18+
cat > $LFS/configure-system.sh << 'EOFCHROOT'
19+
#!/bin/bash
20+
set -e
21+
22+
# System configuration
23+
echo "blazeneuro" > /etc/hostname
24+
25+
cat > /etc/hosts << EOF
26+
127.0.0.1 localhost blazeneuro
27+
::1 localhost
28+
EOF
29+
30+
cat > /etc/fstab << EOF
31+
# <device> <mount> <type> <options> <dump> <pass>
32+
proc /proc proc defaults 0 0
33+
sysfs /sys sysfs defaults 0 0
34+
devpts /dev/pts devpts gid=5,mode=620 0 0
35+
tmpfs /run tmpfs defaults 0 0
36+
EOF
37+
38+
# Use host kernel instead of compiling
39+
KERNEL_VERSION=$(uname -r)
40+
cp /boot/vmlinuz-$KERNEL_VERSION /boot/vmlinuz-blazeneuro 2>/dev/null || \
41+
cp /boot/vmlinuz /boot/vmlinuz-blazeneuro
42+
43+
# Copy modules if available
44+
if [ -d /lib/modules/$KERNEL_VERSION ]; then
45+
cp -r /lib/modules/$KERNEL_VERSION /lib/modules/
46+
fi
47+
48+
# Install GRUB
49+
cd /sources
50+
tar -xf grub-2.12.tar.xz
51+
cd grub-2.12
52+
./configure --prefix=/usr \
53+
--sysconfdir=/etc \
54+
--disable-efiemu \
55+
--disable-werror
56+
make
57+
make install
58+
cd /sources && rm -rf grub-2.12
59+
60+
echo "System configuration with prebuilt kernel completed"
61+
EOFCHROOT
62+
63+
chmod +x $LFS/configure-system.sh
64+
65+
# Execute in chroot
66+
chroot "$LFS" /usr/bin/env -i \
67+
HOME=/root \
68+
TERM="$TERM" \
69+
PS1='(lfs chroot) \u:\w\$ ' \
70+
PATH=/usr/bin:/usr/sbin \
71+
/bin/bash /configure-system.sh
72+
73+
rm -f $LFS/configure-system.sh
74+
75+
# Unmount
76+
umount -v $LFS/dev/pts
77+
umount -v $LFS/dev
78+
umount -v $LFS/proc
79+
umount -v $LFS/sys
80+
umount -v $LFS/run
81+
82+
log_success "Stage 5 with prebuilt kernel completed"

0 commit comments

Comments
 (0)