Copying kernel to a floppy without a filesystem?
- ThisMayWork
- Member
- Posts: 65
- Joined: Sat Mar 22, 2014 1:14 pm
- Location: /bin
Copying kernel to a floppy without a filesystem?
I have created a floppy image using dd which has my bootloader on the first sector. Now I need to copy my kernel to the next one but I cannot mount it on OSX (it complains about not recognising the filesystem). Is there any other way to copy it? Thanks in advance!
"Programming is an art form that fights back."
-Kudzu
-Kudzu
Re: Copying kernel to a floppy without a filesystem?
Can't you copy it to the second sector (or whatever sector your bootloader expects it to be at)?ThisMayWork wrote:I have created a floppy image using dd which has my bootloader on the first sector. Now I need to copy my kernel to the next one but I cannot mount it on OSX (it complains about not recognising the filesystem). Is there any other way to copy it? Thanks in advance!
If you were on linux and your bootloader binary was called "mbr" and the kernel binary was called "system" and the bootloader wanted the kernel at sector number 2, then you would do the following:
Code: Select all
dd if=mbr of=/dev/sdb seek=0 conv=sync
dd if=system of=/dev/sdb seek=1 conv=sync
Every universe of discourse has its logical structure --- S. K. Langer.
- ThisMayWork
- Member
- Posts: 65
- Joined: Sat Mar 22, 2014 1:14 pm
- Location: /bin
Re: Copying kernel to a floppy without a filesystem?
I thought of that but my kernel is not 512B in size (the size of the sector). Will this work as expected?
"Programming is an art form that fights back."
-Kudzu
-Kudzu
Re: Copying kernel to a floppy without a filesystem?
It'll copy however many sectors it needs to.
Here is a tiny kernel which has a build system that installs the system onto a harddisk just like you want to on a floppy. Check out the "build.x86" directory and look at the "Makefile", especially the target "harddisk". Look at the last section of the README file in the top level directory for a wee bit more info on how the disk is prepared.
EDIT: Make sure the conv=sync option is given (linux) or conv=osync (BSD) - I don't know what it is on OSX. If you don't have this set you can get problems with your last sector.
Here is a tiny kernel which has a build system that installs the system onto a harddisk just like you want to on a floppy. Check out the "build.x86" directory and look at the "Makefile", especially the target "harddisk". Look at the last section of the README file in the top level directory for a wee bit more info on how the disk is prepared.
EDIT: Make sure the conv=sync option is given (linux) or conv=osync (BSD) - I don't know what it is on OSX. If you don't have this set you can get problems with your last sector.
Every universe of discourse has its logical structure --- S. K. Langer.
- ThisMayWork
- Member
- Posts: 65
- Joined: Sat Mar 22, 2014 1:14 pm
- Location: /bin
Re: Copying kernel to a floppy without a filesystem?
This is actually very helpful! However, objcopy is not available for OSX and there doesn't seem to be any decent alternative. Will there be any difference if I just link it as .bin instead of .elf? ELF is flat, right?
"Programming is an art form that fights back."
-Kudzu
-Kudzu
Re: Copying kernel to a floppy without a filesystem?
PM me with your email address and I'll send you the source code for a wee tool which will flatten an ELF so you can just copy it with dd.
Every universe of discourse has its logical structure --- S. K. Langer.
Re: Copying kernel to a floppy without a filesystem?
That's a rather large sig!ThisMayWork wrote:...
Re: Copying kernel to a floppy without a filesystem?
Hi,
Cheers,
Brendan
Neither of these function actually do anything; so your question (whether they work as expected) doesn't really make any sense.ThisMayWork wrote:I thought of that but my kernel is not 512B in size (the size of the sector). Will this work as expected?
NOTCode: Select all
void foo() { }
Code: Select all
void foo() { }
Cheers,
Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
-
- Member
- Posts: 510
- Joined: Wed Mar 09, 2011 3:55 am
Re: Copying kernel to a floppy without a filesystem?
That's his sig, not code that he's asking about.Brendan wrote: Neither of these function actually do anything; so your question (whether they work as expected) doesn't really make any sense.
Cheers,
Brendan
Re: Copying kernel to a floppy without a filesystem?
Hi,
Cheers,
Brendan
I never would've noticed - perhaps his signature should be larger so it stands out more, and his post/s smaller to avoid distracting people...linguofreak wrote:That's his sig, not code that he's asking about.Brendan wrote: Neither of these function actually do anything; so your question (whether they work as expected) doesn't really make any sense.
Cheers,
Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
- ThisMayWork
- Member
- Posts: 65
- Joined: Sat Mar 22, 2014 1:14 pm
- Location: /bin
Kernel compiled, everything linked. Floppy?!
Hello! I am fairly new to OS development and I have successfully managed to compile my *tiny* kernel, assemble my *tiny* bootloader and link everything together in one file called os-image. Now how do I create a floppy and copy that image to it so Virtual PC will boot it? I am running OSX...
EDIT: I managed to create a floppy image using hdiutil, Apple's image tool. However, it contains no file system (that is exactly what I want, as my bootloader using no file system, only jumps to the correct sector and loads the whole floppy after that to memory). However, since it has no filesystem, OSX refuse to mount it so I have no way of copying my os-image to it.
EDIT: I managed to create a floppy image using hdiutil, Apple's image tool. However, it contains no file system (that is exactly what I want, as my bootloader using no file system, only jumps to the correct sector and loads the whole floppy after that to memory). However, since it has no filesystem, OSX refuse to mount it so I have no way of copying my os-image to it.
"Programming is an art form that fights back."
-Kudzu
-Kudzu
Re: Copying kernel to a floppy without a filesystem?
ThisMayWork: I took the liberty of merging your new topic into the old topic as they seem to be a continuation of each other.
- Bender
- Member
- Posts: 449
- Joined: Wed Aug 21, 2013 3:53 am
- Libera.chat IRC: bender|
- Location: Asia, Singapore
Re: Copying kernel to a floppy without a filesystem?
You can use HxD to copy the sectors, and regardless if it's a floppy with a filesystem, QEMU (or any other sane emulator) should be able to boot it.
I highly recommend to use a well-known filesystem (extN/FATXX etc.) because your kernel will soon turn big enough.
I highly recommend to use a well-known filesystem (extN/FATXX etc.) because your kernel will soon turn big enough.
"In a time of universal deceit - telling the truth is a revolutionary act." -- George Orwell
(R3X Runtime VM)(CHIP8 Interpreter OS)
(R3X Runtime VM)(CHIP8 Interpreter OS)
- max
- Member
- Posts: 616
- Joined: Mon Mar 05, 2012 11:23 am
- Libera.chat IRC: maxdev
- Location: Germany
- Contact:
Re: Copying kernel to a floppy without a filesystem?
Re: Copying kernel to a floppy without a filesystem?
Build a cross compiler, the toolchain comes with objcopy. This is (still?) the recommended option in this forum.
Search the wiki for detail.