Linux MBR



Master Boot Record

The master boot record is a small area at the beginning of a hard drive, before any partitions. When a computer is started, it looks on the master boot record for instructions on what to do next.

The master boot record is automatically created when the first partition is created.

Some older USB drives were formatted without a master boot record. If you want to create one, delete the partition and create a new one. This can be done using any partitioning program, including one of the Live CDs for Partitioning.


Install Linux Last

The simplest way to set up the Master Boot Record so it starts Grub, is to install Linux last, and it will automatically set up the Master Boot Record.


Set Up the Master Boot Record

There may be times when you install another operating system last. For example, you may have both Linux and Windows on a computer, and reinstall Windows, or install a newer version of Windows. When installing Windows, it will set up the Master Boot Record to start Windows, so you won't be able to start other operating systems. To rectify this, you need to set up the Master Boot Record to start Grub.

You may also use Grub on a computer where the operating system does not automatically set up the Master Boot Record.


Grub Prompt

To set up the Master Boot Record, you need a Grub prompt.

You can get a Grub prompt while running most Linux live CDs.

To get a Grub prompt, open the Root Terminal and type:

grub

If you use the live CD of a Linux Distribution which uses sudo, such as Ubuntu, Kubuntu, Xubuntu, Mint, and distributions based on them, open the Terminal and type:

sudo grub

Set Up the Master Boot Record

When setting up the Master Boot Record, you need to enter appropriate partition information. In this example, Grub is in the first partition on the first hard drive, which is (hd0,0) in Grub. Change this to whatever partition Grub is in.

After getting the Grub prompt, type:

root (hd0,0)
setup (hd0)
quit

Drives and Partitions

In Grub, the first number indicates the drive, and the second number indicates the partition. Grub drive and partition numbers start with zero, so the number used is always one less than the actual number.

In the example above, Grub is in the first partition on the first hard drive.

If Grub is in the second partition on the first hard drive, use:

root (hd0,1)

If Grub is in the third partition on the first hard drive, use:

root (hd0,2)

If Grub is in the first partition on the second hard drive, use:

root (hd1,0)

If Grub is in the second partition on the second hard drive, use:

root (hd1,1)

Where you see "setup (hd0)," you need to indicate where to set up the master boot record. The number indicates the drive where the master boot record will be set up. Again starting with zero, so the number used is one less than the actual number.

When setting up the master boot record on a hard drive which remains in the computer, you need to set up the master boot record on the first hard drive (even if Grub is on another hard drive), so leave the second line as:

setup (hd0)

Removable Drives

You may install an operating system on a removable drive, such as a USB drive, so you can run the operating system from the removable drive. To start the operating system, you need to set up the master boot record on the removable drive. (There are also methods other than Grub for starting operating systems.)

When setting up the master boot record on a removable drive, be careful that you don't unintentionally change the master boot record on the hard drive. If you do, you may not be able to start the operating systems on the computer.

One way to be sure, is to disconnect the computer's hard drive. Use a Linux live CD to get a Grub prompt.

With the hard drive disconnected, after getting a grub prompt, type:

root (hd0,0)
setup (hd0)
quit

When setting up the master boot record on a removable drive, if you do not disconnect the hard drive, and the computer has only one hard drive, after getting a grub prompt, type:

root (hd1,0)
setup (hd1)
quit

If the computer has two hard drives, and you do not disconnect them, after getting a grub prompt, type:

root (hd2,0)
setup (hd2)
quit

If the removable drive has other partitions, and Grub is not on the first partition, use the appropriate partition number. For example, if the computer has one hard drive and you do not disconnect it, and grub is on on the second partition of the removable drive, after getting a grub prompt, type:

root (hd1,1)
setup (hd1)
quit


source:http://gr8idea.info/os/tutorials/linux/mbr.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值