Back to home page

DOS ain't dead

Forum index page

Log in | Register

Back to the board
Thread view  Mix view  Order
nico7550

27.02.2021, 19:44
 

Floppy boot sector injection/conversion to HD (Miscellaneous)

Hi,

I would like to know 2 related things if you know ?

1.
Is there a way to inject a boot sector on a HD without using sys.com or similar tools, I'm looking for something "universal" that can handle BIN boot sector file.
Here is the tools I use to do it on a floppy, each file inject a specific boot sector (found on a russian DOS compilation... more bootsector added by myself using an hex editor) but from my test when I boot on a floppy disk, it only inject on the floppy.

https://uptobox.com/orxf6qgwiqzw

2.
Is there a way to convert a floppy boot sector to work with a HD ?

Thanks

ecm

Homepage E-mail

Düsseldorf, Germany,
27.02.2021, 21:27

@ nico7550

Floppy boot sector injection/conversion to HD

> Hi,
>
> I would like to know 2 related things if you know ?
>
> 1.
> Is there a way to inject a boot sector on a HD without using sys.com or
> similar tools, I'm looking for something "universal" that can handle BIN
> boot sector file.
> Here is the tools I use to do it on a floppy, each file inject a specific
> boot sector (found on a russian DOS compilation... more bootsector added by
> myself using an hex editor) but from my test when I boot on a floppy disk,
> it only inject on the floppy.
>
> https://uptobox.com/orxf6qgwiqzw

May not fit your requirements entirely, but there is my instsect tool. You can get a current pre-built one from the lDebug releases, in the bin/ subdirectory of the zipfile/tarball. There's the help on how to use it. For your use case you can use the /S=filename switch (load 512-byte sector loader from a file) as well as /IN (on FAT32 don't write to FSINFO) and if you need it /SN (don't check jump and informational FS ID valid).

However, this tool always preserves the EBPB or BPB, including new BPB fields (volume label, serial number, and FS ID). This may be unlike what you want, it is not entirely clear. Though, modifying it to replace the BPBs too would not be much work. (And it is free software.)

> 2.
> Is there a way to convert a floppy boot sector to work with a HD ?

Not generally. Some loaders (such as Microsoft's) work for both FAT12 and FAT16, regardless of whether that FS is on a diskette or hard disk. Others work only for either FAT12 or FAT16, not both. FAT32 loaders generally work only with FAT32.

---
l

mceric

Germany,
27.02.2021, 23:07

@ nico7550

Floppy boot sector injection/conversion to HD

As far as I remember, some of the versions of SYS for FreeDOS are quite flexible as tools for what you are trying to do, so you may want to have a look at the documentation and command line help of those :-)

---
FreeDOS / DOSEMU2 / ...

nico7550

27.02.2021, 23:24

@ mceric

Floppy boot sector injection/conversion to HD

Thanks guys, I got the infos, and I will test booth tools.

For the boot sector of the HD, from what I see on some page, there is infos about the number of sectors, clusters size, etc..., so the boot sector of one HD will not be injectable in another. You confirm this ?

mceric

Germany,
28.02.2021, 01:48

@ nico7550

Floppy boot sector injection/conversion to HD

> For the boot sector of the HD, from what I see on some page, there is infos
> about the number of sectors, clusters size, etc..., so the boot sector of
> one HD will not be injectable in another. You confirm this ?

For FAT filesystems, boot sectors contain that type of information, yes. Well-written boot sectors base their file system processing only on documented fields, so a SYS style tool can combine filesystem properties for the current drive with generic code provided for the OS and the combination will boot.

Situations where this will most likely not work are when the boot sector is for FAT12, FAT16 or FAT32 and the filesystem is not the same FAT variant as the boot sector expects. Some boot sectors can only do CHS, or only LBA, others automatically switch. FAT32 boot sectors are often more than one sector long, so your SYS tool will have to install more than one sector.

Also, when the boot sector contains additional data such as "cluster number of some boot file" instead of actually looking into the directory data, it will of course only work if they are used with some special installer which stores the extra data in the boot sector. In the other direction, some boot sectors use information passed from the partition table, which can even let them compensate gaps in filesystem property data stored in the boot sector itself, for example regarding the absolute position of the partition on disk, the filesystem type, whether or not to use LBA or CHS etc.

So your success can easily depend on some very specific properties of the boot sector you want to install. Putting a floppy (FAT12) boot sector on a harddisk partition will often NOT work, unless you make a small FAT12 boot partition near the start of the disk to stay in FAT12 context and to stay in CHS geometry with small C, H and S numbers.

Some smart FAT12 boot sectors may be a bit more universal and automatically switch to LBA when available. If you are very lucky, you could even have a combined FAT12 and FAT16 boot sector. But it is extremely unlikely that a floppy boot sector will recognize and support being used for a FAT32 partition.

You might be able to use some FreeDOS boot sectors together with one of the more flexible SYS versions to say you want the boot sector to load a file from the root directory with any name of your choice, to any address segment of your choice. Depending on whether your operating system needs anything more than that, this lets you use FreeDOS boot infrastructure to load and boot kernels of other DOS brands by giving the right parameters on the SYS command line. Could be useful for DR DOS, EDR DOS, MS DOS, PC DOS etc. multiboot "switching" by updating your boot sector and restarting the computer. Not sure how experimental this was and which SYS versions have it.

---
FreeDOS / DOSEMU2 / ...

ecm

Homepage E-mail

Düsseldorf, Germany,
28.02.2021, 08:57

@ mceric

Floppy boot sector injection/conversion to HD

> You might be able to use some FreeDOS boot sectors together with one of the
> more flexible SYS versions to say you want the boot sector to load a file
> from the root directory with any name of your choice, to any address
> segment of your choice. Depending on whether your operating system needs
> anything more than that, this lets you use FreeDOS boot infrastructure to
> load and boot kernels of other DOS brands by giving the right parameters on
> the SYS command line. Could be useful for DR DOS, EDR DOS, MS DOS, PC DOS
> etc. multiboot "switching" by updating your boot sector and restarting the
> computer. Not sure how experimental this was and which SYS versions have
> it.

This only works if the file in question allows loading as a FreeDOS load protocol kernel. This is only true of FreeDOS's own kernel.sys (expects to be loaded at 60h:0 and probably doesn't support other addresses), later EDR-DOS's drbio.sys (at 70h:0), and my later RxDOS.COM and ldebug.com files (require loading at 60h:0 because that is how they detect they're entered in the FreeDOS load protocol). The ss:bp far pointer points to the boot sector with BPB in memory, typically at 1FE0h:7C00h, and the entire file is loaded to the specified address. The bl register contains the ROM-BIOS unit to load from.

MS-DOS (up to version 6.xx) and PC-DOS (including up to version 7.10) follow a different protocol: the boot sector is located at 0:7C00h and the first three sectors (more accurately, 1.5 KiB) are loaded to 70h:0, and some registers are set up, including dl with the unit to load from. The directory entries for the BIO and DOS file are located at 0:500h and 0:520h.

MS-DOS 7 and 8 have their own protocol: the boot sector is again usually at 0:7C00h and also pointed to by ss:bp. Four sectors (more accurately 2 KiB) of the file are loaded to 70h:0 and entered at 70h:200h. si:di or only di contain the first cluster of the load file. The dword below the boot sector copy in memory contains the number of the first data cluster's sector, absolute within the boot unit (including hidden sectors).

A way of multibooting that works with a range of loaders and not just FreeDOS-compatible ones is to use my debugger's BOOT command while in bootloaded mode. The included instsect.com installs a loader (lDOS protocol) which allows loading the debugger. The debugger can in turn load any kernel in a variety of formats. Then if the load succeeded simply run q or g and the kernel is executed.

---
l

nico7550

28.02.2021, 10:35

@ ecm

Floppy boot sector injection/conversion to HD

Thanks for the details, will try to figure out something with my low level of DOS user.

Seems the easiest way is to have each "sys.com" for each operating systems to ensure the boot sector will be "compose" as it need to be.

Have a nice day and keep safe

mceric

Germany,
28.02.2021, 16:09

@ ecm

Floppy boot sector injection/conversion to HD

From Jeremy, via the FreeDOS mailing lists:

"It supports most ms/pc/dr DOS kernels

Any issues found should be reported and I will look into them. The only
issue I recall is it doesn't move files, so needs to be ran on freshly
formatted disk for early kernels. The boot sector is not universal, it is
customized when sys is ran. I used it to switch kernels for testing."

So apparently both FreeDOS/EDR and MS/PC DOS style are possible with
the flexible FreeDOS SYS and boot sector variants used by Jeremy :-)

---
FreeDOS / DOSEMU2 / ...

ecm

Homepage E-mail

Düsseldorf, Germany,
28.02.2021, 18:26

@ mceric

Floppy boot sector injection/conversion to HD

> From Jeremy, via the FreeDOS mailing lists:
>
> "It supports most ms/pc/dr DOS kernels
>
> Any issues found should be reported and I will look into them. The only
> issue I recall is it doesn't move files, so needs to be ran on freshly
> formatted disk for early kernels. The boot sector is not universal, it is
> customized when sys is ran. I used it to switch kernels for testing."
>
> So apparently both FreeDOS/EDR and MS/PC DOS style are possible with
> the flexible FreeDOS SYS and boot sector variants used by Jeremy :-)

I was replying specifically to this part:

> You might be able to use some FreeDOS boot sectors together with
> one of the more flexible SYS versions to say you want the boot
> sector to load a file from the root directory with any name of
> your choice, to any address segment of your choice.

The other kernels require an OEM switch for the recent FreeDOS SYS I believe. It is not a matter of just setting the name and segment as the quoted part may have seemed to imply.

---
l

RayeR

Homepage

CZ,
01.03.2021, 14:52

@ nico7550

Floppy boot sector injection/conversion to HD

> Seems the easiest way is to have each "sys.com" for each operating systems
> to ensure the boot sector will be "compose" as it need to be.

Yes, I use this way too. I use sys to write bootsector with proper data field and back up it in a file associated for each DOS. Then do sys for another DOS and so on. Then I can use e.g. NTLDR to load bootsectors from saved files via menu entries to load specific DOS.

---
DOS gives me freedom to unlimited HW access.

Back to the board
Thread view  Mix view  Order
22049 Postings in 2034 Threads, 396 registered users, 138 users online (0 registered, 138 guests)
DOS ain't dead | Admin contact
RSS Feed
powered by my little forum