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

How to encapsulate axios in Vue

Table of contents 1. Installation 1. Introduction...

How to set static IP for Ubuntu 18.04 Server

1. Background Netplan is a new command-line netwo...

Docker link realizes container interconnection

Table of contents 1.1. Network access between con...

A brief analysis of the function calling process under the ARM architecture

Table of contents 1. Background knowledge 1. Intr...

The perfect solution to the Chinese garbled characters in mysql6.x under win7

1. Stop the MySQL service in the command line: ne...

Disabled values ​​that cannot be entered cannot be passed to the action layer

If I want to make the form non-input-capable, I se...

Detailed steps for creating a Vue scaffolding project

vue scaffolding -> vue.cli Quickly create a la...

MySQL export of entire or single table data

Export a single table mysqldump -u user -p dbname...

Detailed explanation of the installation process of Jenkins on CentOS 7

Install Jenkins via Yum 1. Installation # yum sou...

Introduction and use of Javascript generator

What is a generator? A generator is some code tha...

Detailed steps to install Sogou input method on Ubuntu 20.04

1. Install Fcitx input framework Related dependen...

MySQL Index Detailed Explanation

Table of contents 1. Index Basics 1.1 Introductio...

Detailed explanation of Angular structural directive modules and styles

Table of contents 1. Structural instructions Modu...

Basic knowledge of website design: newbies please read this

Now many people are joining the ranks of website ...