Page 1 of 1

MyOS Problem

Posted: Sat Aug 13, 2011 5:49 pm
by jackson
Hi my name is Jackson and I'm a following the tuturial series and building a bootloader. I'm using Linux Mint 10 for all of the compiling and coding. I'm wondering how to put both of them on a floppy. I like linux and mac but not windows. It would be great if somebody could explain.

Re: MyOS Problem

Posted: Sat Aug 13, 2011 11:21 pm
by Andyhhp
dd is your friend. It is much nicer than the windows alternatives.

See man dd for details.

Re: MyOS Problem

Posted: Sun Aug 14, 2011 1:43 am
by jackson
Thanks but how do you put stage2 on it. I've tried to use loopback but it won't work

Re: MyOS Problem

Posted: Sun Aug 14, 2011 10:43 am
by Andyhhp
Yes it really will.

You make a loopback device, dd the bootsector to the beginning, remount it to get the correct filesystem driver, and cp the second stage on.

~Andrew

Re: MyOS Problem

Posted: Sun Aug 14, 2011 2:31 pm
by jackson
So it would look like this right?

dd if=Stage1.bin bs512 count=2880 of OS.img

losetup /dev/loop0 OS.img

mkdosfs /dev/loop0

mount -t msdos /dev/loop0 /mnt/MyOS

cp OS.img Stage1.bin

Re: MyOS Problem

Posted: Sun Aug 14, 2011 5:06 pm
by jackson
This is the .sh build file I use but when I type
sudo bash
./MyOS/build.sh

It says

Compiling Files...
Copying bootloader to floppy...
1+0 records in
1+0 records out
Copying Kernel and files to floppy...
cp: cannot create regular file `tmp-loop/KRNLDR.SYS': No space left on device
Unmounting loopback floppy
Done

Why does it say "cp: cannot create regular file `tmp-loop/KRNLDR.SYS': No space left on device "

So no matter what if run it in qemu it won't work because the Stage2 file is not on the floppy image because

Here's the file I don't know why but, it won't work.

if test "`whoami`" != "root" ; then
echo "You must be logged in as root to build"
echo "Enter su or sudo bash to switch to root"
exit
fi

if [ ! -e coppingos.flp]
then
echo "Making Floppy..."
mkdosfs -C MyOS/MyOS.flp 1440 || exit
fi

echo "Compiling Files..."
nasm MyOS/Stage2.asm -o MyOS/KRNLDR.SYS
nasm MyOS/Stage1.asm -o MyOS/Stage1.bin

echo "Copying bootloader to floppy..."

dd status=noxfer conv=notrunc if=MyOS/Stage1.bin of=MyOS/MyOS.flp || exit

echo "Copying Kernel and files to floppy..."

rm -rf tmp-loop

mkdir tmp-loop && mount -o loop -t vfat MyOS/MyOS.flp tmp-loop && cp MyOS/KRNLDR.SYS tmp-loop

echo "Unmounting loopback floppy"

umount tmp-loop || exit

rm -rf tmp-loop

echo "Done"

Re: MyOS Problem

Posted: Fri Aug 19, 2011 7:22 am
by chibicitiberiu
Here is an article which may be useful: http://wiki.osdev.org/GRUB#Installing_to_floppy

And as a tip, you can type #!/bin/bash in the first line of your shell script, then enable permission to execute file (from Properties - Permissions), and then you can launch it as executable.