FAT32 and MBR-Partitioned Disk Questions

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.
Post Reply
User avatar
ScropTheOSAdventurer
Member
Member
Posts: 86
Joined: Sun Aug 25, 2013 5:47 pm
Location: Nebraska, USA

FAT32 and MBR-Partitioned Disk Questions

Post by ScropTheOSAdventurer »

I have been working on having my FAT32 based bootloader support partitioned disks instead of just the partitionless FAT32 disk image I had been using prior. It proved to be problematic when I had trouble just finding a tool that could automatically create a partitioned disk image and manipulate it as necessary (flag partitions as bootable, manipulate a raw partition image, format a partition, etc.). I settled on guestfish, but I keep having problems with that too.

Their built-in partition formatting options at best let me use mkfs.vfat with FAT16 formatting (at least by looking at the hex editor), when I want to do FAT32. I then decided to run "mkfs.vfat -F 32 -h HIDDENSECTORS" on the raw partition image that I extracted from the disk image. I calculated HIDDENSECTORS by taking the number of sectors I specified for the disk image and subtracting "du -k $(PARTITIONIMG) --block-size=512" from it. However, it keeps overestimating the number of hidden sectors to the point that I have to manually fix it by hex editor.

Also, their part-set-bootable option, which is supposed to mark a partition as bootable, doesn't seem to work as advertised, forcing me to mark my FAT32 boot partition as bootable via hex editor.

I have found short-term solutions to all of these problems for the meantime, but I have two questions. First, is there any reason that you know of that my method of figuring out hidden sectors may overestimate the number of them? Second, does anyone have any suggestions for what tools to use for manipulating MBR disks?
"Procrastination is the art of keeping up with yesterday."
Octocontrabass
Member
Member
Posts: 5587
Joined: Mon Mar 25, 2013 7:01 pm

Re: FAT32 and MBR-Partitioned Disk Questions

Post by Octocontrabass »

It sounds like you're using Linux. Create a reasonably-sized file with dd, mount it as a loopback device, and manipulate the loopback device the same way you would a real disk. (You may need to use partprobe to update the /dev/loop#p# devices after partitioning.)
User avatar
ScropTheOSAdventurer
Member
Member
Posts: 86
Joined: Sun Aug 25, 2013 5:47 pm
Location: Nebraska, USA

Re: FAT32 and MBR-Partitioned Disk Questions

Post by ScropTheOSAdventurer »

Oh, yeah; that is what I was originally doing with my non-partitioned FAT disk, but it bothered me that I had to use sudo. Should have mentioned that earlier.
"Procrastination is the art of keeping up with yesterday."
Octocontrabass
Member
Member
Posts: 5587
Joined: Mon Mar 25, 2013 7:01 pm

Re: FAT32 and MBR-Partitioned Disk Questions

Post by Octocontrabass »

In that case, create a reasonably-sized file with dd, partition and format it with parted, and add files to it using mcopy (from mtools).
User avatar
iansjack
Member
Member
Posts: 4706
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: FAT32 and MBR-Partitioned Disk Questions

Post by iansjack »

ScropTheOSAdventurer wrote:it bothered me that I had to use sudo
Why did/does that bother you?
User avatar
ScropTheOSAdventurer
Member
Member
Posts: 86
Joined: Sun Aug 25, 2013 5:47 pm
Location: Nebraska, USA

Re: FAT32 and MBR-Partitioned Disk Questions

Post by ScropTheOSAdventurer »

How did I forget about mcopy? My memory is like a goldfish's.

The reason I dislike using sudo is because it seems so unnecessary. I shouldn't have to get root access just to manipulate a disk image.

Thanks for reminding me of mcopy!
"Procrastination is the art of keeping up with yesterday."
User avatar
iansjack
Member
Member
Posts: 4706
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: FAT32 and MBR-Partitioned Disk Questions

Post by iansjack »

sudo is not the same as granting root access.

But anyway, you have found an acceptable solution so all is well.
User avatar
ScropTheOSAdventurer
Member
Member
Posts: 86
Joined: Sun Aug 25, 2013 5:47 pm
Location: Nebraska, USA

Re: FAT32 and MBR-Partitioned Disk Questions

Post by ScropTheOSAdventurer »

I know it isn't the same as actually BEING root, but it still gets me admin for the moment. I am not ignorant in that regard. It just seems all unnecessary to me.

Anyways, thanks for reminding me about mtools guys. It is so convenient.
"Procrastination is the art of keeping up with yesterday."
Post Reply