This article explains how to move the boot partition to another storage disk partition in CloudLinux.
Issue:
- The current /boot partition is too small and needs to be migrated to a larger partition on another disk.
- A larger reserved space is required before the first partition for leapp.
Note: This process applies to CloudLinux 7, CloudLinux 8, and CloudLinux 9 environments.
Solution:
We assume two disks: /dev/sda (existing boot partition) and /dev/sdb (new storage disk). Follow these steps to migrate the /boot partition from /dev/sda to /dev/sdb.
- Create a New Partition on /dev/sdb
- Ensure there is unallocated space at the beginning of /dev/sdb for the GRUB bootloader. If there is no partition table, create one:
parted /dev/sdb mklabel msdos
Note: Ensure /dev/sdb has no important data, as this process will erase existing data.
- Create the new /boot partition:
parted /dev/sdb mkpart primary ext4 1MiB 1024MiB
- Ensure there is unallocated space at the beginning of /dev/sdb for the GRUB bootloader. If there is no partition table, create one:
- Format the New Partition
Format /dev/sdb1 with the ext4 filesystem:mkfs.ext4 /dev/sdb1
- Copy Boot Files to the New Partition
Mount /dev/sdb1 and copy the contents of /boot:mount /dev/sdb1 /mnt rsync -avh /boot/ /mnt/
- Install GRUB on the New Disk
Install the GRUB bootloader onto /dev/sdb:grub2-install --boot-directory=/mnt /dev/sdb
This writes the necessary bootloader files into the reserved space created earlier.
- Update /etc/fstab
- Modify /etc/fstab to reflect the new boot partition. Retrieve the UUID of /dev/sdb1:
blkid /dev/sdb1
- Sample output:
/dev/sdb1: UUID="9143bc94-1047-4bd7-b77d-ba393cbc71aa" TYPE="ext4"
- Edit /etc/fstab to include:
UUID=9143bc94-1047-4bd7-b77d-ba393cbc71aa /boot ext4 defaults 1 1
- Verify the changes:
mount -a
- Modify /etc/fstab to reflect the new boot partition. Retrieve the UUID of /dev/sdb1:
- Reboot and Change Boot Priority
- Restart the system.
- Enter BIOS settings and set /dev/sdb as the primary boot disk.
- Boot the system and verify that the new partition is mounted:
df -h
- Expected output should display /dev/sdb1 mounted as /boot:
Filesystem Size Used Avail Use% Mounted on /dev/sdb1 989M 149M 773M 17% /boot
- Recreate GRUB Configuration
- Before deleting the old /boot files, regenerate the GRUB configuration:
grub2-mkconfig -o /boot/grub2/grub.cfg
- Sample output:
Generating grub configuration file ... Found linux image: /boot/vmlinuz-... Found initrd image: /boot/initramfs-...
- Done
- Before deleting the old /boot files, regenerate the GRUB configuration:
Your system is now successfully using the new /boot partition. You can safely remove the old boot files if everything is working correctly.