help-grub
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Moving /boot to another partition


From: Xen
Subject: Re: Moving /boot to another partition
Date: Tue, 11 Oct 2016 21:31:41 +0200
User-agent: Roundcube Webmail/1.2.0

Martin schreef op 11-10-2016 20:13:
Hi Grub-Team,
I have ubuntu 16.04 and my /boot directory has become too small (only
150MB) so I want to move it. For this I need some help.
I asked in ubuntuforums.org and askubuntu.com, but nobody could help.

/boot is on a separate ext4 partition with 150MB.
"/" is on a btrfs partition with 40GB.

My thoughts how to solve this:

    -create /boot2 on btrfs
    -copy all files from /boot to /boot2
    -unmount /boot
    -rename /boot2 to /boot
    -run grub-install /dev/sdb5   # ?

I'm not sure about the device for grub-install.
Is it the device where the grub partition is (sdb1) or is it the
device where /boot is (sdb5)?

The device will simply be /dev/sdb

The device chosen as the location of your grub files is going to be the devices that is mounted at /boot during the running of update-grub (grub-mkconfig).

You won't be able to .... rename directories... while they are mounted.

1. create a /boot2 directory (or whatever) on btrfs (if grub can handle that)
2. copy the files
3. unmount /boot
4. rmdir /boot
5. rename /boot2 /boot
6. run grub-install /dev/sdb

Well, almost the same ;-).


    Number  Start   End     Size    File system     Name      Flags
     1      1049kB  316MB   315MB                   bios      bios_grub
     2      316MB   473MB   157MB   ext4            boot
     3      473MB   8862MB  8389MB  linux-swap(v1)  swap
     5      8862MB  50,6GB  41,8GB  btrfs           root
     4      50,6GB  120GB   69,2GB  btrfs           home
     6      120GB   120GB   210MB   fat32           exchange  msftdata

What you can also do is delete the first and second partition after saving your files.

Or:

parted /dev/sdb resizepart 1 6143s # turns your bios boot partition into just 2 MB which is all it needs
tar -cvzf /tmp/boot-files.tgz /boot
umount /boot
parted /dev/sdb rmpart 2
parted /dev/sdb mkpart primary 6144s $( parted /dev/sdc unit s p | grep "^ 3" | awk '{print substr($2,1,length($2)-1) - 1}' )s

Parted is not an easy tool to use.

The above would resized your bios boot partition to 2MB, then delete your regular boot partition and then recreate it using "3MB" as the starting sector (6144s) and the last available sector before your swap partition as the ending sector.

It might be much easier to do that with cfdisk.

Then:

mkfs.ext4 /dev/sdb2 (if it has number 2 now, because I'm not sure)
tar -xvzf /tmp/boot-files.tgz -C /

update-grub / grub-mkconfig (however you do it).

Or maybe grub-install, I never know.

Also fix the entry for /boot in fstab.


You would end up with:

     1      1049kB  3145kB  2097kB                  bios      bios_grub
     2      3145kB  473MB   470MB   ext4            boot
     3      473MB   8862MB  8389MB  linux-swap(v1)  swap
     5      8862MB  50,6GB  41,8GB  btrfs           root
     4      50,6GB  120GB   69,2GB  btrfs           home
     6      120GB   120GB   210MB   fat32           exchange  msftdata

As long as the numbers are still correct (number 2). I believe you can reorder partition numbers but that would also reorder 5 and 4.


What I mean is: your bios boot partition doesn't need to be so big. You can shrink it and then grow the boot partition by deleting it and recreating it anew. Then it will suddenly be 470MB in size and you don't need to worry about putting it on btrfs or elsewhere.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]