How to extend /boot partition in SafeSquid

General Information about how to make best use of this forum
India Pratik
Posts: 25
Joined: Fri Jun 10, 2022 7:15 am

How to extend /boot partition in SafeSquid

Post by Pratik » Fri Aug 12, 2022 11:14 am

The older version of the SafeSquid ISO installer suggests a default partition layout with /boot partition size of 232 megabytes.
This was sufficient for older versions of the operating system (older than ubuntu 18.04 LTS) however, with newer versions of ubuntu /boot partitions get utilized rather quickly.
Example of an obsolete filesystem structure.
old_fs.JPG
old_fs.JPG (97.76 KiB) Viewed 1490 times
Moreover /boot partition gets populated with old kernel modules and other leftover upgrades.
SafeSquid ISO installs, which are not recent may have issues with /boot partition utilized to 100%

This can prevent system updates and security patches essential for server security.
Example of such an error.

Code: Select all

Preparing to unpack .../06-libcupsimage2_2.2.7-1ubuntu2.9_amd64.deb ...
Unpacking libcupsimage2:amd64 (2.2.7-1ubuntu2.9) over (2.2.7-1ubuntu2.8) ...
Preparing to unpack .../07-libcups2_2.2.7-1ubuntu2.9_amd64.deb ...
Unpacking libcups2:amd64 (2.2.7-1ubuntu2.9) over (2.2.7-1ubuntu2.8) ...
Preparing to unpack .../08-libmagickcore-6.q16-3-extra_8%3a6.9.7.4+dfsg-16ubuntu6.13_amd64.deb ...
Unpacking libmagickcore-6.q16-3-extra:amd64 (8:6.9.7.4+dfsg-16ubuntu6.13) over (8:6.9.7.4+dfsg-16ubuntu6.12) ...
Selecting previously unselected package linux-modules-4.15.0-188-generic.
Preparing to unpack .../09-linux-modules-4.15.0-188-generic_4.15.0-188.199_amd64.deb ...
Unpacking linux-modules-4.15.0-188-generic (4.15.0-188.199) ...
dpkg: error processing archive /tmp/apt-dpkg-install-DPzMI2/09-linux-modules-4.15.0-188-generic_4.15.0-188.199_amd64.deb (--unpack):
 cannot copy extracted data for './boot/System.map-4.15.0-188-generic' to '/boot/System.map-4.15.0-188-generic.dpkg-new': failed to write (No space left on device)
Attached is a complete log for detailed analysis.
error.txt
(12.83 KiB) Downloaded 47 times
In a newer version of SafeSquid ISO install, the problem of a smaller boot partition has been resolved.
/boot is configured to have comparatively large disk space.
Example of existing filesystem structure.
new_fs.jpg
new_fs.jpg (91.59 KiB) Viewed 1443 times
Workaround for users with older installs and smaller boot partitions can extend their /boot partition size.
Below is a guide on how to extend your /boot partitions.

How to extend /boot partition for an older version of SafeSquid install
(Note: Test for extending /boot portion was performed on newer SafeSquid install as we do not have SafeSquid with the older install, although execution remains similar.)
Default filesystem for SafeSquid ISO install
unaltered.jpg
unaltered.jpg (86.39 KiB) Viewed 1487 times
Add a new disk with a minimum of 2GB and a maximum of 5GB to your SafeSquid server.
(Note: Adding a new disk will not be covered here, you can find resources online to achieve the same based on your system type)

Validate disk status.

Code: Select all

lsblk
- List all storage devices.
For me, after adding a new storage device, the existing sda storage device is now referred to as sdb and new storage device is referred to as sda
Slide1.JPG
Slide1.JPG (96.57 KiB) Viewed 1509 times
Create a new filesystem of type ext4.
(Note: In this example, the new storage device is referred to as sda and the existing boot partition is referred to as /dev/sdb1.
If you are following this guide please make sure that you have selected the appropriate partitions before performing any given task.)

Code: Select all

 mkfs.ext4 /dev/<sda> 
Slide2.JPG
Slide2.JPG (59.42 KiB) Viewed 1509 times
Create new directory in /usr/local/src/old_boot for mounting old boot partition.

Code: Select all

mkdir -p /usr/local/src/old_boot

Code: Select all

umount /dev/<sdb1> ; mount /dev/sdb1 /usr/local/src/old_boot
Slide3.JPG
Slide3.JPG (33.62 KiB) Viewed 1509 times
Mount new partition to /boot directory

Code: Select all

mount /dev/<sda> /boot
use rsync to copy all files with their permissions from the old boot directory to the new boot directory.

Code: Select all

rsync  -avz /usr/local/src/old_boot /boot
Slide4.JPG
Slide4.JPG (57.81 KiB) Viewed 1509 times
Edit /etc/fstab to modify the UUID of /boot directory.
To get the UUID of your storage device, use the below command.

Code: Select all

 blkid| grep /dev/<sda>| awk '{print $2}' | awk -F = '{print $2}' | awk -F \" '{print $2}'
copy UUID and edit /etc/fstab file.
Slide5.JPG
Slide5.JPG (34.97 KiB) Viewed 1509 times

Code: Select all

vim /etc/fstab
Slide8.JPG
Slide8.JPG (115.14 KiB) Viewed 1502 times
Hit "Esc" and

Code: Select all

:wq!
to save and exit from vim.
restart your server.
Validate if /dev/sda has automounted in /boot directory.

Code: Select all

lsblk
Slide9.JPG
Slide9.JPG (100.35 KiB) Viewed 1509 times
Executing the below command if you have any unattended updates

Code: Select all

apt update && apt upgrade -y
The system should now update without any errors.
Slide1.JPG
Slide1.JPG (54.7 KiB) Viewed 1499 times