Solve the problem of dual operating system boot for Linux and Windows

Source: Internet
Author: User
Article Title: solve the problem of dual operating system boot for Linux and Windows. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.

The ruler has strengths and the inch is short. although it can work in Linux, entertainment. however, computers only serve humans. how can this problem be solved? The operating system is also installed on Linux and Windows.

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 adopts 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:

# 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.

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 bs = 512, bs = 1 k, and count = 1 must be specified during MBR backup. then, we often see bs = 446 count = 1 in HOWTO. this 446 is the restoration of the instruction part, not the restoration of DPT. the first command in MBR is cli ...... It is interesting to study.

References

Http://forum.ubuntu.org.cn/about17047-0-asc-0.html

Here you can get free Ubuntu installation disc: https://shipit.ubuntu.com/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.