Fedora Linux Support Community & Resources Center
  #1  
Old 3rd November 2012, 03:19 AM
badwithnames Offline
Registered User
 
Join Date: Aug 2012
Location: Texas
Posts: 5
linuxchrome
How to move /boot between partitions, under GRUB2

Hi everyone. I have an 80 MB /boot partition, which is obviously a problem. I'd like to move the contents of that partition into the /boot directory on my root partition, and change my boot process to no longer mount the /boot partition and instead boot from my root partition. I would say I'm an intermediate Linux user, but I also learned most of what I know about GRUB when they were still in what they now call legacy GRUB. Since I am currently using GRUB2 I was hoping I could get a bit of help, seeing as my boot configuration is not the kind of thing I want to muck up while learning how to configure GRUB2 properly. Any help would be tremendous.
  #2  
Old 3rd November 2012, 05:45 AM
weitjong Offline
Registered User
 
Join Date: Oct 2006
Location: Singapore, 新加坡
Posts: 986
macossafari
Re: How to move /boot between partitions, under GRUB2

I think you need to boot into your system in rescue/recovery mode using Fedora installation media. Once you are in chroot shell, do this:

0. Before everything, backup.

1. Determine which partition has the current /boot mountpoint.
# lsblk

Let's just assume that /boot is mounted from, say, /dev/sda1 partition. Change this according to your own output.

2. Unmount the existing /boot partition.
# umount /boot

3. Mount partition temporarily to other mount point
# mount /dev/sda1 /mnt

4. Copy the content of "/boot partition" to "/boot directory".
# cp -a /mnt/* /boot

5. Tell the system not to automatically mount from /dev/sda1 partition to /boot mountpoint again.
# perl -pi.bak -e 's/(^.+\s+\/boot\s+)/#$1/g' /etc/fstab

Actually, it is easier to open /etc/fstab in vi (or using your favorite editor) and add a "#' to comment out the line that have "/boot" keyword.

6. Fix the grub2 menu entries. This will modify the grub.cfg in the new "/boot directory", which is exactly what we want.
# grub2-mkconfig -o /boot/grub2/grub.cfg

7. Reboot. If everything goes well, you should now boot from /boot directory. Double check that by using lsblk command again. You should not see /boot mountpoint anymore.

Note that we have not reclaimed the space of the "old" /boot partition yet. So, if the above does not work for you, you can still revert back easily. Good luck.
__________________
YaoWT - Leave no window unbroken ♪ (^。^) 

Last edited by weitjong; 4th November 2012 at 03:15 AM.
  #3  
Old 3rd November 2012, 06:24 AM
DBelton Offline
Administrator
 
Join Date: Aug 2009
Posts: 8,414
linuxfirefox
Re: How to move /boot between partitions, under GRUB2

Good instructions weitjong...

But, just to be certain, I would add a step to reinstall the bootloader as well..

In your step # 6 above, add the command to install the bootloader...

grub2-install /dev/sda
(The above assumes the bootloader was installed to the boot sector of the first hard drive.. adjust as necessary to match where yours is installed)

The grub2 bootloader will be looking for the grub.cfg file in the old /boot partition, and you need to reinstall it so it points to the new location.

Edit:

One other thing you should do BEFORE trying any of this...

Get you either a LiveCD or the install DVD. If something goes wrong, you can then boot from the LiveCD or DVD into recovery mode and fix the problems.

Last edited by DBelton; 3rd November 2012 at 06:31 AM.
  #4  
Old 3rd November 2012, 07:36 AM
weitjong Offline
Registered User
 
Join Date: Oct 2006
Location: Singapore, 新加坡
Posts: 986
macossafari
Re: How to move /boot between partitions, under GRUB2

Quote:
Originally Posted by DBelton View Post
One other thing you should do BEFORE trying any of this...

Get you either a LiveCD or the install DVD. If something goes wrong, you can then boot from the LiveCD or DVD into recovery mode and fix the problems.
Which is exactly why I ask him to do the steps in the rescue/recovery mode in my post earlier. All the steps that I mentioned above are actually doable in a normal system boot. I agree with you that any small wrong move then one would have to recover the system using the rescue/recovery mode anyway. So I reason it is good to get familiar with the recovery environment at the beginning of the steps.
__________________
YaoWT - Leave no window unbroken ♪ (^。^) 

Last edited by weitjong; 3rd November 2012 at 07:38 AM.
  #5  
Old 3rd November 2012, 09:21 PM
badwithnames Offline
Registered User
 
Join Date: Aug 2012
Location: Texas
Posts: 5
linuxchrome
Re: How to move /boot between partitions, under GRUB2

Thanks, weitjong and DBelton! It worked! I actually did it without recovery mode, and afterward I ran `yum install kernel` to get myself the latest kernel and allow yum to do the normal cleanup it does when I've deleted kernels in the past (to make more room for newer ones).
  #6  
Old 4th November 2012, 07:58 AM
weitjong Offline
Registered User
 
Join Date: Oct 2006
Location: Singapore, 新加坡
Posts: 986
macossafari
Re: How to move /boot between partitions, under GRUB2

You are welcome.

Quote:
Originally Posted by badwithnames View Post
... and afterward I ran `yum install kernel` to get myself the latest kernel ...
Lucky you .
__________________
YaoWT - Leave no window unbroken ♪ (^。^) 
  #7  
Old 8th March 2017, 04:10 AM
phurvitz Offline
Registered User
 
Join Date: Mar 2017
Location: United States
Posts: 1
windows_98_nt_2000chrome
Re: How to move /boot between partitions, under GRUB2

I originally had /boot as a subdir of / (i.e., on the same partition as /, rather than in its own partition). I wanted to create a separate /boot partition as part of making an mdadm raid 1.

I was able to update the book process by booting to the Centos 7 Live DVD.
During boot it is possible to specify options by tapping <TAB>. I edited the vmlinuz line to boot using root as /dev/sda1 which is where my copy of the original /boot directory was (rather than the default Live CD).

I then ran as root:
grub2-mkconfig -o /boot/grub2/grub.cfg
grub2-install /dev/sda

I also verified that the UUID of /dev/sda1 was listed in /boot/grub2/grub.cfg.

After that, the machine booted using the hard drive and everything seems to be in order.
  #8  
Old 8th March 2017, 10:02 AM
antikythera Offline
Administrator
 
Join Date: Dec 2013
Location: United Kingdom
Posts: 3,650
linuxfedorafirefox
Re: How to move /boot between partitions, under GRUB2

@phurvitz - welcome to the Fedora Forum, thanks for sharing your solution to moving boot to a separate partition. Please don't necro-post though, with which in mind this thread is closed.

If you need any assistance with an issue relating to a Fedora installation and can only find threads of this vintage, feel free to start a new one of your own.
__________________
Download, Install and Share Fedora - Official ISO Torrents | Live ISO Respins containing post-release updates
Closed Thread

Tags
grub2, or boot, partitions

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Grub2 boot menu F/16 KDE rich52 Using Fedora 2 8th February 2013 05:48 AM
[SOLVED] F17 upgrade does not boot with grub2 janvlug Installation, Upgrades and Live Media 0 19th June 2012 07:27 AM
[SOLVED] How do I fix grub2 boot? splatt Using Fedora 0 8th December 2011 01:22 AM
can move partitions in Fedora 5? knot2afrayed Using Fedora 9 24th September 2006 02:53 AM


Current GMT-time: 04:15 (Tuesday, 28-03-2017)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat