Windows XP, Linux Ubuntu. but the basic idea is the same: Linux's popular bootloader is grub. xp and nt use ntloader. this article in the Ubuntu Forum argues that ntloader-& gt; grub-& gt; win/lin. however, as some netizens have said, grub has considered windows boot, while ntloader has not considered
Windows uses XP and Linux uses Ubuntu, but the basic idea is the same: Linux's popular bootloader is grub. xp and nt adopt ntloader.
This article in the Ubuntu Forum advocates the following guiding method: ntloader-> grub-> win/lin. however, as some netizens have said, grub has taken windows boot into consideration, while ntloader has not considered booting other systems than windows. in addition, using ntloader for guidance is cumbersome. it is easier to use grub for guidance. here I use grub as the bootloader.
First, I would like to add some basic knowledge: Understand the Linux Startup Process. in addition, you must have an installation CD for xp and Ubuntu. (Ubuntu LiveCD is used to mount hard disk partitions and restore mbr ). before starting, you need to know the following facts: (1) when the PC is started, after the bios is loaded, the bootloader located in the mbr is loaded. This bootloader can be ntloader, or grub. (2) When installing windows, the installer writes ntloader to mbr as bootloader. (3) grub can be installed in mbr or other locations. however, Ubuntu liveCD is installed in mbr by default.
The question is: how can we ensure that the dual system can be started normally? If one of the systems is reinstalled, how can we ensure that another system is not affected? This is the question.
First Installation
First install Windows, then install Linux. this sequence is used not only to prevent ntloader from overwriting grub (even if it is overwritten, there is a solution, which will be described later), but also because Linux can be installed in extended partitions and Windows won't work. in addition, when installing linux, grub detects existing partitions and generates appropriate startup options to load windows systems.
Note that the file system can adopt the following method: When you first install windows, divide the space planned for linux into one partition, and then delete the partition when installing Linux, create multiple partitions again. ubuntu liveCD has been very foolish and will not encounter any problems during installation.
Recover MBR
Compared with Linux, Windows reinstalls the mbr frequently, and the mbr is overwritten after the reinstallation, so that the linux system cannot be guided. to solve the problem, you only need to restore the previous MBR. if you reinstall Linux, there is no problem. grub detects existing windows partitions.
First, back up the mbr and run the dd command to capture the first 446 bytes of the first sector of the hard disk and save it. after windows is reinstalled, the mbr will be restored. this requires the linux boot CD. start to enter the command line, mount the partition where the stored mbr file is located, and then run the dd command to restore it. (Note that I am using a SCSI hard disk, so it is sda and the IED hard disk is hda)
Backup MBR (Hard Disk Master Boot Record) -- Main Boot Record:
# Dd if =/dev/sda of =/boot. NNNN bs = 446 count = 1
Recover MBR:
# Dd if =/boot. NNNN of =/dev/sda bs = 446 count = 1
-Why isn't it 512? The primary Boot Sector is a single sector (512 bytes )?
-Only the first 446 bytes of the backup file boot. NNNN of the primary boot Sector are overwritten into the primary boot Sector.
Boot. NNNN is the backup of the entire primary boot partition before Linux is installed. If we set
Write all the 512 bytes into the Main Boot Sector and the hard disk may be changed after Linux is installed.
The DPT table is also damaged.
(Disk Partition Table) Hard Disk Partition Table
In the MBR (Master Boot Record) at the beginning of the hard disk, MBR occupies 512 bytes at the start of the hard disk.
MBR consists of three parts:
1. Main Bootstrap code, 446 bytes
2. Hard Disk Partition Table DPT, 64 bytes
3. 55AA
The 64 bytes from the offset 01BEH to the end of the Offset 01FDH. The hard disk partition table can be divided into four small parts, each of which indicates the information of a partition, accounting for 16 bytes. Therefore, the total number of Hard Disk Partitions cannot exceed 4. The number of active partitions cannot exceed 3, the number of extended partitions cannot exceed 1, and the number of active partitions must be less than or equal to 1.