For those of us who like using SBM (Smart Boot Manager) at one point or another will come across a situation where a partition tool which falsely reports no partitions on the drive and, instead, will usually report the whole drive as one big FAT12 partition.......Partimage is one of those programs, as well as RedHat's Disk Druid and for the Puppy Linux fans, the Pmounter partition tool......For the most part all the various fdisk programs, gparted, and others, have no problem reporting the correct partition table.........This leads me to suspect that maybe it's not entirely the fault of SBM, but the shortcoming of those "buggy" programs that have problems with SBM.....
I consider SBM as one of the best boot managers to put in the MBR....It is able to chainload any bootable partition which contains an operating system's native bootloader, and also has it's own el torito stack for booting CD drives for those old BIOS which cannot boot such a drive.
Well, I finally got tired of it all and decided to investigate the problem.........I started off by looking up the "magic" number that identifies a FAT12 partition, which is 0x01 in hexadecimal.....Next, I opened up a hex editor and took a peek at the primary hard drive (/dev/hda) and did a hex search or '01', which I found at offsets 0x0000000d and 0x0000000e (the 13th and 14th bytes from the beginning, starting with 0).....
Then, I changed only the first offset to a null byte (0x00), fired up partimage, and partimage now reported all the partitions......After saving the change, I rebooted to see if I broke SBM......And what do you know, there was SBM staring me in the face
.........I highlighted the appropriate entry to boot me back into the same OS, and everything was working perfectly........
So I decided to write a script to automate the process, using dd to make the appropriate change..........With the hex editor, I changed the offset back to it's original value and first tested dd on the command line with the following command:
Code:
dd if=/dev/zero bs=1 count=1 seek=14 of=/dev/hda
I opened up the hex editor to look at the change, and discovered I changed the wrong offset......I changed the second instance of 0x01 at offset 0x0000000e, not the one before it.............After a bit if head-scratching, I finally figured out where I went wrong..........I was doing the count starting with 1, where I should have started the count with 0.......
Since I was feeling adventurous, I decided to see if that made any difference with partimage..........To my surprise, partimage reported the partitions correctly!.........Here, I was trying to change the very first instance of 0x01, figuring that would do the trick and accidentally discovered that changing the second occurrence also worked..........
I then decided to change both occurrences to null bytes and see what happens.........Partimage still reported all the partitions correctly, so I rebooted to check on the boot manager......After rebooting, SBM still appeared and looking normal........So, again, I highlighted the correct OS, and booted in without any issues.....
So I modified the dd command (getting it right this time) and made the following script for whenever I need to reinstall SBM:
Code:
#! /bin/sh
dd if=/dev/hda bs=16 count=1 of=/sbm.bin # Save the relevent portion before making the change in the MBR
dd if=/dev/zero bs=1 count=2 seek=13 of=/dev/hda
I saved the script as
sbmhack.sh.......I didn't make it executable, just as an added precaution........
For those interested, to run the script you must be root (or have root privileges) and simply run it like so:
sh sbmhack.sh.......Using a script will avoid any heartache from possible typos (as long as the script is free of typos
)
I hope this will be of help for those who like Smart Boot Manager, like I do...........This is a safe hack as long as you use the script, but I will NOT be responsible for any problems if you decide to do so............You make the choice without any arm-twisting, so it's your responsibility for any problems. YOU HAVE BEEN WARNED!........
But as I said, this is a safe hack and will not cause any data loss by following the instructions carefully and correctly.....
---thegeekster