導航:首頁 > 源碼編譯 > debian10內核編譯

debian10內核編譯

發布時間:2023-06-10 09:08:45

A. Debian 雙網卡配置

Debian可通過以下步驟配置網卡:

1、將當前目錄切換到網卡配置文件所在的目錄,網卡配置文件所在的目錄為「/etc/network/」。使用「cd /etc/network」命令切換到網卡配置文件所在目錄;

2、使用nano編輯器或者vim編輯器,編輯網卡配置文件(interfaces),在當前目錄下執行命令"nano interfaces"即可編輯網卡配置文件的內容;

3、使用「Ctrl + O」組合鍵保存網卡配置文件內容,使用「Ctrl + X」組合鍵退出nano編輯器。使用「cat interfaces」命令查看已修改的網卡配置文件的內容;

4、使用「/etc/init.d/networking restart」命令使用網卡配置文件內容生效,並使用「ifconfig」命令查看網卡eth0網卡的ip地址;

5、使用nano保存、退出組合鍵保存文件內容。使用網卡重啟命令重啟即可獲取到IP地址。

# This file describes the network interfaces availableon your system

# and how to activate them. For more information, see interfaces(5).

#/etc/network/interfaces

# The loopback network interface

auto lo

iface lo inet loopback

auto eth0

iface eth0 inet static

address 192.168.1.116

netmask 255.255.255.0

gateway 192.168.1.2

auto eth0:1

iface eth0:1 inet static

address 192.168.1.135

netmask 255.255.255.0

gateway 192.168.1.2

1命令

uname -r                                                        //查看內核

lsb_release -a  //所有版本信息

cat /etc/debian_version                               //查看deb

B. ubuntu內核編譯需要多長時間

在分析linux內核源碼的過程中,要是能夠修改內核源碼並運行修改後的內核,我想肯定是令人高興的事,哪怕第一次修改僅僅是在啟動時列印一行"Hello, Wang Jiankun!",肯定也是令我高興的。為了能成功編譯修改後的內核,今天先編譯一遍內核。
為了有一個完整的記錄,今天的起點是一台裸機。
1、在裸機上安裝一個最小的debian系統
為了能夠盡可能清晰的顯示編譯一個內核所需要的組件,在安裝系統時,僅僅安裝最小系統,然後需要什麼,就使用apt-get安裝什麼。
使用網路安裝,在安裝過程中出現Software selection界面時不要選擇任何選項,這樣安裝的系統將是最小的系統。
為了使用ssh遠程登錄,最小系統安裝完成後,要安裝ssh伺服器並且要設置靜態ip地址(debian安裝過程中是通過dhcp獲取的ip地址)。
2、安裝ssh伺服器
apt-get install ssh
3、設置靜態ip地址
修改文件/etc/network/interfaces,其中藍色部分是增加的,紅色部分是屏蔽掉的,黑色部分是沒有變化的。
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
allow-hotplug eth0
# Wang Jiankun commented the following line
#iface eth0 inet dhcp
# Wang Jiankun added the the following lines
iface eth0 inet static
address 192.168.1.251
netmask 255.255.255.0
broadcast 192.168.1.255
network 192.168.1.0
gateway 192.168.1.1
重啟系統後,修改將生效。
4、通過wget下載linux內核源碼
administrator@wangjk:~/kernel$ wget http://kernel.org/pub/linux/kernel/v2.6/linux-2.6.19.tar.bz2
5、解壓文件linux-2.6.19.tar.bz2
administrator@wangjk:~/kernel$ tar jxf linux-2.6.19.tar.bz2
tar: bzip2: Cannot exec: No such file or directory
tar: Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error exit delayed from previous errors
administrator@wangjk:~/kernel$
看來是沒有bzip2這個包,那就安裝一個:
apt-get install bzip2
6、安裝debian的kernel-package軟體包
在安裝kernel-package軟體包時,最好使用命令:apt-get build-dep kernel-package,而不要使用命令:
apt-get install kernel-package,後者安裝的軟體包是前者的子集,使用後者安裝kernel-package軟體包後,執行make menuconfig命令會出現頭文件找不到的錯誤,如下所示:
administrator@wangjk:~/kernel/linux-2.6.19$ make menuconfig
HOSTCC scripts/basic/fixdep
scripts/basic/fixdep.c:105:23: error: sys/types.h: No such file or directory
scripts/basic/fixdep.c:106:22: error: sys/stat.h: No such file or directory
scripts/basic/fixdep.c:107:22: error: sys/mman.h: No such file or directory
scripts/basic/fixdep.c:108:20: error: unistd.h: No such file or directory
scripts/basic/fixdep.c:109:19: error: fcntl.h: No such file or directory
scripts/basic/fixdep.c:110:20: error: string.h: No such file or directory
scripts/basic/fixdep.c:111:20: error: stdlib.h: No such file or directory
scripts/basic/fixdep.c:112:19: error: stdio.h: No such file or directory
主要是因為libc6-dev軟體包沒有安裝。所以即使使用了apt-get install kernel-package還得使用apt-get build-dep kernel-package,不如一次使用apt-get build-dep kernel-package完成方便。
7、安裝libncurses5-dev軟體包來支持make menuconfig
通過apt-get build-dep kernel-package安裝完成kernel-package後,執行make menuconfig仍然報錯,如下所示:
administrator@wangjk:~/kernel/linux-2.6.19$ make menuconfig
HOSTCC scripts/kconfig/lxdialog/checklist.o
In file included from scripts/kconfig/lxdialog/checklist.c:24:
scripts/kconfig/lxdialog/dialog.h:32:20: error: curses.h: No such file or directory
In file included from scripts/kconfig/lxdialog/checklist.c:24:
scripts/kconfig/lxdialog/dialog.h:97: error: expected specifier-qualifier-list before 'chtype'
scripts/kconfig/lxdialog/dialog.h:187: error: expected ')' before '*' token
scripts/kconfig/lxdialog/dialog.h:193: error: expected ')' before '*' token
scripts/kconfig/lxdialog/dialog.h:195: error: expected ')' before '*' token
scripts/kconfig/lxdialog/dialog.h:196: error: expected ')' before '*' token
scripts/kconfig/lxdialog/dialog.h:197: error: expected ')' before '*' token
scripts/kconfig/lxdialog/dialog.h:198: error: expected ')' before '*' token
scripts/kconfig/lxdialog/dialog.h:200: error: expected ')' before '*' token
scripts/kconfig/lxdialog/checklist.c:31: error: expected ')' before '*' token
scripts/kconfig/lxdialog/checklist.c:59: error: expected ')' before '*' token
scripts/kconfig/lxdialog/checklist.c:95: error: expected ')' before '*' token
[省略其後部分]
原來是最小系統不支持圖形的原因,安裝libncurses5-dev後即可。
8、將系統的config文件拷貝到內核目錄下
cp /boot/config-2.6.18-6-686 ./.config
9、執行make menuconfig
雖然是將原來系統的config文件拷貝過來的,但是如果所以的配置都採用默認的配置仍然會有問題,在我的系統上在載入文件系統時會死掉,所以還是要做必要的配置,主要是將scsi和sata部分編譯進內核而不要編譯成模塊,如下所示:
Device Drivers --->
Serial ATA (prod) and Parallel ATA (experimental) drivers --->
SCSI device support --->
將藍色兩部分級聯的選項全部編譯進內核(其實沒有必要全部,但為了簡單起見,暫時這樣做)。
10、安裝fakeroot軟體包
11、編譯內核
fakeroot make-kpkg --initrd --revision=custom.1.0 kernel_image
12、安裝內核
wangjk:/home/administrator/kernel# dpkg -i linux-image-2.6.19_custom.1.0_i386.deb
Selecting previously deselected package linux-image-2.6.19.
(Reading database ... 17679 files and directories currently installed.)
Unpacking linux-image-2.6.19 (from linux-image-2.6.19_custom.1.0_i386.deb) ...
Done.
Setting up linux-image-2.6.19 (custom.1.0) ...
Running depmod.
Finding valid ramdisk creators.
Using mkinitramfs-kpkg to build the ramdisk.
Running postinst hook script /sbin/update-grub.
You shouldn't call /sbin/update-grub. Please call /usr/sbin/update-grub instead!
Searching for GRUB installation directory ... found: /boot/grub
Searching for default file ... found: /boot/grub/default
Testing for an existing GRUB menu.lst file ... found: /boot/grub/menu.lst
Searching for splash image ... none found, skipping ...
Found kernel: /boot/vmlinuz-2.6.19
Found kernel: /boot/vmlinuz-2.6.18-6-686
Updating /boot/grub/menu.lst ... done
13、重啟系統引導新內核後查看版本號
administrator@wangjk:~$ cat /proc/version
Linux version 2.6.19 (root@wangjk) (gcc version 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)) #1 SMP Thu May 7 21:52:10 CST 2009
administrator@wangjk:~$
可以看出已經是我編譯的內核了。

本文來自CSDN博客,轉載請標明出處:http://blog.csdn.net/jiankun_wang/archive/2009/05/04/4147806.aspx

------------------------------------

ubuntu不帶linux內核源碼,需要自己下載安裝。
1,查看自己的內核版本
uname -r
2,查看源內的內核源碼類表
apt-cache search linux-source
3,下載安裝內核源代碼
sudo apt-get install linux-source-2.6.27 //我選的是這一個,自己看著辦吧
4,等待........

下載完成後,在/usr/src下會有一個文件名為linux-source-2.6.xx.tar.bz2的壓縮
5,解壓縮包
tar jxvf linux-source-2.6.27.tar.bz2 //看清自己的版本

解壓後會生成一個源代碼目錄/usr/src/linux-source-2.6.27
6,進入源碼目錄後,配置文件
make oldconfig
7,生成內核
make
8,瘋狂等待,大約1個多小時

9,編譯模塊
make moles
10,安裝模塊
make moles_install

大功告成!^_^
下面說一下Makefile文件

$(MAKE) -C $(KERNELDIR) M=$(PWD) moles_install #PWD當前工作目錄的變數
obj-m := hello.o
#hello.o是你要生成的驅動,以後可以自己改
KERNELDIR:=/lib/moles/2.6.27-7-generic/build
#這里別抄,寫成你自己的版本,這個目錄執行了內核源碼目錄
PWD:=$(shell pwd) #將當前工作目錄賦值該PWD
moles:
$(MAKE) -C $(KERNELDIR) M=$(PWD) moles
moles_install:

下面是一個經典的Hello,world!例子自己make一下就行了。
#include <linux/init.h>
#include <linux/mole.h>
MODULE_LICENSE("Dual BSD/GPL");
static int hello_init(void)
{
printk(KERN_ALERT "Hello, world!\n");
return 0;
}
static void hello_exit(void)
{
printk(KERN_ALERT"Goodbye, cruel world!\n");
}
mole_init(hello_init);
mole_exit(hello_exit);

本文來自CSDN博客,轉載請標明出處:http://blog.csdn.net/unikingest/archive/2009/03/10/3977747.aspx

-----------------------------------------------------------------------------

修改的這篇文章,自己加了幾個注意點
http://blog.theosoft.net/article.asp?id=57

第一次的Linux kernel上機內容是編譯一個內核。我用的是Ubuntu,有很多地方和其它 Linux不一樣,所以就來把我的過程寫下來,以後也好有個參照
首先當然是下載內核源代碼,如果你要最新的內核,可以去ftp.kernel.org。當然,國內速度可能會很慢。如果你是教育網用戶,可以去上海交大的鏡像站下載,地址是http://ftp.sjtu.e.cn/sites/ftp.kernel.org/,缺點就是沒有最新的內核(更新需要一定的時間)。
==================================================備注
如果是就是編譯ubuntu本省自帶的內核,只需要
新立得搜索linux souce,下載帶ubuntupatch的kernel的source code。
sudo apt-get source linux-source-2.6.27
==================================================備注
我下載的是linux-2.6.19.2.tar.gz可以下到的最新版本了。下完之後當然是解壓縮。不過還不能直接編譯,因為Ubuntu的默認安裝里缺少必要的組建。打開終端,輸入一下命令:
sudo -i
apt-get install build-essential kernel-package libncurses5-dev
然後到新立得里把所有以ncurses開頭的軟體包全部裝上,這樣就可以開始編譯內核了。
先運行以下命令,復制當前內核的配置文件。
cp /boot/config-`uname -r` ./.config
然後
make menuconfig

選擇 "Load an Alternate Configuration File",再選擇你剛才拷貝過來的.config文件作為配置文件。然後確定。當結束後,你選擇退出時,會提示問你 "Do you wish to save your new kernel configuration?"選擇yes即可。
接下來就要編譯了。輸入命令:
make
你也可以將編譯任務分成2個線程來執行,只要輸入:
make -j2
編譯一般需要1~1.5小時左右,就看cpu的性能如何
編譯完成後,開始安裝:
make mole_install
make install
然後添加引導信息,不過之前還是要裝一個組件initramfs-tools,裝完以後輸入:
mkinitramfs -o /boot/initrd.img-2.X.XX /lib/moles/2.X.XX
==================================================備注
後面的參數不要忘記了,否則啟動新內核會出現錯誤:
WARNING: Couldn』t open directory /lib/moles/2.6.15.7-ubuntu1: No such file or directory
FATAL: Could not open /lib/moles/2.6.15.7-ubuntu1/moles.dep.temp for writing: No such file or directory
==================================================備注
最後打開 /boot/grub/menu.lst
在 ## ## End Default Options ## 下面添加類似下面的兩段
title Ubuntu, kernel 2.6.19.2
root (hd0,4)
kernel /vmlinuz-2.6.19.2 root=/dev/hdd6
initrd /initrd.img-2.6.19.2
savedefault
boot

title Ubuntu, kernel 2.6.19.2 (recovery mode)
root (hd0,4)
kernel /vmlinuz-2.6.19.2 root=/dev/hdd6 ro single
initrd /initrd.img-2.6.19.2
boot
注意 root和kernel欄位要模仿menu.lst下面已有的內容寫。下面是 (hd0,4),那麼你也寫(hd0,4),下面寫root=/dev/hdd6,你也寫root=/dev/hdd6,只是內核的版本號改為現在編譯的版本號。然後重新啟動計算機,在GRUB中選擇新內核啟動。如果啟動失敗,你可以重啟選擇老內核。

C. PVE內核在ARM64下安裝及編譯

以下命令在Linux root下進行

1.apt-getinstall gnupg2 wget –y

2.加入Proxmox 軟逗山早件包源

wget -qO -http://download.proxmox.com/debian/proxmox-ve-release-6.x.gpg | sudo apt-key add echo "deb http://download.proxmox.com/debian/pve buster pve-no-subscription " | sudotee /etc/apt/sources.list.d/buster-pvetest.list

3.apt-getupdate

4.安裝編譯環境

apt-get install build-essentialasciidoc binutils bzip2 gawk gettext git libncurses5-dev libz-dev patch unzipzlib1g-dev libc6-dev subversion flex uglifyjs p7zip p7zip-full msmtp libssl-devtexinfo libglib2.0-dev xmlto qemu-utils upx libelf-dev autoconf automakelibtool autopoint device-tree-compiler screen

apt-get install python3-dev  python3-sphinx lintian bc bison libdw-devlibiberty-dev libnuma-dev libslang2-dev lz4 rsync  libpve-common-perl dh-make docbook5-xml

若山雀是出現libncurses5-dev安裝依賴錯誤,用aptitude安裝即可解決

5. Git pve內核源碼

git clonegit://git.proxmox.com/git/pve-kernel.git

6. 修改Makefile文件

23行內容 KERNEL_ARCH=x86和之後 修改成如下圖所示:

7.  在pve-kernel/debian/rules.d文件目錄下生成文件arm64.mk,內容如下

KERNEL_BUILD_ARCH       = arm64

KERNEL_HEADER_ARCH   = $(KERNEL_BUILD_ARCH)

KERNEL_BUILD_IMAGE     = Image

KERNEL_IMAGE_PATH =arch/$(KERNEL_BUILD_ARCH)/boot/${KERNEL_BUILD_IMAGE}

KERNEL_INSTALL_FILE       = vmlinuz

8.  修改pve-kernel/debian/rules文件,將rysnc中的tools修改成source,修改結果如下圖所示

9.  Make all

10.最終編譯成功後會生唯橡成四個文件包,使用dpkg -i命令安裝四個deb包,即可完成pve內核的安裝。

linux-tools-{KERNEL_VER}_arm64.deb

linux-tools-5.0-dbgsym_{KERNEL_VER}_arm64.deb

pve-headers-{KERNEL_VER}_arm64.deb

pve-kernel-{KERNEL_VER}_arm64.deb

閱讀全文

與debian10內核編譯相關的資料

熱點內容
dvd光碟存儲漢子演算法 瀏覽:758
蘋果郵件無法連接伺服器地址 瀏覽:963
phpffmpeg轉碼 瀏覽:672
長沙好玩的解壓項目 瀏覽:145
專屬學情分析報告是什麼app 瀏覽:564
php工程部署 瀏覽:833
android全屏透明 瀏覽:737
阿里雲伺服器已開通怎麼辦 瀏覽:803
光遇為什麼登錄時伺服器已滿 瀏覽:302
PDF分析 瀏覽:486
h3c光纖全工半全工設置命令 瀏覽:143
公司法pdf下載 瀏覽:383
linuxmarkdown 瀏覽:350
華為手機怎麼多選文件夾 瀏覽:683
如何取消命令方塊指令 瀏覽:350
風翼app為什麼進不去了 瀏覽:779
im4java壓縮圖片 瀏覽:362
數據查詢網站源碼 瀏覽:151
伊克塞爾文檔怎麼進行加密 瀏覽:893
app轉賬是什麼 瀏覽:163