Thiết lập phần cứng để testing mainline kernel mới trên điện thoại sử dụng GNU/Linux làm OS

ducphilykha

New member
** Cách viết tập lệnh cập nhật kernel cho GNU/Linux **

GNU/Linux chạy hạt nhân chính với 2 phần chính: kernel và rootfs.

* Kernel chứa /khởi động, /mô -đun, /nhà cung cấp firmware, v.v.
* Rootfs chứa X11, Wayland, Shell và Phần mềm, v.v.

Chúng tôi có thể cập nhật và nâng cấp rootfs, nhưng khi một kernel mới được phát hành, nhà phát triển kernel phải cài đặt lại toàn bộ hệ thống, rất tốn thời gian.

Để tiết kiệm thời gian, chúng ta có thể sử dụng lại rootfs và chỉ thay đổi /khởi động trong phân vùng khởi động và /mô -đun trong rootfs.

Trong bài viết này, tôi sẽ chỉ cho bạn cách viết tập lệnh để tự động hóa quá trình cập nhật kernel.

## Điều kiện tiên quyết

Bạn sẽ cần những điều sau đây để làm theo cùng với hướng dẫn này:

* Một hệ thống Linux có hạt nhân hoạt động
* Công cụ dòng lệnh `git`
* Công cụ dòng lệnh `make`
* Công cụ dòng lệnh `wget`

## Bước 1: Bản sao kho lưu trữ Postmarketos

Bước đầu tiên là sao chép kho lưu trữ postmarketos.Kho lưu trữ này chứa các hình ảnh cho thiết bị trong cộng đồng.

`` `
Git Clone https://github.com/postmarketos/pmbootstrap.git
`` `

## Bước 2: Tải xuống hạt nhân mới

Bước tiếp theo là tải xuống kernel mới.Bạn có thể làm điều này bằng cách chạy lệnh sau:

`` `
wget https://doad.postmarketos.org/kernel/latest/zimage
`` `

## Bước 3: Trích xuất hạt nhân

Khi kernel đã được tải xuống, bạn cần trích xuất nó.Bạn có thể làm điều này bằng cách chạy lệnh sau:

`` `
TAR -XVF Zimage
`` `

## Bước 4: Sao chép hạt nhân vào phân vùng khởi động

Bước tiếp theo là sao chép kernel vào phân vùng khởi động.Bạn có thể làm điều này bằng cách chạy lệnh sau:

`` `
CP Zimage /Boot /Zimage
`` `

## Bước 5: Cập nhật initRAMFS

Bước cuối cùng là cập nhật initRAMFS.Bạn có thể làm điều này bằng cách chạy lệnh sau:

`` `
tạo mô -đun -c/boot/grub/i386 -pc/devicetree
`` `

## Đó là nó!

Bây giờ bạn đã cập nhật thành công kernel của bạn.Bạn có thể khởi động lại hệ thống của mình và kernel mới sẽ được tải.
=======================================
**How to write a kernel update script for GNU/Linux**

GNU/Linux runs the mainline kernel with 2 main parts: Kernel and Rootfs.

* The Kernel contains /boot, /module, /firmware vendor, etc.
* The Rootfs contains X11, Wayland, Shell and software, etc.

We can update and upgrade the Rootfs, but when a new Kernel is released, the kernel developer has to reinstall the whole system, which is very time-consuming.

To save time, we can reuse the Rootfs and only change /boot in the boot partition and /modules in the Rootfs.

In this article, I will show you how to write a script to automate the kernel update process.

## Prerequisites

You will need the following to follow along with this tutorial:

* A Linux system with a working kernel
* The `git` command-line tool
* The `make` command-line tool
* The `wget` command-line tool

## Step 1: Clone the PostmarketOS repository

The first step is to clone the PostmarketOS repository. This repository contains the images for the device in the Community.

```
git clone https://github.com/postmarketos/pmbootstrap.git
```

## Step 2: Download the new kernel

The next step is to download the new kernel. You can do this by running the following command:

```
wget https://download.postmarketos.org/kernel/latest/zImage
```

## Step 3: Extract the kernel

Once the kernel has been downloaded, you need to extract it. You can do this by running the following command:

```
tar -xvf zImage
```

## Step 4: Copy the kernel to the boot partition

The next step is to copy the kernel to the boot partition. You can do this by running the following command:

```
cp zImage /boot/zImage
```

## Step 5: Update the initramfs

The final step is to update the initramfs. You can do this by running the following command:

```
make -C /boot/grub/i386-pc/devicetree modules
```

## That's it!

You have now successfully updated your kernel. You can reboot your system and the new kernel will be loaded.
 
Join Telegram ToolsKiemTrieuDoGroup
Back
Top