Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

writing bootstrap code to USB MBR

365 views
Skip to first unread message

santoshsy

unread,
Oct 21, 2008, 7:25:29 AM10/21/08
to
Hi,

I'm trying to write a small OS (just for fun and for better
understanding), I have written a bootstrap code and a small kernel and
tested writing it to floppy and booting from the floppy, it works
fine.
But how to write the bootstrap to USB boot sector and boot from the
USB. Can some one please help me with this information.


Thanks,
Santosh

Rod Pemberton

unread,
Oct 22, 2008, 1:28:40 AM10/22/08
to
"santoshsy" <sant...@gmail.com> wrote in message
news:0d778d0a-90e4-4002...@r15g2000prh.googlegroups.com...

I use John Fine's partcopy for DOS. As long as DOS or the Windows dosbox
recognizes the USB device as a drive, his utility should be useable. On my
old PC, Win98SE recognizes the USB as a drive and I can use partcopy from
Windows dosbox. The old PC won't boot a USB device, but my new PC will boot
one created from the old PC. On my new PC, the BIOS recognizes the USB and
presents it as a drive to DOS. The new PC will also boot larger USB devices
that have DOS partitions even if the partition isn't set as active by
fdisk - as long as the USB device is first in the boot order.

One of a few Chris Giese mirrors with John Fine's old pages:
http://geezer.osdevbrasil.net/johnfine/index.htm


Rod Pemberton

santoshsy

unread,
Oct 24, 2008, 12:06:51 AM10/24/08
to
On Oct 22, 10:28 am, "Rod Pemberton" <do_not_h...@nohavenot.cmm>
wrote:
> "santoshsy" <santos...@gmail.com> wrote in message


I'm using WinXP, it recognizes USB as a removable drive (say N). My PC
BIOS also has an option to BOOT from a USB.
I tried using partcopy.exe to write bootstrap code to USB boot sector
using the command
"partcopy.exe boot.bin 0 200 -aN" (where N is a USB drive) but it
throws me an error "application is trying to write to partition
directly, which is not supported". So is there any solution or I'm
doing it wrong.

Thanks,
Santoshsy

Rod Pemberton

unread,
Oct 24, 2008, 7:45:52 AM10/24/08
to
"santoshsy" <sant...@gmail.com> wrote in message
news:f411a4c3-39ce-4ff8...@b2g2000prf.googlegroups.com...

> I'm using WinXP, it recognizes USB as a removable drive (say N). My PC
> BIOS also has an option to BOOT from a USB.
> I tried using partcopy.exe to write bootstrap code to USB boot sector
> using the command
> "partcopy.exe boot.bin 0 200 -aN" (where N is a USB drive) but it
> throws me an error "application is trying to write to partition
> directly, which is not supported". So is there any solution or I'm
> doing it wrong.

You could see if XP's dosbox has the DOS LOCK and UNLOCK commands. If so,
they'll lock and unlock the drive blocking other access, allowing the dosbox
to do direct writes.

LOCK N:
partcopy
UNLOCK N:

I haven't used -aN... I usually use -fX for floppy, or -hX for hard drive
and USB. E.g.,

partcopy boot.bin 0 200 -h1

You'll notice you need the "drive number," 1 in the example, not the drive
letter which corresponds to a partition. When I'm unsure, I _read_ from the
device first, becauase I don't want to mess up the boot on my good drives.
For USB, you should be able to watch the USB's led. It should blink or turn
on/off. E.g., if you think your USB is the second "hard disk," i.e., h1,
you'd read:

partcopy -h1 0 200 junk.bin

If it blinks, that's it. I think, but am not 100% sure, that the physical
HD's are ordered sequentially from zero followed by the USB devices. E.g.,
if I've got C:, D:, E:, F:, where F: is the USB, E: is a partition
consuming the second HD, C: and D: are partitions on the first HD, then I
think F: is -h2, E: is -h1, C: and D: are -h0.

Once you're sure you've got the correct drive number, you'd write:

partcopy boot.bin 0 200 -h1

Perhaps, locking the first (example using F: and h1...):

LOCK F:
partcopy boot.bin 0 200 -h1
UNLOCK F:


Rod Pemberton

Zaphod Beeblebrox

unread,
Oct 24, 2008, 8:09:24 AM10/24/08
to

"santoshsy" <sant...@gmail.com> wrote in message
news:0d778d0a-90e4-4002...@r15g2000prh.googlegroups.com...

I've had success using the HP USB Format utility (google for HP
SP27213.exe). I couldn't find it on HP's web site, but it still appears
to be available from other places.

Hope this helps!

--
Zaphod

No matter where you go, there you are!


Robert Riebisch

unread,
Oct 24, 2008, 8:53:16 AM10/24/08
to
Zaphod Beeblebrox wrote:

> I've had success using the HP USB Format utility (google for HP
> SP27213.exe). I couldn't find it on HP's web site, but it still appears
> to be available from other places.

AFAIK SP27213.exe has been superseeded by SP27608.exe. see
http://h50178.www5.hp.com/support/PB137UA/more_info_local_17550.html

Robert Riebisch

0 new messages