Skip to content

Instantly share code, notes, and snippets.

@Mr-Bossman
Last active May 19, 2025 17:27
Show Gist options
  • Select an option

  • Save Mr-Bossman/2cb4fc98fb6c8fdc9dd724ae5232789c to your computer and use it in GitHub Desktop.

Select an option

Save Mr-Bossman/2cb4fc98fb6c8fdc9dd724ae5232789c to your computer and use it in GitHub Desktop.

Revisions

  1. Mr-Bossman revised this gist May 19, 2025. 1 changed file with 12 additions and 6 deletions.
    18 changes: 12 additions & 6 deletions emile-68k-qemu.sh
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    #!/bin/bash
    PART_NAME="test"
    IMG_NAME="test.img"
    PART_NAME="linux"
    IMG_NAME="emile.img"
    PART_SIZE=$((1024*1024*1000))
    BS=$((1024*1024))

    @@ -35,7 +35,15 @@ cat << EOF > setup.sh
    #!/bin/bash
    /debootstrap/debootstrap --second-stage
    cat << EOT >> etc/initramfs-tools/modules
    mac_esp
    esp_scsi
    sd_mod
    EOT
    update-initramfs -u -k all
    EOF

    chmod +x setup.sh
    sudo mv setup.sh rootfs/

    @@ -62,9 +70,8 @@ cat << EOF > setup.sh
    emile --backup
    emile
    echo exit qemu please
    sync
    read
    poweroff -f
    EOF
    chmod +x setup.sh
    sudo mv setup.sh rootfs/
    @@ -78,7 +85,6 @@ rmdir rootfs

    dd if=/dev/zero of=pram.img bs=512 count=1

    #You may need to use linux-image-6.10.3-m68k
    qemu-system-m68k -M q800 -m 1000M -net nic,model=dp83932 -net user -nographic -append "root=/dev/sda4 rw console=ttyS0 init=/setup.sh" -kernel vmlinuz -initrd initrd.img -drive file="$IMG_NAME",format=raw

    exit
    @@ -92,4 +98,4 @@ qemu-system-m68k \
    -display gtk \
    -device scsi-hd,scsi-id=0,drive=hd1 \
    -drive file=pram.img,format=raw,if=mtd \
    -drive file=test.img,media=disk,format=raw,if=none,id=hd1
    -drive file=emile.img,media=disk,format=raw,if=none,id=hd1
  2. Mr-Bossman revised this gist May 19, 2025. 1 changed file with 22 additions and 21 deletions.
    43 changes: 22 additions & 21 deletions emile-68k-qemu.sh
    Original file line number Diff line number Diff line change
    @@ -1,36 +1,36 @@
    #!/bin/bash
    PART_NAME=test
    IMG_NAME=test.img
    PART_NAME="test"
    IMG_NAME="test.img"
    PART_SIZE=$((1024*1024*1000))
    BS=$((1024*1024))

    # HD0-OpenRetroSCSI-7.5.3.hda
    # https://mega.nz/folder/8hA3AQCJ#pWUq92L70yDXlogy9lk5Dg/file/hkIxnQ4S
    #mv HD0-OpenRetroSCSI-7.5.3.hda MacOS.img
    cp MacOS.img $IMG_NAME
    dd if=/dev/zero of=$IMG_NAME conv=notrunc oflag=sync,append status=progress bs=$BS count=$(( $PART_SIZE / $BS ))
    cp MacOS.img "$IMG_NAME"
    dd if=/dev/zero of="$IMG_NAME" conv=notrunc oflag=sync,append status=progress bs="$BS" count=$(( PART_SIZE / BS ))

    START_SEC=$(partx -ro START $IMG_NAME | sort -n | tail -n1)
    LAST_SEC=$(($START_SEC - 1))
    END_SEC=$(($LAST_SEC + ( $PART_SIZE ) / 512))
    START_SEC=$(partx -ro START "$IMG_NAME" | sort -n | tail -n1)
    LAST_SEC=$((START_SEC - 1))
    END_SEC=$((LAST_SEC + ( PART_SIZE ) / 512))

    dd if=$IMG_NAME of=${IMG_NAME}.tmp bs=512 count=1
    parted -s $IMG_NAME mkpart $PART_NAME ext4 ${START_SEC}s ${END_SEC}s
    dd if=${IMG_NAME}.tmp of=$IMG_NAME bs=512 count=1 conv=notrunc oflag=sync
    rm ${IMG_NAME}.tmp
    dd if="$IMG_NAME" of="$IMG_NAME".tmp bs=512 count=1
    parted -s "$IMG_NAME" mkpart "$PART_NAME" ext4 "$START_SEC"s "$END_SEC"s
    dd if="$IMG_NAME".tmp of="$IMG_NAME" bs=512 count=1 conv=notrunc oflag=sync
    rm "$IMG_NAME".tmp

    PART_NUM=$(partx $IMG_NAME -o NR,NAME | sed -nr "s/([0-9]+) $PART_NAME/\1/p")
    PART_NUM=$(($PART_NUM + 0))
    PART_NUM=$(partx "$IMG_NAME" -o NR,NAME | sed -nr "s/([0-9]+) $PART_NAME/\1/p")
    PART_NUM=$((PART_NUM + 0))

    LOOP_DEV=$(losetup -f)
    ROOT_PART=${LOOP_DEV}p${PART_NUM}
    ROOT_PART="$LOOP_DEV"p"$PART_NUM"

    losetup -P $LOOP_DEV $IMG_NAME
    sudo mke2fs $ROOT_PART
    losetup -P "$LOOP_DEV" "$IMG_NAME"
    sudo mke2fs "$ROOT_PART"
    mkdir -p rootfs
    sudo mount $ROOT_PART rootfs
    sudo mount "$ROOT_PART" rootfs
    sudo debootstrap --no-check-gpg --arch=m68k --foreign --variant=minbase --components=main,non-free --include=nano,linux-image-m68k,systemd-sysv,emile --extra-suites=unreleased sid rootfs https://deb.debian.org/debian-ports/
    sudo cp $(which qemu-m68k-static) rootfs/usr/bin/
    sudo cp "$(which qemu-m68k-static)" rootfs/usr/bin/
    cat << EOF > setup.sh
    #!/bin/bash
    /debootstrap/debootstrap --second-stage
    @@ -69,21 +69,22 @@ EOF
    chmod +x setup.sh
    sudo mv setup.sh rootfs/

    cp rootfs/vmlinux .
    cp rootfs/vmlinuz .
    cp rootfs/initrd.img .

    sudo umount rootfs
    losetup -D $LOOP_DEV
    losetup -D "$LOOP_DEV"
    rmdir rootfs

    dd if=/dev/zero of=pram.img bs=512 count=1

    #You may need to use linux-image-6.10.3-m68k
    qemu-system-m68k -M q800 -m 1000M -net nic,model=dp83932 -net user -nographic -append "root=/dev/sda4 rw console=ttyS0 init=/setup.sh" -kernel vmlinux -initrd initrd.img -drive file=$IMG_NAME,format=raw
    qemu-system-m68k -M q800 -m 1000M -net nic,model=dp83932 -net user -nographic -append "root=/dev/sda4 rw console=ttyS0 init=/setup.sh" -kernel vmlinuz -initrd initrd.img -drive file="$IMG_NAME",format=raw

    exit

    # https://www.macintoshrepository.org/7038-all-macintosh-roms-68k-ppc- Old_World_Mac_Roms.zip
    # shellcheck disable=SC2317
    qemu-system-m68k \
    -M q800 \
    -bios Quadra800.rom \
  3. Mr-Bossman created this gist May 19, 2025.
    94 changes: 94 additions & 0 deletions emile-68k-qemu.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,94 @@
    #!/bin/bash
    PART_NAME=test
    IMG_NAME=test.img
    PART_SIZE=$((1024*1024*1000))
    BS=$((1024*1024))

    # HD0-OpenRetroSCSI-7.5.3.hda
    # https://mega.nz/folder/8hA3AQCJ#pWUq92L70yDXlogy9lk5Dg/file/hkIxnQ4S
    #mv HD0-OpenRetroSCSI-7.5.3.hda MacOS.img
    cp MacOS.img $IMG_NAME
    dd if=/dev/zero of=$IMG_NAME conv=notrunc oflag=sync,append status=progress bs=$BS count=$(( $PART_SIZE / $BS ))

    START_SEC=$(partx -ro START $IMG_NAME | sort -n | tail -n1)
    LAST_SEC=$(($START_SEC - 1))
    END_SEC=$(($LAST_SEC + ( $PART_SIZE ) / 512))

    dd if=$IMG_NAME of=${IMG_NAME}.tmp bs=512 count=1
    parted -s $IMG_NAME mkpart $PART_NAME ext4 ${START_SEC}s ${END_SEC}s
    dd if=${IMG_NAME}.tmp of=$IMG_NAME bs=512 count=1 conv=notrunc oflag=sync
    rm ${IMG_NAME}.tmp

    PART_NUM=$(partx $IMG_NAME -o NR,NAME | sed -nr "s/([0-9]+) $PART_NAME/\1/p")
    PART_NUM=$(($PART_NUM + 0))

    LOOP_DEV=$(losetup -f)
    ROOT_PART=${LOOP_DEV}p${PART_NUM}

    losetup -P $LOOP_DEV $IMG_NAME
    sudo mke2fs $ROOT_PART
    mkdir -p rootfs
    sudo mount $ROOT_PART rootfs
    sudo debootstrap --no-check-gpg --arch=m68k --foreign --variant=minbase --components=main,non-free --include=nano,linux-image-m68k,systemd-sysv,emile --extra-suites=unreleased sid rootfs https://deb.debian.org/debian-ports/
    sudo cp $(which qemu-m68k-static) rootfs/usr/bin/
    cat << EOF > setup.sh
    #!/bin/bash
    /debootstrap/debootstrap --second-stage
    EOF
    chmod +x setup.sh
    sudo mv setup.sh rootfs/

    sudo chroot rootfs/ /usr/bin/qemu-m68k-static /bin/bash /setup.sh

    cat << EOF > emile.conf
    partition /dev/sda3
    first_level /boot/emile/first_scsi
    second_level /boot/emile/second_scsi
    timeout 5
    default 0
    title Debian GNU/Linux
    root ext2:(sd0,3)
    kernel /vmlinuz
    initrd /initrd.img
    args root=/dev/sda4 rw rootwait earlyprintk console=ttyS0 console=tty0 fbcon=font:ProFont6x11 ignore_loglevel printk.time=1
    EOF
    sudo mv emile.conf rootfs/boot/emile/

    cat << EOF > setup.sh
    #!/bin/bash
    emile --backup
    emile
    echo exit qemu please
    sync
    read
    EOF
    chmod +x setup.sh
    sudo mv setup.sh rootfs/

    cp rootfs/vmlinux .
    cp rootfs/initrd.img .

    sudo umount rootfs
    losetup -D $LOOP_DEV
    rmdir rootfs

    dd if=/dev/zero of=pram.img bs=512 count=1

    #You may need to use linux-image-6.10.3-m68k
    qemu-system-m68k -M q800 -m 1000M -net nic,model=dp83932 -net user -nographic -append "root=/dev/sda4 rw console=ttyS0 init=/setup.sh" -kernel vmlinux -initrd initrd.img -drive file=$IMG_NAME,format=raw

    exit

    # https://www.macintoshrepository.org/7038-all-macintosh-roms-68k-ppc- Old_World_Mac_Roms.zip
    qemu-system-m68k \
    -M q800 \
    -bios Quadra800.rom \
    -m 128 \
    -display gtk \
    -device scsi-hd,scsi-id=0,drive=hd1 \
    -drive file=pram.img,format=raw,if=mtd \
    -drive file=test.img,media=disk,format=raw,if=none,id=hd1