Linux – Can /boot Be Split to Different Partition?

bootlinuxpartition

I have set up my system, configured it and everything, using only one partition for / (ext4).
So no separate home, boot, swap etc.

So the question is:

Is there a way to go from this configuration to a 'separate' partition set-up?

Can I make room for a separate boot partition and maybe copy my /boot there?

Best Answer

You can shrink your existing filesystem and partition to make room for other partitions, then copy your files. Most filesystems can't be shrunk while they're mounted, so do it from a live CD/USB such as your distribution's or the GParted live CD (live CD dedicated to partitioning) or SystemRescueCD (general system administration and rescue live CD).

I do not, however, recommend making /boot a separate partition. Making /boot separate is only useful if your boot system can't manage to load a kernel from your root partition. The typical circumstances in which this happens are

  • You have an old BIOS (firmware) that can't see the whole disk, so you need to put the software that's necessary for booting in a small partition near the beginning of the disk.
  • You have a bootloader that can't read your root partition. For example, your bootloader is Grub 1 and your root partition is on an LVM volume.

If your system can already boot with the kernel on the root partition, there's nothing to be gained by creating a separate boot partition.

If you do decide to create a separate boot partition — or, for that matter, if you merge an existing boot partition onto your root partition, there's a bit more to it than just copying the files. When a PC boots, the BIOS loads the boot sector (the first 512 bytes of the boot disk) into memory. There isn't enough room in there to put a whole filesystem driver, so what that code does is to load more code from a location that's stored in the boot sector. If you move that code around to a different partition, you need to update that location. You may need to update your bootloader's configuration file as well.

  • With Grub, if your distribution ships with update-grub (e.g. Debian or Ubuntu), run it. Otherwise, edit the configuration file (/boot/grub/menu.lst for Grub 1 or /boot/grub/grub.cfg for Grub 2) and update the device from which Grub will find the kernel. (With Grub 2, you may have nothing to do as it can find the kernel automatically at run time.) In either case, also run grub-install /dev/sda.
  • With Lilo, run lilo.
Related Question