Some questions about MBR
Some questions about MBR
I have windows XP installed in the first partition of the first hard-disk. If I write my MBR to the first sector, I'll overwrite also some informations for the NTFS. How can I do?
I know this. My question is: how to write a MBR to boot windows and my system without using a boot manager like GRUB and without corrupt NTFS's informations.muisei wrote:If you want to write some boot code try using emulators.Qemu, Bochs, Virtual PC are good.If you want to try it on a real PC use a floppy disk or USB flash(if you have a new PC).Mesing with you primary HDD is a very dangerous job.
Maybe I can change bytes of the bootcode in the NTFS structure, but if I change these bytes how can I boot windows?
In few words I want to write a simple boot manager. GRUB and GAG are too much complex.
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: Some questions about MBR
You can replace the MBR with GRUB without breaking windows, if you have a separate partition to put it on. Writing your chainloader for common usage is more trouble than its worth.MarkOS wrote:I have windows XP installed in the first partition of the first hard-disk. If I write my MBR to the first sector, I'll overwrite also some informations for the NTFS. How can I do?
I use grub as well to multiboot between windows, linux, and my own os without trouble, and it was installed after windows.
I've got W2k installed on this box a few years AFTER I installed GRUB on it. I guess Windows must have looked at MBR, thought "seems that's not quite the standard thing out there" and just left it alone.
The real problem with goto is not with the control transfer, but with environments. Properly tail-recursive closures get both right.
If you are sure you want to mess with the boot process, I know two ways:
1.If you are using LINUX/UNIX system and you are root then you can have full access to the HDD.The command for read/write is 'dd'.First of all you MUST copy the MBR's partition table from your HDD which is placed from the 466th byte to the 510th byte.Then copy that partition table to your MBR and then copy your MBR to the first block of the HDD.
2.The second way is a little more complex.You can write a program which boots from a floppy/USB flash/CD.This program should do the following in this order:store the MBR's partition table from your HDD, then copy the partiotion table to your MBR, then copy your modified MBR to the first block of the HDD.
If something goes wrong, don't blame me!
Be exremely cautious with this.You can LOOSE ALL the data!
My suggestion is to spare some time learning how to use grub.This will save you a lot of headaches.By the way GAG is very easy to use.
1.If you are using LINUX/UNIX system and you are root then you can have full access to the HDD.The command for read/write is 'dd'.First of all you MUST copy the MBR's partition table from your HDD which is placed from the 466th byte to the 510th byte.Then copy that partition table to your MBR and then copy your MBR to the first block of the HDD.
2.The second way is a little more complex.You can write a program which boots from a floppy/USB flash/CD.This program should do the following in this order:store the MBR's partition table from your HDD, then copy the partiotion table to your MBR, then copy your modified MBR to the first block of the HDD.
If something goes wrong, don't blame me!
Be exremely cautious with this.You can LOOSE ALL the data!
My suggestion is to spare some time learning how to use grub.This will save you a lot of headaches.By the way GAG is very easy to use.
In which case, you really need to read up on NTFS, FAT and any other partitions you may want to install on. Can I suggest reading http://www.osdev.org/wiki/NTFS, particularly the links at the bottom of the page.
Cheers,
Adam
Cheers,
Adam
I have another very important question:
If I read the MBR and print these values, all (including LBA values) are correct except CHS values. Why?
Code: Select all
struct partition_table
{
unsigned char active;
unsigned char start_head;
unsigned char start_sector;
unsigned char start_cylinder;
unsigned char type;
unsigned char end_head;
unsigned char end_sector;
unsigned char end_cylinder;
unsigned int start_lba;
unsigned int end_lba;
} __attribute__((packed));
struct _mbr_t
{
uunsigned char useless_data[446];
struct partition_table partitions[4];
unsigned short signature;
} __attribute__((packed));
But the partition's utility included in yast says to me corrects cylinders values of all partitions. Maybe the values must be written in a different way? I print like this: printf("End Cylinder: %d\n", mbr.partitions[0].end_cylinder);muisei wrote:I'm not sure about this but I think this is because with CHS you can address maximum 8GB and with LBA you can address 2TB.