个人工具

“UbuntuHelp:CreateBootPartitionAfterInstall”的版本间的差异

来自Ubuntu中文

跳转至: 导航, 搜索
 
(未显示同一用户的2个中间版本)
第14行: 第14行:
 
</nowiki></pre>
 
</nowiki></pre>
 
This tutorial covers how to create a boot partition for an Ubuntu 8.04 install after installing the system without a boot partition.
 
This tutorial covers how to create a boot partition for an Ubuntu 8.04 install after installing the system without a boot partition.
 +
Why may you want to do this?
 +
* If you get this error message after updating your linux kernel:
 +
'''Error 18: Selected cylinder exceeds maximum supported by BIOS'''
 
Needed for this tutorial are
 
Needed for this tutorial are
 
* An Ubuntu live CD
 
* An Ubuntu live CD
第22行: 第25行:
 
Boot from the Ubuntu Live CD as you would normally, select your language and choose the 'try Ubuntu' option
 
Boot from the Ubuntu Live CD as you would normally, select your language and choose the 'try Ubuntu' option
 
=== Creating a partition for /boot ===
 
=== Creating a partition for /boot ===
Once your system has booted from the live CD open GParted
+
Once your system has booted from the live CD open [[UbuntuHelp:GParted|GParted]]
 
this is in 'System -> Administration -> Partition Editor'
 
this is in 'System -> Administration -> Partition Editor'
Resize the your main partition by adding 100mb of free space before this,
+
Resize your main partition by adding 100 MB of free space before this,
 
turn this created free space in a partition as well.
 
turn this created free space in a partition as well.
if you don't know how, read this howto [[UbuntuHelp:HowtoPartition|HowtoPartition]]
+
If you don't know how, read this: [[UbuntuHelp:HowtoPartition|HowtoPartition]]
 
We now have 2 partitions on the main drive, in my case /dev/sda
 
We now have 2 partitions on the main drive, in my case /dev/sda
* /dev/sda2 - 100mb new partition
+
* /dev/sda2 - 100 MB new partition
* /dev/sda1 - 3,65gb linux installation partition
+
* /dev/sda1 - 3.65 GB linux installation partition
Disable the bootflag on /dev/sda1 and enable it on /dev/sda2 using the right-click menu in GParted
+
Disable the bootflag on /dev/sda1 and enable it on /dev/sda2 using the right-click menu in [[UbuntuHelp:GParted|GParted]]
''Maybe it's possible to switch the names of /dev/sda2 and /dev/sda1, but i don't know how.. feel free to add this information!!''
+
'' Q: Is this really necessary?  GRUB and LILO are supposed to ignore the bootable flag''
 +
'' A: In rare cases, the motherboard BIOS requires a partition with a bootable flag in order to boot from the hard drive. I have personal experience with this. In these cases, GRUB or LILO are not given control even if installed in the MBR.''
 +
The partition order can be fixed so that /dev/sda1 comes before /dev/sda2 in fdisk using the advanced options "f fix partition order"
 
== Moving files from existing /boot to new location ==
 
== Moving files from existing /boot to new location ==
Now lets start a console
+
Now let's start a console
 
in the console type
 
in the console type
 
<code><nowiki>sudo su</nowiki></code>
 
<code><nowiki>sudo su</nowiki></code>
第53行: 第58行:
 
</nowiki></pre>
 
</nowiki></pre>
 
=== Remount the boot partition ===
 
=== Remount the boot partition ===
Now whe are remounting the boot partition to be where /boot is,
+
Now we are remounting the boot partition to be where /boot is,
 
we need this for later to re-install grub
 
we need this for later to re-install grub
 
<pre><nowiki>
 
<pre><nowiki>
第103行: 第108行:
 
# groot=(hd0,1)
 
# groot=(hd0,1)
 
</nowiki></pre>
 
</nowiki></pre>
 +
Next, update the boot entries at the end of the file. Since you now have a /boot partition, all kernel and initrd paths are relative to /boot/ instead, eg.
 +
<pre><nowiki>
 +
title          Ubuntu 8.04.1, kernel 2.6.24-21-generic
 +
root            (hd0,1)
 +
kernel          /vmlinuz-2.6.24-21-generic root=UUID=41f24518-160e-48a1-9bb1-295213e94a67 ro quiet splash
 +
initrd          /initrd.img-2.6.24-21-generic
 +
quiet
 +
</nowiki></pre>
 +
Update '''root''' to match that of groot above and remove /boot from the '''kernel''' and '''initrd''' paths in all the entries.
 
=== Reinstall grub ===
 
=== Reinstall grub ===
 
run:
 
run:
 
<pre><nowiki>
 
<pre><nowiki>
grub-install hd0,1
+
sudo grub
 +
grub> root (hd0,1)
 +
grub> setup (hd0)
 
</nowiki></pre>
 
</nowiki></pre>
It will give an error about a filesystem, but in the output it also says you can ignore this
+
remember in the setup command do not use hd0,1 as you need to install grub in the master boot record not in this specific partition boot record.
 
== Reboot ==
 
== Reboot ==
 
reboot your system by typing  
 
reboot your system by typing  
第128行: 第144行:
 
recreated the /boot dir as empty dir.<<BR>>
 
recreated the /boot dir as empty dir.<<BR>>
 
remounted the boot partition.
 
remounted the boot partition.
 +
== Maintenance ==
 +
'''Remember when your install new linux kernel next time, you may need to reinstall grub after mounting your boot partition over /boot in the live-CD root as shown above.'''
 
----
 
----
 
[[category:CategoryBootAndPartition]]
 
[[category:CategoryBootAndPartition]]
  
 
[[category:UbuntuHelp]]
 
[[category:UbuntuHelp]]

2010年5月19日 (三) 21:57的最新版本

  1. title Create boot partition after install
    This is not finished (but then isn't this the nature of the web?)
    These procedures could damage the information on your computer. Make backups first.
    Be careful. Read the documentation, again. You have been warned. Twice.
    !!! All device names (like /dev/sda1 and hd0,1) 
    used in the tutorial need not to apply on your situation,
    do some research of your device names first and don't 
    blindly copy every command from this tutorial !!!

This tutorial covers how to create a boot partition for an Ubuntu 8.04 install after installing the system without a boot partition. Why may you want to do this?

  • If you get this error message after updating your linux kernel:

Error 18: Selected cylinder exceeds maximum supported by BIOS Needed for this tutorial are

Preparations

Booting the Ubuntu Live CD

Boot from the Ubuntu Live CD as you would normally, select your language and choose the 'try Ubuntu' option

Creating a partition for /boot

Once your system has booted from the live CD open GParted this is in 'System -> Administration -> Partition Editor' Resize your main partition by adding 100 MB of free space before this, turn this created free space in a partition as well. If you don't know how, read this: HowtoPartition We now have 2 partitions on the main drive, in my case /dev/sda

  • /dev/sda2 - 100 MB new partition
  • /dev/sda1 - 3.65 GB linux installation partition

Disable the bootflag on /dev/sda1 and enable it on /dev/sda2 using the right-click menu in GParted Q: Is this really necessary? GRUB and LILO are supposed to ignore the bootable flag A: In rare cases, the motherboard BIOS requires a partition with a bootable flag in order to boot from the hard drive. I have personal experience with this. In these cases, GRUB or LILO are not given control even if installed in the MBR. The partition order can be fixed so that /dev/sda1 comes before /dev/sda2 in fdisk using the advanced options "f fix partition order"

Moving files from existing /boot to new location

Now let's start a console in the console type sudo su to become root, like this you can do all the root task without having to use 'sudo' all the time.

Mount drives

next is to make a directory to mount the two drives in.

mkdir /mnt/boot
mkdir /mnt/root

and mount the two drives in here

mount /dev/sda2 /mnt/boot
mount /dev/sda1 /mnt/root

Copy files

cp -r /mnt/root/boot/* /mnt/boot/

Remount the boot partition

Now we are remounting the boot partition to be where /boot is, we need this for later to re-install grub

umount /dev/sda2
mount /dev/sda2 /boot

Editing the files from your Ubuntu install

Add /boot to your /etc/fstab

in the console write

gedit /mnt/root/etc/fstab

to edit the fstab file in your Ubuntu install and add the line

/dev/sda2    /boot     ext2     defaults    0  0

or if you want to find out the UUID of the drive and use that in the fstab file, in the console type

blkid

in the output there will be

/dev/sda2:  UUID="<some uid>" TYPE="ext2"

the line to add in /etc/fstab would now be

UUID=<uid found with blkid> /boot   ext2   defaults  0  0

The UUID will be the same in the live cd environment as in your normal Ubuntu, so it's completely save to copy this value

Setting up GRUB

Edit /boot/grub/menu.lst

in the console write

gedit /boot/grub/menu.lst

gedit opens with the menu.lst file, find the part that says:

# groot=(hd0,0)

and change the line

# groot=(hd0,0)

to

# groot=(hd0,1)

Next, update the boot entries at the end of the file. Since you now have a /boot partition, all kernel and initrd paths are relative to /boot/ instead, eg.

title           Ubuntu 8.04.1, kernel 2.6.24-21-generic
root            (hd0,1)
kernel          /vmlinuz-2.6.24-21-generic root=UUID=41f24518-160e-48a1-9bb1-295213e94a67 ro quiet splash
initrd          /initrd.img-2.6.24-21-generic
quiet

Update root to match that of groot above and remove /boot from the kernel and initrd paths in all the entries.

Reinstall grub

run:

sudo grub
grub> root (hd0,1)
grub> setup (hd0)

remember in the setup command do not use hd0,1 as you need to install grub in the master boot record not in this specific partition boot record.

Reboot

reboot your system by typing reboot. Take out the ubuntu live cd, and boot back to your normal system voila, you now have a working /boot partition

Final Cleanup

You are now booted using your new /boot partition, but in the old /boot dir on the / (root) filesystem there are still the files used for booting before you had a separate partition for that. To clean this up, open up a console and type the following commands

umount /boot
rm -rf /boot
mkdir /boot
mount /boot

You have now unmounted the boot partition,<
> deleted all the files from /boot in the / (root) filesystem.<
> recreated the /boot dir as empty dir.<
> remounted the boot partition.

Maintenance

Remember when your install new linux kernel next time, you may need to reinstall grub after mounting your boot partition over /boot in the live-CD root as shown above.