8

I am running Ubuntu Server 14.04.4 under VirtualBox on a Windows server. When I first set up the machine I opted to put /boot on its own 230 MB partition. This turns out not to have been necessary for my situation and now I’d like to roll /boot into the much larger partition I use for /. How can I safely make this change?

bdesham
  • 343
  • 3
  • 12

2 Answers2

8

Short answer: If it ain't broke, don't fix it.

Long answer: If you insist on fixing what ain't broke:

  1. Open a Terminal window.
  2. Type sudo mkdir /boot2
  3. Type sudo cp -a /boot/* /boot2/
  4. Type sudo umount /boot
  5. Type sudo rmdir /boot
  6. Type sudo mv /boot2 /boot
  7. Edit /etc/fstab and comment out the line that defines the mount point for /boot.
  8. Type sudo grub-install
  9. Type sudo update-grub (if you're using a BIOS-based install, you'll also need to specify a device filename -- probably /dev/sda)
  10. Optionally delete the /boot partition and resize the root (/) partition. See here for details on how to do this.

I have not tested this procedure! If I've forgotten something or if there's an unexpected error, your system will be rendered unbootable! Hence:

  1. Please reconsider my "short answer," above.
Rod Smith
  • 44,284
  • 7
  • 63
  • 105
  • 4
    It is broke: Ubuntu automatically installs new kernels but doesn’t automatically remove old ones, so /boot will run out of space every month or two unless someone manually uninstalls the old kernels. I will read through the documentation of these commands and gingerly give it a shot. – bdesham Mar 04 '16 at 19:11
  • This worked for me. Though step 7 should be comment out instead of "uncomment", and I needed to specify the device name (in my case /dev/sda) in step 8. – Wang Dingwei Jul 31 '17 at 05:46
  • @WangDingwei, I've edited the answer appropriately. Thanks for pointing out the error and omission. – Rod Smith Jul 31 '17 at 13:01
  • Specifying the drive is probably related to grub-install instead of update-grub. – Melebius May 01 '18 at 15:22
  • If this works out for /boot I suppose it should work for /var as well, right? – chefarov May 11 '18 at 11:15
  • @RodSmith Unless I'm mistaken (and in spite of the clear mention that this procedure has not been tested), the rmdir command called in 7. would not work unless /boot is empty, right?

    Perhaps recommending the use of Trash management tools following the FreeDesktop.org's Trash Specification may help a bit in gaining confidence here. What do you think?

    – Th. Ma. Oct 01 '22 at 14:02
  • What about raspberry clones? I have an ODROID-HC2 headless with an sd card with 2 partitions: /boot has 400MBs and / has 1600MBs. Both are ext4. It will be great to merge them in one partition, but such devices do not have and do not boot with grub. Any advices? – Chameleon Dec 05 '22 at 23:22
1

Updating with new answer that supports EFI. (EFI requires a FAT32 partition mounted as /boot/efi).

  1. sudo cp -a /boot /boot2
  2. sudo umount /boot/efi && sudo umount /boot || echo -e "\n\rNot EFI?? STOP!"
  3. sudo rmdir /boot
  4. sudo cp -a /boot2 /boot
  5. sudo rm -r /boot/efi/*
  6. sudo mount /boot/efi
  7. sudo diff -r /boot /boot2 && sudo rm -r /boot2 || echo -e "\n\r\n\rSOMETHING'S WRONG, STOP!!"
  8. sudo nano /etc/fstab
    • Edit /etc/fstab and comment out the line that defines the mount point for /boot. Leave the /boot/efi entry unaltered!
  9. sudo update-grub
    • Make sure entries are found in /boot/, e.g. "Found linux image: /boot/vmlinuz-*"
  10. Optionally, delete the /boot partition and resize the / partition.
NiJo
  • 46