Page 1 of 1
Obtain partition table for my MBR
Posted: Thu Feb 26, 2009 3:35 am
by mangaluve
As far as I understand, the MBR holds the partition table for the disk. But suppose I want to write my own MBR to start other operating systems. Can I obtain the partition table in some way (is it stored somewhere else on the hard drive or something).
Re: Obtain partition table for my MBR
Posted: Thu Feb 26, 2009 4:15 am
by mangaluve
So I have to use the current MBR to obtain a table and then put that partition table in my own MBR?
Re: Obtain partition table for my MBR
Posted: Thu Feb 26, 2009 4:24 am
by xenos
When you write a new MBR to your hard disk, you have to restore the original partition table, otherwise you will lose the information about partitioning. To write an own MBR, you have to read the old MBR, put your new code section together with the old partition table and write both to disk.
Re: Obtain partition table for my MBR
Posted: Thu Feb 26, 2009 4:40 am
by mangaluve
Okey, thanks! So this is something I do when I actually "build" the MBR? In reality, exactly when do I "copy" the old partition table?
Just a quick thought..what if I have a hard drive which is not bootable? Right now I have two hard drives, and only one of them contains operating systems..or they still need a MBR?
Re: Obtain partition table for my MBR
Posted: Thu Feb 26, 2009 4:43 am
by Solar
- Read old MBR;
- Extract partition table from old MBR;
- Write partition table into your new MBR;
- Write new MBR to disk.
Personally, I would do this in one step (i.e., when you "install" the new MBR).
Yes, non-bootable disks also have an MBR, as they also have to have a partition table. The MBR could be empty
except for the partition table, though.
Re: Obtain partition table for my MBR
Posted: Thu Feb 26, 2009 5:26 am
by mangaluve
Thanks for all the replies!
What I really want to do right now (for fun), is to be able to boot my operating systems (win/linux) from a USB stick. So I want to put a MBR / simple "kernel" on an USB stick. Then I want to read the MBR from my hard drive, extract the partition table, and then be able to start from the different partitions.