Page 1 of 2
Computer with floppy
Posted: Tue Jun 09, 2015 12:28 pm
by feare56
After a low point in my life I am picking back up where I left off!
Along my break I ran into a computer that has a floppy drive, yea I know it's a little old. Luckily I have some floppies. So my question is can I put my os on the floppy and run it on real hardware? I have never tested it on real hardware but tested on qemu and worked. It is a floppy image so would I just copy or burn the files? I haven't dealt with floppies since I was like 4
Re: Computer with floppy
Posted: Tue Jun 09, 2015 1:28 pm
by SpyderTL
I actually did this when I first started working on a 16-bit version of my OS, years ago. I had "forgotten" a few things about floppies that you might want to keep in mind...
1. Floppies are unreliable. At several points, I had to write my OS to the floppy disk 2 or 3 times before it was readable by the same drive it was written in.
2. Floppies are slow. It would take several seconds to boot an OS that was essentially a boot loader, and a CLI program that only understood a few commands. Using the hard drive, cd-rom or usb thumb drive, I can boot a much more complex OS and CLI in way under a second.
3. Floppy drives are obsolete, and rather difficult to find, nowadays. USB floppy drives are actually pretty common, but I don't know if you can boot off of them. And if you can, I'm not sure that it would "look" like an actual Floppy Disk Controller from the 1980's to your OS. It would probably look more like a USB thumbdrive... but that's just a guess.
But to answer your question, yes, you can boot a (very small) OS from a floppy drive. You'll need to download a utility that can write a floppy image to a floppy disk, if you are using Windows. Linux is probably just a "dd -if disk.img -of /dev/fda".
Let us know how it works out for you.
Re: Computer with floppy
Posted: Tue Jun 09, 2015 1:31 pm
by Octocontrabass
feare56 wrote:So my question is can I put my os on the floppy and run it on real hardware?
Yes. I do this with my OS project, so I'm pretty familiar with the process.
feare56 wrote:It is a floppy image so would I just copy or burn the files?
Write the image directly to the disk, using a utility such as dd or a hex editor with raw disk access like HxD. You'll probably want to format the disk first, to verify that it can be written and read correctly and ensure the sector layout is standard.
Re: Computer with floppy
Posted: Tue Jun 09, 2015 4:11 pm
by feare56
Ok, while testing a floppy image I found online and put my kernel.bin in by using magiciso, it says on boot something like "image file not found". If it makes a difference I just drag and dropped the kernel file in. I'm on windows and I'm using RawWrite to write to floppy
Re: Computer with floppy
Posted: Tue Jun 09, 2015 4:48 pm
by SpyderTL
What boot loader are you using? Is it "smart" enough to boot from a floppy disk?
Re: Computer with floppy
Posted: Tue Jun 09, 2015 5:30 pm
by feare56
From what I am guessing there is no boot loader but when I test an iso that has only the kernel on it via qemu it works. Granted the only thing I did different was told magiciso to make the iso boot to kernel.bin
Re: Computer with floppy
Posted: Tue Jun 09, 2015 6:10 pm
by Brendan
Hi,
feare56 wrote:From what I am guessing there is no boot loader but when I test an iso that has only the kernel on it via qemu it works. Granted the only thing I did different was told magiciso to make the iso boot to kernel.bin
If your "kernel.bin" has real mode startup code and expects to run at 0x00007C00; then it's plausible for CD, assuming magicISO creates the necessary El Torito information which causes the entire "boot loader" (your kernel) to be loaded and executed.
For floppy there is no El Torito, it's not ISO, the firmware doesn't load the entire file (and only loads one sector); and because of all this the boot loader needs to be designed for it (e.g. that loads the remainder of the "boot loader"/kernel), and magicISO makes no sense at all because it works on CD/ISO images and not floppy.
Cheers,
Brendan
Re: Computer with floppy
Posted: Tue Jun 09, 2015 10:48 pm
by feare56
Ok so find or make a boot loader, put it in first sector, and then point it to the kernel in the second sector? Is grub able to boot from floppy?
Re: Computer with floppy
Posted: Wed Jun 10, 2015 1:54 am
by Brendan
Hi,
feare56 wrote:Ok so find or make a boot loader, put it in first sector, and then point it to the kernel in the second sector? Is grub able to boot from floppy?
GRUB is able to boot from floppy; but it expects the kernel to have a special header and starts the kernel in 32-bit protected mode (not real mode); and will expect the floppy to be formatted with a "known" file system (e.g. FAT) and will load the kernel from that file system.
Cheers,
Brendan
Re: Computer with floppy
Posted: Wed Jun 10, 2015 4:09 am
by Icee
Brendan wrote:GRUB is able to boot from floppy; but it expects the kernel to have a special header and starts the kernel in 32-bit protected mode (not real mode); and will expect the floppy to be formatted with a "known" file system (e.g. FAT) and will load the kernel from that file system.
Actually, the chainloader command with a block list argument (as in (fd0)1+x) should do just fine for a real mode kernel written to the floppy starting from the second sector.
Re: Computer with floppy
Posted: Wed Jun 10, 2015 4:52 am
by Brendan
Hi,
Icee wrote:Brendan wrote:GRUB is able to boot from floppy; but it expects the kernel to have a special header and starts the kernel in 32-bit protected mode (not real mode); and will expect the floppy to be formatted with a "known" file system (e.g. FAT) and will load the kernel from that file system.
Actually, the chainloader command with a block list argument (as in (fd0)1+x) should do just fine for a real mode kernel written to the floppy starting from the second sector.
Yes; as long as GRUB isn't on the floppy, and as long as you don't mind fixing it every time the size of anything changes. Basically, "best case" is a crippled pain in the neck.
Note that for someone who has written a real mode kernel, writing a boot loader for floppy should be a simple ~20 minute job. It'd probably take longer to figure out how to get GRUB to work, and you can bet that ~20 minute boot loader will be far more efficient and much easier to extend/adapt later.
Cheers,
Brendan
Re: Computer with floppy
Posted: Wed Jun 10, 2015 6:31 am
by Kevin
Brendan wrote:Note that for someone who has written a real mode kernel, writing a boot loader for floppy should be a simple ~20 minute job.
That depends. If that real mode kernel is just a better Hello World, you can't conclude much from it. Unfortunately, most of the people asking how to write a boot sector are complete beginners, and it's not a ~20 minute job for them. It will take them longer, and even if they succeed in the end, it will show who wrote that so called boot loader, and it will be a source of endless pain because of how bad that boot loader is.
People should only be guided into writing a custom bootloader if they know what they are doing and why they need it. Beginners are not in this category.
Re: Computer with floppy
Posted: Wed Jun 10, 2015 2:08 pm
by Brendan
Hi,
Kevin wrote:Brendan wrote:Note that for someone who has written a real mode kernel, writing a boot loader for floppy should be a simple ~20 minute job.
That depends. If that real mode kernel is just a better Hello World, you can't conclude much from it. Unfortunately, most of the people asking how to write a boot sector are complete beginners, and it's not a ~20 minute job for them. It will take them longer, and even if they succeed in the end, it will show who wrote that so called boot loader, and it will be a source of endless pain because of how bad that boot loader is.
In that case, you'd spend "X hours" learning things that you'd need to know for both the boot loader and the real mode kernel, and ~20 minutes implementing the boot loader. That "X hours" isn't wasted, it's unavoidable because you have to learn it eventually (for the kernel).
Of course for people writing a protected mode and/or long kernel it'd be potentially different (that "X hours" spent learning about real mode and BIOS is much more likely to be time wasted). It could also be argued that writing a real mode kernel is a complete waste of time (and that would imply the "X hours" learning about real mode and BIOS plus the ~20 minutes implementing boot loader plus the "Y hours" implementing the kernel all adds up to "X + Y + 20/60" hours of wasted time).
Kevin wrote:People should only be guided into writing a custom bootloader if they know what they are doing and why they need it. Beginners are not in this category.
People should be guided into using the right tool for the job. For a real mode kernel GRUB is not the right tool (it's pointless bloat that achieves nothing). For an advanced OS GRUB is not the right tool (it severely limits design flexibility). For someone learning how things work, avoiding learning how boot loaders work is the opposite of their goal so GRUB is probably not the right tool for that either. For all other cases GRUB may be the right tool (assuming other cases actually exist).
Cheers,
Brendan
Re: Computer with floppy
Posted: Wed Jun 10, 2015 3:18 pm
by feare56
Brendan wrote:
Of course for people writing a protected mode and/or long kernel it'd be potentially different (that "X hours" spent learning about real mode and BIOS is much more likely to be time wasted). It could also be argued that writing a real mode kernel is a complete waste of time (and that would imply the "X hours" learning about real mode and BIOS plus the ~20 minutes implementing boot loader plus the "Y hours" implementing the kernel all adds up to "X + Y + 20/60" hours of wasted time).
So in your opinion scrap my real mode os and create a long mode or protected mode kernel?
Re: Computer with floppy
Posted: Wed Jun 10, 2015 4:59 pm
by Brendan
Hi,
feare56 wrote:Brendan wrote:
Of course for people writing a protected mode and/or long kernel it'd be potentially different (that "X hours" spent learning about real mode and BIOS is much more likely to be time wasted). It could also be argued that writing a real mode kernel is a complete waste of time (and that would imply the "X hours" learning about real mode and BIOS plus the ~20 minutes implementing boot loader plus the "Y hours" implementing the kernel all adds up to "X + Y + 20/60" hours of wasted time).
So in your opinion scrap my real mode os and create a long mode or protected mode kernel?
I'm not sure what your goals are, but in general it's almost always a better idea to use long mode and/or protected mode.
For example; if you assume it's going to take about 10 years to write a usable OS, then (for a real mode OS) you'd be releasing an OS in 2025 that's designed for the (severe) limitations of 40 year-old hardware.
Cheers,
Brendan