Issue
- Need to move smaller /boot partition to some another disk containing larger partition for /boot
- Need larger space reserved before the first partition for leapp
Environment
- CloudLinux 7
- CloudLinux 8
- CloudLinux 9
Solution
Let's assume two disks: /dev/sda
and /dev/sdb
. Follow the steps bellow to migrate the /boot
partition from /dev/sda
to a new device /dev/sdb
.
First, we create the new /dev/sdb1
partition on /dev/sdb
. We also need to make sure that we have a post-MBR gap (unallocated space) where grub will be installed. We will leave 1MiB
of unallocated space at the start of the device which is the size used during installation. If there is no partition table on this device, create it:
parted /dev/sdb mklabel msdos
Note: Please make sure that there is no data present on disk /dev/sdb
, as the following procedure will re-create a new disk label on it and a new partition will be created on disk /dev/sdb
, thus it would erase any previous data present on it.
Instructions
1. Create the partition:
parted /dev/sdb mkpart p ext4 1MiB 1024MiB
2. Format the new partition with a filesystem:
mkfs.ext4 /dev/sdb1
3. Mount the filesystem on /mnt
and copy files from /boot
:
mount /dev/sdb1 /mnt
rsync -avh /boot/ /mnt/
4. Install the grub bootloader on the device:
grub2-install --boot-directory=/mnt /dev/sdb
This is what writes to the post-MBR gap which we made sure to have in step 1.
5. Update /etc/fstab
.
- Change the relevant entry for the boot filesystem so that it uses the new partition. If you are using UUIDs to identify the filesystem in
/etc/fstab
, you can find the UUID for the new filesystem withblkid /dev/sdb1
:
# blkid /dev/sdb1
/dev/sdb1: UUID="9143bc94-1047-4bd7-b77d-ba393cbc71aa" TYPE="ext4"
- Your fstab should contain new record with /boot mount point.
#
# /etc/fstab
# Created by anaconda on Fri Jun 7 07:24:04 2024
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=9143bc94-1047-4bd7-b77d-ba393cbc71aa /boot ext4 defaults 1 1
UUID=09b031ab-69aa-448b-9e50-ba873b84a47f / ext4 defaults 1 1
- Verify that fstab is correct using
mount -a
command.
6. Reboot the system.
- Go into
BIOS
settings, change the boot priority from disk/dev/sda
to/dev/sdb
and start the booting process. At this point, the system will boot using the new boot filesystem. Inspect/df -h
to verify that the new filesystem (/dev/sdb1
is mounted on/boot
).
[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 1.9G 0 1.9G 0% /dev
tmpfs 1.9G 0 1.9G 0% /dev/shm
tmpfs 1.9G 8.6M 1.9G 1% /run
tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup
/dev/sda2 28G 3.6G 23G 14% /
/dev/sdb1 989M 149M 773M 17% /boot
tmpfs 379M 0 379M 0% /run/user/0
- After rebooting with the new boot filesystem, and before removing the old files, we need to recreate the grub2 configuration:
# grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-3.10.0-962.3.2.lve1.5.85.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-962.3.2.lve1.5.85.el7.x86_64.img
Found linux image: /boot/vmlinuz-3.10.0-962.3.2.lve1.5.39.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-962.3.2.lve1.5.39.el7.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-0dc80a294c104df681af2d521f3f3eac
Found initrd image: /boot/initramfs-0-rescue-0dc80a294c104df681af2d521f3f3eac.img
done
Comments
0 comments
Please sign in to leave a comment.