Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

share|improve this question
    
Why would you do that? Imho it makes much more sense to put /home on a separate partition. Then you may install a newer system, keeping all your files. Or to put swap on a separate partition, where it is easy to wipe everything. –  user unknown Jul 28 '11 at 1:34
add comment

2 Answers 2

up vote 4 down vote accepted

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.
share|improve this answer
1  
I keep /boot in a separate partition. It's not for everyone but it has several advantages. Distro upgrades can be tested by rotating root file system while still using tried and true kernels configured for that system (I use mostly custom compiled kernels for each system). The /boot partition can be small and out of the way. Using LVM it's easy to migrate the root file system around without worrying about breaking the boot loader. You can also keep a minimal rescue file system on the same partition with busybox and some tools to fix anything that goes wrong with the main root file system. –  Caleb Jul 27 '11 at 19:30
    
@Caleb I used separate /boot partitions when I had to due to older BIOSes or Grub1 with root on LVM, but I was glad when I could stop. –  Gilles Jul 27 '11 at 20:22
1  
I actually still use grub1; not because I have to per-se, just because I haven't bothered to learn and my kernel upgrade/configure/compile/install (including auto updating grub configs with full ability to regress to any kernel and pxe/tftp/netboot scenarios for dozens of machines on three continents) is completely automated by a single script that I would have to teach grub2 to after I learned it myself. –  Caleb Jul 27 '11 at 20:35
    
I actually want a separate /boot to try trusted-grub, a grub implementation that takes advantage of the TPM chip in my Thinkpad, to measure the kernel etc. It needs a separate /boot partition. I didn't create it when installing, because at that time I had three other primary partitions so I could create only one. Now I deleted the 'recovery' partition of lenovo so I can create a primary boot partition. –  nick Jul 30 '11 at 13:26
    
Another reason one might want a separate boot partition is if he needs full encryption of / and the boot partition must be unencrypted. –  nick Jul 30 '11 at 13:27
add comment

I haven't tried it, but copying "/boot" should work. Be sure to also edit your "/etc/fstab" accordingly. I would use some other system (e.g. a live disc) to do this since I don't know how to resize a live partition (if it's even possible/advisable). Also, leave the new boot partition as the first partition ("/dev/sda") to avoid unbootability.

share|improve this answer
    
Thanks @Tshepang. Can you explain a bit more about that unbootable issues you mention? Now the disk already has two other partitions (windows..) that are sda1 and sda2 so my one linux partition (that I want to split) is sda3. –  nick Jul 27 '11 at 15:50
    
When you resize (using a live disc), ensure that the boot partition occupies "/dev/sda3" and rest of your Linux partition occupies whatever else (perhaps "/dev/sda4"). For this, ensure that they remain primary partitions (you should see that option in your partitioning software). This should ensure that your Linux installation will remain bootable. –  Tshepang Jul 27 '11 at 15:53
3  
This isn't enough, you need to update the bootloader as well! Also Linux doesn't care about the partition number of the boot partition, nor whether it's a primary or logical partition. –  Gilles Jul 27 '11 at 16:39
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.