iso hard disk

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
kerravon
Member
Member
Posts: 278
Joined: Fri Nov 17, 2006 5:26 am

iso hard disk

Post by kerravon »

I am thinking of standardizing on an iso cd image, El torito hard disk, as my actual hard disk format.

Iso has 32k of reserved space at the beginning.

I would use the first 512 bytes of that to put a fake mbr.

The fake mbr would use a fake disk number like ff in dl so that the real mbr knows that this is an iso image and it should get the real disk number from dh and get an extra number of hidden sectors from say cx.

The vbr would have something similar.

Any suggestions?

I'm particularly interested in what Id I should use in the partition table of the fake mbr to indicate that this is an iso image, not a normal hard disk.
devc1
Member
Member
Posts: 439
Joined: Fri Feb 11, 2022 4:55 am
Location: behind the keyboard

Re: iso hard disk

Post by devc1 »

The MBR partition you are looking for is ISO-9660, I've never used it but I guess that it should point to the start of an ISO image. Which I do not suggest you to set it as sector 0 (or LBA0). The ID for that partition is 0x96. Here is a list of MBR partition ID's : https://en.m.wikipedia.org/wiki/Partition_type
Octocontrabass
Member
Member
Posts: 5563
Joined: Mon Mar 25, 2013 7:01 pm

Re: iso hard disk

Post by Octocontrabass »

kerravon wrote:I am thinking of standardizing on an iso cd image, El torito hard disk, as my actual hard disk format.
Why?
kerravon wrote:I'm particularly interested in what Id I should use in the partition table of the fake mbr to indicate that this is an iso image, not a normal hard disk.
Syslinux uses 0x17.
kerravon
Member
Member
Posts: 278
Joined: Fri Nov 17, 2006 5:26 am

Re: iso hard disk

Post by kerravon »

devc1 wrote:The MBR partition you are looking for is ISO-9660, I've never used it but I guess that it should point to the start of an ISO image. Which I do not suggest you to set it as sector 0 (or LBA0). The ID for that partition is 0x96. Here is a list of MBR partition ID's : https://en.m.wikipedia.org/wiki/Partition_type
Thanks for that. I did some searching and it looks to me like the start sector for the 0x96 partition should be lba 0.

Is there a reason you are suggesting not to do that?
kerravon
Member
Member
Posts: 278
Joined: Fri Nov 17, 2006 5:26 am

Re: iso hard disk

Post by kerravon »

Octocontrabass wrote:
kerravon wrote:I am thinking of standardizing on an iso cd image, El torito hard disk, as my actual hard disk format.
Why?
It seems neat to me. You can standardize on iso format and burn it to either cdrom or hard disk/USB stick.

With minimal software.
devc1
Member
Member
Posts: 439
Joined: Fri Feb 11, 2022 4:55 am
Location: behind the keyboard

Re: iso hard disk

Post by devc1 »

No, its fine. You can make it at LBA0, I just said that I don't recommend it because ISOs does not have an MBR and this will make another driver consider the partition as corrupt (because the ISO starts with an MBR), Or not ! now I get it, ISOs start with a 32KB system area, you can leave your MBR there, there is absolutely no problem. Is what I said right ? This is my little research.
devc1
Member
Member
Posts: 439
Joined: Fri Feb 11, 2022 4:55 am
Location: behind the keyboard

Re: iso hard disk

Post by devc1 »

Octocontrabass wrote:Syslinux uses 0x17.
Even that Linux uses this partition type. Universally : (The famous Wikipedia) says that this partition type is reserved for hidden file systems, and can be an EFS, NTFS...
Octocontrabass
Member
Member
Posts: 5563
Joined: Mon Mar 25, 2013 7:01 pm

Re: iso hard disk

Post by Octocontrabass »

kerravon wrote:I did some searching and it looks to me like the start sector for the 0x96 partition should be lba 0.

Is there a reason you are suggesting not to do that?
Some BIOSes will examine the partition table and misbehave or refuse to boot if a partition starts at LBA 0.
kerravon wrote:It seems neat to me. You can standardize on iso format and burn it to either cdrom or hard disk/USB stick.
It makes sense for removable media, but it sounds like you're suggesting the internal disk should be formatted this way too...
kerravon
Member
Member
Posts: 278
Joined: Fri Nov 17, 2006 5:26 am

Re: iso hard disk

Post by kerravon »

Octocontrabass wrote:
kerravon wrote:I did some searching and it looks to me like the start sector for the 0x96 partition should be lba 0.

Is there a reason you are suggesting not to do that?
Some BIOSes will examine the partition table and misbehave or refuse to boot if a partition starts at LBA 0.
That's pretty rude. For what reason does the bios need to have knowledge of the internal details of the MBR?

Isn't that the sole prerogative of the MBR code?
kerravon wrote:It seems neat to me. You can standardize on iso format and burn it to either cdrom or hard disk/USB stick.
It makes sense for removable media, but it sounds like you're suggesting the internal disk should be formatted this way too...
Yes, I am planning on standardizing on El torito everywhere.

Pdos would still recognize a traditional MBR, or indeed a traditional vbr-only, but if you want either of those on your hard disk you'll need to extract them yourself.

Also note that my hard disk image will be a vhd so that it can be extracted from the iso and mounted on windows.

Linux will directly manipulate the fat partition in an iso if you tell it the correct offset.
kerravon
Member
Member
Posts: 278
Joined: Fri Nov 17, 2006 5:26 am

Re: iso hard disk

Post by kerravon »

devc1 wrote:No, its fine. You can make it at LBA0, I just said that I don't recommend it because ISOs does not have an MBR and this will make another driver consider the partition as corrupt (because the ISO starts with an MBR), Or not ! now I get it, ISOs start with a 32KB system area, you can leave your MBR there, there is absolutely no problem. Is what I said right ? This is my little research.
That's certainly my understanding, which is why I tentatively decided to go this route.

To date I've only ever produced isos with 32kb NULs so I have no other feedback on real hardware.
Octocontrabass
Member
Member
Posts: 5563
Joined: Mon Mar 25, 2013 7:01 pm

Re: iso hard disk

Post by Octocontrabass »

kerravon wrote:That's pretty rude. For what reason does the bios need to have knowledge of the internal details of the MBR?

Isn't that the sole prerogative of the MBR code?
The BIOS examines the MBR on a USB flash drive to decide whether the drive is bootable, whether INT 0x13 should treat it like a floppy disk or a hard disk, and what the INT 0x13 CHS geometry should be. This is done both to prevent booting from a drive that isn't bootable and to ensure compatibility with software that was written before USB existed.

UEFI needs to examine the partition tables to load a file from a partition. In theory, UEFI should prefer El Torito over MBR regardless of media, but who knows how well vendors follow that part of the specification...
kerravon wrote:Yes, I am planning on standardizing on El torito everywhere.
That seems like a bad idea. The UEFI specification says this should be fine, but I expect you will have problems with real hardware since firmware authors only bother to test Windows.
kerravon wrote:Also note that my hard disk image will be a vhd so that it can be extracted from the iso and mounted on windows.
What happens when you write a small ISO to a big flash drive? Is the rest of the space unusable?
kerravon
Member
Member
Posts: 278
Joined: Fri Nov 17, 2006 5:26 am

Re: iso hard disk

Post by kerravon »

Octocontrabass wrote:
kerravon wrote:That's pretty rude. For what reason does the bios need to have knowledge of the internal details of the MBR?

Isn't that the sole prerogative of the MBR code?
The BIOS examines the MBR on a USB flash drive to decide whether the drive is bootable, whether INT 0x13 should treat it like a floppy disk or a hard disk, and what the INT 0x13 CHS geometry should be. This is done both to prevent booting from a drive that isn't bootable and to ensure compatibility with software that was written before USB existed.
Oh, I wasn't aware I could put a floppy image on a USB stick. That's great. I'll give it a try.

UEFI needs to examine the partition tables to load a file from a partition. In theory, UEFI should prefer El Torito over MBR regardless of media, but who knows how well vendors follow that part of the specification...
Oh, I wasn't expecting El torito, I was expecting my mbr code to be executed. Basically I am designing for a 1995 bios with advance knowledge of El torito.

If the bios detects El torito and bypasses my fake mbr, will it actually give me a writable hard disk or will it make it read only like a normal cd?
kerravon wrote:Yes, I am planning on standardizing on El torito everywhere.
That seems like a bad idea. The UEFI specification says this should be fine, but I expect you will have problems with real hardware since firmware authors only bother to test Windows.
I don't really care if pdos doesn't work on buggy bioses. So long as it is clearly the bios that is violating protocol, someone can report the bug to the vendor.

If the vendor doesn't care, then select a different vendor when buying a pc.
kerravon wrote:Also note that my hard disk image will be a vhd so that it can be extracted from the iso and mounted on windows.
What happens when you write a small ISO to a big flash drive? Is the rest of the space unusable?
My fdisk program only handles a single partition currently, and the pdos mods haven't even started yet, but there is no reason why additional partitions can't be added after the event by fdisk.

fdisk will need to have knowledge of the additional vhd sectors plus the 2048-512 padding after the vhd.
Octocontrabass
Member
Member
Posts: 5563
Joined: Mon Mar 25, 2013 7:01 pm

Re: iso hard disk

Post by Octocontrabass »

kerravon wrote:Oh, I wasn't aware I could put a floppy image on a USB stick. That's great. I'll give it a try.
Unfortunately, some BIOSes (maybe only UEFI CSMs?) will not boot a USB drive that hasn't been partitioned.
kerravon wrote:Oh, I wasn't expecting El torito, I was expecting my mbr code to be executed.
UEFI doesn't execute any legacy code. BIOS and UEFI CSM execute legacy code.
kerravon wrote:If the bios detects El torito and bypasses my fake mbr, will it actually give me a writable hard disk or will it make it read only like a normal cd?
I couldn't tell you - I only use BIOS for booting, and booting doesn't involve writing any disks.
kerravon wrote:I don't really care if pdos doesn't work on buggy bioses. So long as it is clearly the bios that is violating protocol, someone can report the bug to the vendor.

If the vendor doesn't care, then select a different vendor when buying a pc.
So, if I can't choose a different PC, I can't use your OS?
Kevin
Member
Member
Posts: 1071
Joined: Sun Feb 01, 2009 6:11 am
Location: Germany
Contact:

Re: iso hard disk

Post by Kevin »

kerravon wrote:It seems neat to me. You can standardize on iso format and burn it to either cdrom or hard disk/USB stick.
Are you sure that you will never want to write data to the hard disk after creating the image?
Developer of tyndur - community OS of Lowlevel (German)
kerravon
Member
Member
Posts: 278
Joined: Fri Nov 17, 2006 5:26 am

Re: iso hard disk

Post by kerravon »

Octocontrabass wrote:
kerravon wrote:I don't really care if pdos doesn't work on buggy bioses. So long as it is clearly the bios that is violating protocol, someone can report the bug to the vendor.

If the vendor doesn't care, then select a different vendor when buying a pc.
So, if I can't choose a different PC, I can't use your OS?
You could still run pdos if you extract the vhd, or even just the img, from the iso, and burn that to hard disk.

I would be happy to document that, but I just want to ship a single iso.
Post Reply