This tutorial covers how to move the boot partition for an Ubuntu 10.04 install after installing the system without a separate boot partition.

Easy way

See this tutorial: https://help.ubuntu.com/community/BootPartition

http://pix.toile-libre.org/upload/original/1342472594.png?200

Manual way

Info <!> Commands executed improperly can lead to an unbootable condition. If this happens, the user can use the Ubuntu installation CD to repair the installation to a working condition.

Info <!> All device names (like /dev/sda1 and hd0,1) used in the tutorial must be adjusted to match the partitions on the user's specific system. Do not copy commands in this tutorial without adjusting the drive/partition designations when appropriate!

Why may you want to do this?

  • Grub 2 error: no such partition.

  • BIOS limitations prevent the system from seeing the /boot partition files before an Operating System is loaded.
  • The user is using an OS filesystem format not compatible with the boot loader and must create a compatible ext2/3/4 partition for booting purposes.

What other options are there?

  • If an older BIOS doesn't recognise the full hard drive size, enable the 'large file' option (such as enabling LBA) in the BIOS settings; obtain a BIOS update from the manufacturer; or move the entire Ubuntu installation to the first part of the hard drive.

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 via the 'System -> Administration -> Gparted Partition Editor' menu.

Unmount the swap partition: Highlight it, then Partition -> Swapoff

Create a partition of at least 200 MB of free space. This partition can be created from existing unallocated space, or by shrinking another partition and using the newly-created free space.

  • On older systems or very large drives, ensure the boot partition is within the area recognised by the BIOS. Check the BIOS settings for the reported disk size. It may be necessary to place the new boot partition before the Linux/Ubuntu partition in order for the BIOS to see it.

For guidance on creating partitions read this: HowtoPartition

For this guide, actions will be taken on a main Ubuntu installation partition and a new boot partition. These partitions will be designated as:

  • /dev/sda2 - 200 MB (minimum) new boot partition
  • /dev/sda1 - 10 GB linux installation partition

Info <!> Remember to change the designations to match those on your system. The current partitioning setup can be viewed with the sudo fdisk -l (lowercase L) command.

If the boot flag is currently on your Ubuntu partition, move it to the new boot partition. This can be done with Gparted or the Disk Utility application.

  • 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. In these cases, GRUB or LILO are not given control even if installed in the MBR.

The partition order can be changed so that /dev/sda1 comes before /dev/sda2 when using the fdisk command using the advanced options.

  • Info <!> Changing these designations may affect system files which still identify partitions by device name rather than UUID.

Moving files from existing /boot to new location

Open a terminal via Applications -> Accessories -> Terminal To run commands as 'root' for the commands in this guide without using 'sudo': sudo su

Mount drives

Make the mount points. In this guide, we will mount the main Ubuntu partition on /mnt/main, and the new boot partition on /mnt/boot

mkdir /mnt/boot /mnt/main

Mount the two partitions:

mount /dev/sda2 /mnt/boot
mount /dev/sda1 /mnt/main

Copy /boot files

cp -a /mnt/main/boot/* /mnt/boot/

Remount the boot partition

Unmount the boot partition from /mnt and remount to /boot:

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

Editing the files from your Ubuntu install

Add /boot to your /etc/fstab

If you want to find out the UUID and confirm the format of the /boot partition type:

blkid -c /dev/null | grep "/dev/sda2"

The output should look similar to:

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

Open /etc/fstab for editing:

gedit /mnt/main/etc/fstab

Info <!> Note the format in fstab should match the format reported by the blkid command (ext2, ext3, ext4, etc). Add this line.

/dev/sda2    /boot     ext3     defaults    0  0

or to use the preferred UUID designation:

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

Setting up GRUB 2

Using the same mounting procedures as previously executed, from the LiveCD:

umount /dev/sda1 /dev/sda2
mount /dev/sda1 /mnt/main
mount /dev/sda2 /mnt/main/boot
grub-install --root-directory=/mnt/main /dev/sda

Continue at the Reboot section.

Setting up GRUB Legacy

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: {{{UUID=<uid found with blkid> /boot <format> defaults 0 0 Example: UUID=0d5f0b33-c9c2-4b10-873b-7e9df9448df4 /boot ext3 defaults 0 0

# groot=(hd0,0) }}}

and change the line

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

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 10.04, kernel 2.6.32-27-generic
root            (hd0,1)
kernel          /vmlinuz-2.6.32-27-generic root=UUID=41f24518-160e-48a1-9bb1-295213e94a67 ro quiet splash
initrd          /initrd.img-2.6.32-27-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 You will be asked to remove the CD and press "ENTER" before the system will reboot.

Final Cleanup

You are now booted using your new /boot partition but in the old /boot folder and files still exist on the / (root) filesystem.

To clean this up, open up a terminal and type the following commands to unmount the /boot partition, make a backup copy and then delete the old /boot folder*, recreate the /boot folder, and remount the new boot partition:

Info <!> The 'rm -rf' command, if executed improperly, can delete your entire installation. Ensure you have unmounted the new /boot partition with the 'umount' command and confirm you have typed or copied the "rm" command exactly before executing it! A backup copy of the old boot folder will be placed in /root/Desktop

sudo su
umount /boot
cp -a /boot /root/Desktop
rm -rf /boot 
mkdir /boot
mount /boot
exit

Maintenance

If using Grub legacy (not Grub 2), when you install a new linux kernel you may need to reinstall grub after mounting your boot partition over /boot in the live-CD root as shown above.


CategoryBootAndPartition

CreateBootPartitionAfterInstall (last edited 2012-09-03 14:19:01 by yannubuntu)