个人工具

UbuntuHelp:CreateBootPartitionAfterInstall

来自Ubuntu中文

Wikibot讨论 | 贡献2008年10月19日 (日) 22:25的版本

跳转至: 导航, 搜索
  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. 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 the your main partition by adding 100mb of free space before this, turn this created free space in a partition as well. if you don't know how, read this howto HowtoPartition We now have 2 partitions on the main drive, in my case /dev/sda

  • /dev/sda2 - 100mb new partition
  • /dev/sda1 - 3,65gb linux installation partition

Disable the bootflag on /dev/sda1 and enable it on /dev/sda2 using the right-click menu in 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!!

Moving files from existing /boot to new location

Now lets 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 whe 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)

Reinstall grub

run:

grub-install hd0,1

It will give an error about a filesystem, but in the output it also says you can ignore this

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.