OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 3:34 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 28 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: iso hard disk
PostPosted: Wed Sep 21, 2022 3:19 pm 
Offline
Member
Member

Joined: Fri Nov 17, 2006 5:26 am
Posts: 232
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.


Top
 Profile  
 
 Post subject: Re: iso hard disk
PostPosted: Wed Sep 21, 2022 3:50 pm 
Offline
Member
Member

Joined: Fri Feb 11, 2022 4:55 am
Posts: 435
Location: behind the keyboard
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


Top
 Profile  
 
 Post subject: Re: iso hard disk
PostPosted: Wed Sep 21, 2022 4:14 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5099
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.


Top
 Profile  
 
 Post subject: Re: iso hard disk
PostPosted: Wed Sep 21, 2022 4:59 pm 
Offline
Member
Member

Joined: Fri Nov 17, 2006 5:26 am
Posts: 232
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?


Top
 Profile  
 
 Post subject: Re: iso hard disk
PostPosted: Wed Sep 21, 2022 5:02 pm 
Offline
Member
Member

Joined: Fri Nov 17, 2006 5:26 am
Posts: 232
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.


Top
 Profile  
 
 Post subject: Re: iso hard disk
PostPosted: Wed Sep 21, 2022 5:48 pm 
Offline
Member
Member

Joined: Fri Feb 11, 2022 4:55 am
Posts: 435
Location: behind the keyboard
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.


Top
 Profile  
 
 Post subject: Re: iso hard disk
PostPosted: Wed Sep 21, 2022 5:51 pm 
Offline
Member
Member

Joined: Fri Feb 11, 2022 4:55 am
Posts: 435
Location: behind the keyboard
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...


Top
 Profile  
 
 Post subject: Re: iso hard disk
PostPosted: Wed Sep 21, 2022 6:13 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5099
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...


Top
 Profile  
 
 Post subject: Re: iso hard disk
PostPosted: Wed Sep 21, 2022 7:01 pm 
Offline
Member
Member

Joined: Fri Nov 17, 2006 5:26 am
Posts: 232
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?

Quote:
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.


Top
 Profile  
 
 Post subject: Re: iso hard disk
PostPosted: Wed Sep 21, 2022 7:04 pm 
Offline
Member
Member

Joined: Fri Nov 17, 2006 5:26 am
Posts: 232
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.


Top
 Profile  
 
 Post subject: Re: iso hard disk
PostPosted: Wed Sep 21, 2022 7:24 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5099
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?


Top
 Profile  
 
 Post subject: Re: iso hard disk
PostPosted: Thu Sep 22, 2022 4:23 am 
Offline
Member
Member

Joined: Fri Nov 17, 2006 5:26 am
Posts: 232
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.

Quote:

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?

Quote:

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.

Quote:
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.


Top
 Profile  
 
 Post subject: Re: iso hard disk
PostPosted: Thu Sep 22, 2022 10:25 am 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5099
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?


Top
 Profile  
 
 Post subject: Re: iso hard disk
PostPosted: Thu Sep 22, 2022 10:47 am 
Offline
Member
Member

Joined: Sun Feb 01, 2009 6:11 am
Posts: 1070
Location: Germany
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)


Top
 Profile  
 
 Post subject: Re: iso hard disk
PostPosted: Thu Sep 22, 2022 4:43 pm 
Offline
Member
Member

Joined: Fri Nov 17, 2006 5:26 am
Posts: 232
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 28 posts ]  Go to page 1, 2  Next

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], Google [Bot], SemrushBot [Bot] and 64 guests


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 post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group