flat assembler
Message board for the users of flat assembler.

Index > OS Construction > Load OS from usb drive?

Author
Thread Post new topic Reply to topic
rhyno_dagreat



Joined: 31 Jul 2006
Posts: 487
Location: Maryland, Unol Daleithiau
rhyno_dagreat
I have a USB flash drive, and I'd like to put a homemade OS on it. How could I make it bootable/store data in the first sector and everything?

Thanks!
Post 02 Feb 2010, 16:09
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4242
Location: 2018
edfed
under win98, just use int13h as for Hard drives.
but there i a little problem, the CHS from windows98 and the one from BIOS is not alwas the same on USB pens.

on my PC, the chs difference starts at 18__kb approximatelly. then, i cannot play with files over 18_kB (for the moment), maybe LBA addressing can solve it easy.
Post 02 Feb 2010, 16:53
View user's profile Send private message Visit poster's website Reply with quote
smiddy



Joined: 31 Oct 2004
Posts: 559
smiddy
Can you provide information on the system that you intend to use to create the boot disk? That will help in defining your needs a little better.

I am about to start down this journey myself, BTW. I intend to use WinImage to create the image, and use Bochs to insure the MBR, and VBR are setup correctly, then I am going to start using it as my platform tester.

I think the most generic sense is treat the USB drive as any other HDD, making certain your BIOS supports booting from it, and direct accessing it, without a USB driver, per se.
Post 02 Feb 2010, 19:14
View user's profile Send private message Reply with quote
zhak



Joined: 12 Apr 2005
Posts: 490
Location: Belarus
zhak
i did some trick that is fine for me. all my project (source, tools, etc.) is on a usb memory stick. i compile a HDD image each time i compile my OS source code. when i need to run it under bochs, i just boot from that image. i've also installed grub on my usb memory stick and configured it to boot from the HDD image. so i can boot my OS on a physical PC. sometimes i run it under VMWare, and i just configure it to use the whole disk as hdd and choose my usb stick. so, using grub i can load my OS on any environment. it's pretty convenient
Post 02 Feb 2010, 19:40
View user's profile Send private message Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
Dex4u
I writen a fasm win32 program to add boot sector to usb drive for both floppy and hdd emulation.
I can post the code, if i can find.

You can try the program here: http://www.dex4u.com/USBboot.htm
Post 02 Feb 2010, 22:09
View user's profile Send private message Reply with quote
smiddy



Joined: 31 Oct 2004
Posts: 559
smiddy
Thanks Dex! A quick look-see it appears to be 16 bit FAT, yes? Have you done anything with 32 bit FAT?
Post 03 Feb 2010, 18:21
View user's profile Send private message Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
Dex4u
It was just a safety thing, i thought that if you had to format the drive fat16 first, i could test for that, as well as that its a usb drive.

I did not want to nuke there usb external hard drive, if they press yes to the wrong drive letter.
So you can just mod the code to write to fat32 too or even fat64.
It would be a case of moding the one line of code.

I will PM you a link to the code and remember i program in windows very little.

[EDIT] I have PM you.
Post 04 Feb 2010, 10:58
View user's profile Send private message Reply with quote
booter



Joined: 08 Dec 2006
Posts: 67
booter
rhyno_dagreat wrote:
I have a USB flash drive, and I'd like to put a homemade OS on it. How could I make it bootable/store data in the first sector and everything?

Thanks!
Just write your custom MBR which would load your OS into memory and pass control to it.
Use Int 13 function 42h to read your OS by absolute LBA address to make it BIOS independent. In fact, you should update MBR with the new LBA address each time you write your OS to the USB, or better do it once and then update the OS image file without moving it.
Post 04 Feb 2010, 18:28
View user's profile Send private message Reply with quote
smiddy



Joined: 31 Oct 2004
Posts: 559
smiddy
Thanks Dex...

I saw that there was some 64 bit FAT verbiage on the net, but I haven't looked at it with any critical eyes yet. I did see it wasn't supported by Microsoft, but then again, that is no big deal either. I was hoping to save me some coding time. I am refreshing my memory on FAT entirely and will be coding my own versions eventually. I'm nearly done setting up my test environment, this code will help in that vain. Smile

-smiddy
Post 04 Feb 2010, 19:29
View user's profile Send private message Reply with quote
rhyno_dagreat



Joined: 31 Jul 2006
Posts: 487
Location: Maryland, Unol Daleithiau
rhyno_dagreat
Sorry for the late reply - I'm using a msi E7235 laptop with a Intel Core 2 Duo 2.0GHz processor in it.

Can I just use WinImage to write the binary file to the USB directly as if I were to do it to a floppy disk, or because it's different hardware I need to do something entirely?
Post 07 Feb 2010, 16:19
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.