Solve the boot problem of Linux and Windows dual system

  

It has a long rule and a short inch. Although it can work entirely with Linux, entertainment. But the computer is only for humans. How to make it convenient, the operating system is also Both Linux and Windows are installed.

In this article, Windows uses XP and Linux uses Ubuntu. But the basic idea is the same: Linux's popular bootloader is grub. xp and nt use ntloader. Br>

This article in the Ubuntu forum advocates such a boot method: ntloader -> grub -> win/lin. But as some netizens said, grub takes into account boot windows, and ntloader has not considered Other systems than booting windows. Moreover, using ntloader to boot is more cumbersome. It is better to use grub to boot. Here I use grub as bootloader.

First add the basics: Understand the Linux boot process. In addition, you should have the xp and Ubuntu installation CDs on hand. (Ubuntu LiveCD, which is used to mount the hard disk partition and restore mbr). Before you start, you should know the following facts: (1) When the PC starts, it loads the bios. After that, the bootloader located in mbr is loaded. The bootloader can be ntloader or grub. (2) When installing windows system, the installer will write ntloader to mbr as bootloader. (3) grub can be installed. To mbr, you can also install to other locations. But Ubuntu liveCD is installed by default in mbr.

This problem comes up: How can we ensure that the dual system can start normally? One of the systems, how to ensure that another system is not affected? This is the problem to be said here.

First installation

Install Windows first, Then install Linux. This order is not only to avoid ntloader overwriting grub (even if it is overwritten, there are solutions, as described later), and because Linux can be installed in the extended partition and Windows does not work. In addition, when installing linux, Grub will detect the existing partitions and generate the appropriate boot options to load the windows system.

One thing to note is the file system, you can use this method: When you first install windows The space that is planned for linux is divided into one area. After installing Linux, this area is deleted, and then new multiple partitions are created. Ubuntu liveCD has been foolish, and the installation will not encounter any problems.

Recovering MBR

Compared to Linux, Windows will reload more frequently. After reinstalling, mbr will be overwritten, which will prevent Linux from booting. Solving the whole problem only needs to be restored. The previous MBR. Reinstall Linux does not have any problems. Because grub will detect the existing windows partition.

First backup mbr, use the dd command to the first sector of the hard disk 446 bytes' Grab 'down to save. After reinstalling windows and then restore mbr. This requires the use of linux boot CD. Boot into the command line, mount the partition where the saved mbr file is located, and then use the dd command to restore it. Note that I am a SCSI hard disk, so it is sda, IED hard disk is hda)

Backup MBR:

# dd if=/dev/sda of=/boot/boot.NNNN bs=446 Count=1

Restore MBR:

# dd if=/boot/boot.NNNN of=/dev/sda bs=446 count=1

- Why isn't 512, the main boot sector is a sector (512 bytes)?

- Only the first 446 of the backup file boot.NNNN of the primary boot sector The byte is rewritten to the primary boot sector.

boot.NNNN is the backup of the entire primary boot partition before we install Linux. If we write

512 bytes to the main boot sector, the hard disk

DPT table changed after installing Linux may also be destroyed.

MBR-> Main/Master Boot Record, some books are written as Master.

I think it can be divided into three parts, MBR+DPT+MagicNumber(446+64+2=512)

This is why you should specify bs=512 or bs=1k, count=1 when performing MBR backup. Then you can see that HOWTO is bs=446 count=1. This 446 is the instruction part. Recovery, not DPT recovery. Often the first instruction in MBR is cli... It is interesting to study.

Copyright © Windows knowledge All Rights Reserved