linux系統管理(1)之 內核編譯選項查看

三個方法linux

  1. proc文件系統
  2. ubunut debain
  3. 紅帽等

proc文件系統

/proc/config.gz
This file shows you the compile-time configuration settings for the kernel (gzip compressed, use zcat or zless to see its contents). It is available only if you enable it using CONFIG_IKCONFIG_PROC when you compile.shell

Say you want to upgrade to the next available kernel. Your current kernel works fine, so you'd like to use the same parameters, but you accidentally lost your original .config configuration file. Simplyzcat /proc/config.gz > /usr/src/linux/.config and you're ready to go.ubuntu

Example output:less

Automatically generated make config: don't edit

Linux kernel version: 2.6.17

Sat Jul 15 17:01:24 2006

CONFIG_X86_32=y
CONFIG_SEMAPHORE_SLEEPERS=y
CONFIG_X86=y
CONFIG_MMU=y
CONFIG_GENERIC_ISA_DMA=y
CONFIG_GENERIC_IOMAP=y
CONFIG_GENERIC_HWEIGHT=y
CONFIG_ARCH_MAY_HAVE_PC_FDC=y
CONFIG_DMI=yide

#zcat /proc/config.gz

須要開啓內核配置項CONFIG_IKCONFIG纔會生成這個文件code

ubuntu

  1. 文件下查看
    /usr/src/linux-headers-VERSION-generic/.configip

  2. 從系統/boot目錄下獲取ci

[root@localhost ~]# uname -r
4.9.77
[root@localhost ~]# ls /boot/
config-4.9.77-30.el7.x86_64                              System.map
grub                                                     System.map-4.9.77
grub2                                                    System.map-4.9.77-30.el7.x86_64
initramfs-0-rescue-d5e5083a18b24f4db74d0c0f71770f64.img  System.map-4.9.77.old
initramfs-4.9.77.img                                     vmlinuz
initramfs-4.9.77kdump.img                                vmlinuz-0-rescue-d5e5083a18b24f4db74d0c0f71770f64
initrd-plymouth.img                                      vmlinuz-4.9.77
symvers-4.9.77-30.el7.x86_64.gz

3.從系統/usr/src/kernel目錄下獲取it

[root@localhost ~]# uname -r
4.9.77
[root@localhost ~]# cd /usr/src/kernels
[root@localhost kernels]# ls
4.9.77-30.el7.x86_64
[root@localhost kernels]# cd 4.9.77-30.el7.x86_64/
[root@localhost 4.9.77-30.el7.x86_64]# ls -a
.     block   .config      drivers   include  Kconfig  Makefile        net      security    tools
..    certs   .config.old  firmware  init     kernel   mm              samples  sound       usr
arch  config  crypto       fs        ipc      lib      Module.symvers  scripts  System.map  virt

如上所示,當前內核的編譯配置文件爲:.configio

相關文章
相關標籤/搜索