Introduction to the process of extending the boot partition in Kylin 4.0.2 (Ubuntu)

Introduction to the process of extending the boot partition in Kylin 4.0.2 (Ubuntu)

Preface

In some cases (such as developing kernel modules), we need to install multiple versions of the kernel. At this time, the problem of insufficient boot partition space may occur. This article describes how to expand the boot partition of Kylin (4.0.2).

Since the boot partition is usually located in the first partition of the disk, it is difficult to expand it directly. Therefore, the new partition is used to replace the original partition to indirectly expand the boot partition. Please note that replacing the boot partition is risky. Please evaluate the risks and proceed with caution.

1. Prepare new partitions

If it is a virtual machine, you can directly add a virtual disk. If it is a physical machine, you can clean up an unused partition from the existing disk and format it with a disk tool (such as parted).

If the disk is in msdos format, the new partition must be primary. How to use Disk Utility is not described here. Assume that the new partition is /dev/newpart (your new partition will definitely not be called this name), format it using mkfs:

mkfs.ext4 /dev/newpart

2. Copy the boot partition

First mount the new partition to a directory, such as /mnt:

mount /dev/newpart /mnt

Then copy all the files in /boot to the mounted directory:

cp –a /boot/* /mnt

3. Modify the fstab file

Use the command blkid or lsblk –f to view the UUID of the new partition and write it down. Modify the /etc/fstab file with root privileges, replace the partition UUID corresponding to the original boot partition with the UUID of the new partition, save the file and exit. Before restarting, you can use:

systemctl daemon-reload
mount –a
lsblk

Confirm in turn that the configuration file has been modified correctly, the new partition can be loaded normally, and restart the system. The purpose of restarting is to allow the system to recognize the new boot partition and then automatically update grub.

4. Update grub

Use the update-grub command to update grub and open /boot/grub/grub.cfg to confirm that the kernel and driver are loaded from the new partition. The yellow line in the figure below should be the UUID of the new partition. The figure only lists the contents of one startup item. If there are multiple startup items, you can check them one by one.

But usually if the first one is correct, the following ones should also be correct.

In theory, you can then let the BIOS or UEFI boot from the new partition, but unfortunately, even if the boot attribute of the new partition is set to on, it may not be able to boot from the new partition during boot (it may also be a problem with my operation). To solve this problem, we still retain the original boot partition that was replaced, and

Copy the new grub configuration file to the grub directory of the original partition. In this way, the operating system will still start from the original boot partition, but because the new grub configuration file points the location of the kernel and driver files to the new disk partition, the kernel and driver files under the original partition can be deleted.

The problem is solved. Assuming that the original boot partition is mounted under /dev/oldpart, remount the original partition to copy the grub.cfg file:

mount /dev/oldpart /mnt
cp /boot/grub/grub.cfg /mnt/grub/

Check /mnt/grub/grub.cfg and confirm that everything is correct. You can now restart the operating system. After booting, you can enter the corresponding startup item in the grub boot interface to further confirm the correctness of the boot partition replacement.

If everything goes well when booting, after entering the system, you can use df –h to view the utilization of the new boot partition. In addition, if you want to further save disk space, you can delete the kernel and driver files in the original boot partition.

If you do not delete it, there will be no impact, because subsequent operations such as adding a new kernel will not use the original boot partition.

It is worth mentioning that if a new kernel is added later, after executing update-grub to generate a new /boot/grub/grub.cfg, don't forget to copy the file to the grub directory under the original boot partition, otherwise the corresponding kernel will not be visible in the grub startup interface.

Because we are still booting from the original partition, the grub boot interface displays the grub.cfg in the original boot partition.

This is the end of this article about the process of extending the boot partition of Kylin 4.0.2 (Ubuntu). For more information about extending the boot partition of Kylin Ubuntu, please search the previous articles of 123WORDPRESS.COM or continue to browse the related articles below. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • How to add a swap partition in Ubuntu
  • Introduction to partitioning the root directory of Ubuntu with Vmvare virtual machine

<<:  Implementation of CSS3 button border animation

>>:  Understanding of CSS selector weight (personal test)

Recommend

Detailed description of the use of advanced configuration of Firewalld in Linux

IP masquerading and port forwarding Firewalld sup...

In-depth understanding of the seven communication methods of Vue components

Table of contents 1. props/$emit Introduction Cod...

Detailed explanation of the failure of MySQL to use UNION to connect two queries

Overview UNION The connection data set keyword ca...

MySQL 5.7 installation and configuration tutorial

This article shares the MySQL installation and co...

Vue implements a movable floating button

This article example shares the specific code of ...

Mysql master-slave synchronization Last_IO_Errno:1236 error solution

What is the reason for the Last_IO_Errno:1236 err...

HTML special character conversion table

character Decimal Character Number Entity Name --...

docker cp copy files and enter the container

Enter the running container # Enter the container...

In-depth reading and practice records of conditional types in TypeScript

Table of contents Using conditional types in gene...

Understanding and usage scenarios of ES6 extension operators

Table of contents 1. Replace the apply method, ge...

Detailed explanation of keepAlive usage in Vue front-end development

Table of contents Preface keep-avlive hook functi...

HTML table markup tutorial (14): table header

<br />In HTML language, you can automaticall...

Let’s talk in detail about how browsers view closures

Table of contents Preface Introduction to Closure...