OSDev.org

The Place to Start for Operating System Developers
It is currently Tue Jan 16, 2018 9:28 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 21 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: Re: FAT 32 MBR Creation
PostPosted: Thu Nov 30, 2017 5:08 pm 
Offline
Member
Member
User avatar

Joined: Fri Oct 27, 2006 9:42 am
Posts: 1056
Location: Athens, GA, USA
Octacone wrote:
@Schol-R-LEA looks like you know a lot about old computers. It is always nice to learn some history along the way.


Thanks, although I should have done more fact-checking: my recollection to the contrary, the original IBM PC could have two full-height floppy drives. However, I am pretty sure that I was correct about it never booting from drive B:, though I am open to corrections.

Also, I once again forgot to specify which university abbreviated as 'SCSU' I was talking about; I meant Southern Connecticut State University, the CT State schools being the junior state university system to University of Connecticut's senior in the same way California State is to University of California.

_________________
Rev. First Speaker Schol-R-LEA;2 LCF ELF JAM POEE KoR KCO PPWMTF
μή εἶναι βασιλικήν ἀτραπόν ἐπί γεωμετρίαν
Lisp programmers tend to seem very odd to outsiders, just like anyone else who has had a religious experience they can't quite explain to others.


Top
 Profile  
 
 Post subject: Re: FAT 32 MBR Creation
PostPosted: Fri Dec 01, 2017 11:07 am 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 1214
Octacone wrote:
Mkdosfs doesn’t seem to care about fdisk partitioned virtual HDDs??

Utilities like mkdosfs expect to operate on a partition device when the disk is partitioned. You're telling mkdosfs to work directly with your entire disk image, which it isn't really prepared to handle.

Since you're using Linux, it's pretty easy to mount your disk image as separate partition devices. You can then use mkdosfs to format the individual partition devices, just like you would partitions on a physical disk.


Top
 Profile  
 
 Post subject: Re: FAT 32 MBR Creation
PostPosted: Sat Dec 02, 2017 8:00 am 
Offline
Member
Member

Joined: Fri Aug 07, 2015 6:13 am
Posts: 898
@Octocontrabass
Okay so I started over. Created an empty HDD image with 2 partitions, 5 GB each, mounted EACH of them as a loopback device. Checked everything with a hex editor, everything seems to be okay. Now I have a problem, since both fdisk and this page Loopback_Device are outdated I cannot create a FAT 32 filesystem on them. Why, you ask? Because I don't know how many #blocks are there.
This line:
Code:
mkdosfs -F32 /dev/loop0 #blocks

There is no way for me to figure that out and Wiki says I should. Any ideas on what that could be and how could I get that number? Google says one block = 1024 bytes but that doesn't make me know the value.

Edit: I figured out the formula:
Code:
block_count = ((last_sector - first_sector) * 512) / 1024

_________________
OS: Basic OS


Top
 Profile  
 
 Post subject: Re: FAT 32 MBR Creation
PostPosted: Sat Dec 02, 2017 8:20 am 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 1214
The wiki instructions expect you to do everything manually, which is quite stupid when automated solutions exist. That's why I directed you to this page describing how to automatically set up partition devices from a loop device.

If you mount your disk image following those instructions, you will see partition devices named similar to /dev/loop0p1 that can be treated exactly the same as any partition on a physical disk, including the format commands. You won't need to specify the number of blocks since the partition device will be the correct size.


Top
 Profile  
 
 Post subject: Re: FAT 32 MBR Creation
PostPosted: Sat Dec 02, 2017 9:12 am 
Offline
Member
Member

Joined: Fri Aug 07, 2015 6:13 am
Posts: 898
Octocontrabass wrote:
The wiki instructions expect you to do everything manually, which is quite stupid when automated solutions exist. That's why I directed you to this page describing how to automatically set up partition devices from a loop device.

If you mount your disk image following those instructions, you will see partition devices named similar to /dev/loop0p1 that can be treated exactly the same as any partition on a physical disk, including the format commands. You won't need to specify the number of blocks since the partition device will be the correct size.


I actually managed to mount both of them. I don't have any problems with that, anymore. Except they are not formatted correctly... again...
I will try to use your method and see if it works.

Edit:
Success!
I did everything as suggested and it worked. There are now two mounted and FAT 32 formatted partitions that I can access. Now I can finally start working on my bootloader without having to worry about this kind of stuff.
Is it normal for a hard drive with two partitions to contain 4 "FAT32 " signatures? Are those just FAT 32 specific backup tables?

For those who are interested here is my MBR:
Attachment:
HDD_MBR.png
HDD_MBR.png [ 86.03 KiB | Viewed 252 times ]

and here is a table whose purpose I don't know. Is this a bios parameter block together with a file allocation table altogether forming a VBR? What are those 4 extra bytes after 55 AA (not in the picture, 52 52 61 41)?
https://i.imgur.com/PeHqMfR.png

_________________
OS: Basic OS


Top
 Profile  
 
 Post subject: Re: FAT 32 MBR Creation
PostPosted: Sun Dec 03, 2017 12:01 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 1214
Now might be a good time to grab a copy of Microsoft's FAT filesystem specification and see if you can find the answers to your questions in it.

Here's a PDF copy of it.


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

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot] and 15 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