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 explanation of how to reduce memory usage in MySql

Preface By default, MySQL will initialize a large...

Sending emails in html is easy with Mailto

Recently, I added a click-to-send email function t...

JS+Canvas draws a lucky draw wheel

This article shares the specific code of JS+Canva...

Tutorial on installing and uninstalling python3 under Centos7

1. Install Python 3 1. Install dependency package...

Vue implements simple calculator function

This article example shares the specific code of ...

The HTML 5 draft did not become a formal standard

<br />Yesterday I saw at W3C that the new HT...

Develop a vue component that encapsulates iframe

Table of contents 1. Component Introduction 2. Co...

JavaScript to implement simple carousel chart most complete code analysis (ES5)

This article shares the specific code for JavaScr...

Vue.js implements simple folding panel

This article example shares the specific code of ...

How to install Composer in Linux

1. Download the installation script - composer-se...

How to execute Linux shell commands in Docker

To execute a shell command in Docker, you need to...

Quickly solve the problem that the mysql57 service suddenly disappeared

one, G:\MySQL\MySQL Server 5.7\bin> mysqld --i...

About the problem of offline installation of Docker package on CentOS 8.4

The virtual machine used is CentOS 8.4, which sim...