gpt - Out of Band Disk Partitioning and Tables

05
2014-04
  • Milind R

    Our current methods of disk partitioning involve storing the partition layout on the disk itself, right along with the data.

    It's easy to screw up the data in a disk : just wipe out the partition data. GPT fixes this somewhat, but the data of how it's partitioned is still sitting next to the data.

    Can we not store the partition table in a flash memory chip on disk, in an Out of Band(OoB) manner? Provide an ATA command to query partitions, and to seek a specific sector in a specific partition, which the drive controller can translate to disk-absolute sector numbers and addresses. Compatibility would not be a problem : the disk would switch into partitioned mode using a specific command. Else it would just spoof the relevant sectors for the partition table, or better, it'll use current way of storing table with data. This way, protection for writing to partition table info can be achieved...

    UPDATE

    PROPOSAL :

    • Store Partition table AND partition table querying code ON disk in a tiny flash chip.
    • Reading through usual ATA commands.
    • Modifying partition table requires new ATA commands
    • Writing a new scheme of partitioning requires other new commands.
    • Compatibility layer for seamless operation with non-OoB-partitioning-aware systems.

    BENEFITS :

    • GPT uses a maximum of 34 sectors twice on 512 byte sectors. 34KB.
    • Reduces risk of overwriting or losing partition data
    • Disk can be partitioned in ANY WAY : the ATA commands will take care, using routines stored
    • Makes disks a lot more portable, OS not required to bother about it
    • Standard methods to write to flash, both for modifying, and flashing new partitioning schemes
  • Answers
  • ultrasawblade

    This is in line with a classic, recurring problem in computers in general - is it better to store metadata (i.e. "data about data" - esp. things like "what type is this data") in the same stream as the data itself or separately?

    If the flash chip holding the hardware information is read/write accessible just as much as sector 0 of the hard drive, you really haven't bought yourself any additional protection. It's just as easy to trash the partition flash storage as it is sector 0, and only marginally harder to avoid.

    You've introduced additional complexity, firmware development needs and manufacturing cost for little benefit.

    "Locking" and such - I guess it'd be nice to make provision for a BIOS to lock a drive's partition table, but I'm really more worried about the data in the partition rather than the partition itself. I'd also like to be able to change the partitions and switch hard drives without potentially having to ask my future DRM-enabled BIOS for permission.

    One thing that studying networking has taught me is that sometimes for a device or service to say "nothing is my job but this one task" is really the best and most robust thing. We want hard drive designers and manufacturers to concentrate on one thing - reliable, copious storage. If you don't have that, little else matters in a computer. Letting everything else (partitioning, security, etc.) to be "not the drive's job" allows the drive itself to be a reliable, replaceable, easily upgradeable and expandable commodity.


  • Related Question

    windows 7 - More than 4 primary partitions on MacBook with rEFIt (GPT/MBR syncing)?
  • fideli

    I currently have a triple-boot on my MacBook (OS X 10.6.5, Windows 7, Ubuntu 10.10) which works very well. I'd like to now make an ExFAT storage partition that would be shared amongst the three OS's, with the importance on sharing between Windows and OS X. This is what it looks like right now:

    $ diskutil list
    /dev/disk0
       #:                       TYPE NAME                    SIZE       IDENTIFIER
       0:      GUID_partition_scheme                        *500.1 GB   disk0
       1:                        EFI                         209.7 MB   disk0s1
       2:                  Apple_HFS MacOSX                  400.0 GB   disk0s2
       3:       Microsoft Basic Data BOOTCAMP                74.5 GB    disk0s3
       4:       Microsoft Basic Data                         25.3 GB    disk0s4
    

    There are, it appears, 4 partitions on the drive already, since the EFI requires 200 MB in the beginning. I'm wondering if I were to add another partition whether that would mess up the GPT/MBR syncing that rEFIt does for me because there would be more than 4 primary partitions on the disk. I will likely use iPartition for this.

    EDIT
    To add to the complexity, for unrelated reasons I decided to switch from Ubuntu to Fedora on that last partition. During the install, my curiosity made me select the recommended two partition setup with /boot going on a 500 MB /dev/sda4 and / in an LVM on /dev/sda5. The drive now looks like this:

    $ diskutil list
    /dev/disk0
       #:                       TYPE NAME                    SIZE       IDENTIFIER
       0:      GUID_partition_scheme                        *500.1 GB   disk0
       1:                        EFI                         209.7 MB   disk0s1
       2:                  Apple_HFS MacOSX                  400.0 GB   disk0s2
       3:       Microsoft Basic Data BOOTCAMP                74.5 GB    disk0s3
       4:                        EFI                         524.3 MB   disk0s4
       5:                  Linux LVM                         24.8 GB    disk0s5
    

    When I re-synced rEFIt, it suggested an MBR table that only had the first 4 partitions on it. Will try to get that info to add to this next time I reboot.

    EDIT
    Turns out that that you can't have more than 4 primary partitions with the GPT/MBR sync. In retrospect, it all makes sense now. I decided to just go ahead and test this so I created a 25 GB partition on the end of the drive. Looks like this now:

    /dev/disk0
       #:                       TYPE NAME                    SIZE       IDENTIFIER
       0:      GUID_partition_scheme                        *500.1 GB   disk0
       1:                        EFI                         209.7 MB   disk0s1
       2:                  Apple_HFS MacOSX                  373.4 GB   disk0s2
       3:       Microsoft Basic Data BOOTCAMP                74.5 GB    disk0s3
       4:                        EFI                         524.3 MB   disk0s4
       5:                  Linux LVM                         24.8 GB    disk0s5
       6:       Microsoft Basic Data Transfer                26.6 GB    disk0s6
    

    Used OS X to format the last partition as exFAT (volume name Transfer). Used rEFIt to sync the GPT and MBR tables. Only showed up to 4 (which answers this question), which doesn't show up in Windows (which was expected). Next, I downloaded an OS X binary of the gptsync.efi program that rEFIt uses from the InsanelyMac forums and ran the following command to select the GPT partitions I wanted in the MBR table (1, 2, 3, and 6):

    sudo gptsync /dev/disk0 2+af 3-07 6-07
    

    thinking that the MBR type is 07 as listed on the exFAT WikiPedia page. When I rebooted into Windows again, the partition showed up in diskmgmt.msc, but as a RAW format. Upon accessing it in Explorer, I get the option to format it. I decided to try using a different MBR code and ran the following command again in OS X:

    sudo gptsync /dev/disk0 2+af 3-07 6-0c
    

    which did not resolve the problem. A cursory search suggests that exFAT is only meant to be used on external volumes, and that Windows would not load an internal partition formatted as exFAT. So, two things: (1) I either still have the MBR code wrong or (2) it just won't be read by Windows.


  • Related Answers
  • Everett

    I did exactly this (Win7 64, Ubuntu 10 64bit, OS X 64 bit, and an ExFAT part). When I found out that Customs could search a laptop at will without a court order in violation of the Constitution, I chose to move the ExFAT to a 128GB ExpressCard SSD (100 GB ExFAT set up for user space, 8 for each OS swap file, and the leftover space as RAM for Win7 to use).

    This way all three systems could use the ExFAT as user space, it wasn't physically on the computer (it's removable), and since I was using 2 drives (one for OS/Apps, the other for user space/swap space) I sped up my system (not a huge amount).

    If I had to worry about anyone wanting to see what was on my computer, I simply removed the user/swap space. I have licenses for all the Apps and the OS's on my Apps/OS drive. There are no applications that are unlawful for me to own/use to the best of my knowledge. I use Launchbar to search my user space (because the database for it is kept on the user space not on the OS/App space like Spotlight). I just wanted to give you food for thought.