/* Format the MBR & partitiontable */
GrubBootSector mbr = (GrubBootSector) (createFormatter()
.getBootSector());
IBMPartitionTableEntry pte = mbr.initPartitions(geom, IBMPartitionTypes.PARTTYPE_DOS_FAT16_LT32M);
/*
* System.out.println("partition table:"); for (int i = 0; i < 4; i++) {
* System.out.println("" + i + " " + mbr.getPartition(i)); }
*/
/* Format partition 0 */
part0 = new MappedFSBlockDeviceSupport(device, pte.getStartLba()
* bytesPerSector, pte.getNrSectors() * bytesPerSector);
GrubFatFormatter ff = createFormatter();
ff.setInstallPartition(0x0000FFFF);
ff.format(part0);
GrubBootSector part0bs = (GrubBootSector) ff.getBootSector();
/* Fixup stage2 sector in MBR */
mbr.setStage2Sector(pte.getStartLba() + part0bs.getStage2Sector());
try {
mbr.write(device.getAPI(BlockDeviceAPI.class));
} catch (ApiNotFoundException ex) {
final IOException ioe = new IOException("BlockDeviceAPI not found on device");
ioe.initCause(ex);