Linux 内核修改及静默启动
前言引用网友的的文字:Linux的图形界面实在是太耗资源了,同时开几个虚拟机感觉已经hold不住了,赶紧把这些Linux服务器的图形界面都关掉。CLI:command Line Interface,命令行界面。现在的Linux发行版默认登陆界面几乎都是默认为GUI界面,如果按照旧版本的修改inittab文件,在一些比较新的版本是没有这个文件的(Linux的启动服务机制发生改变)...
·
前言
引用网友的的文字:
Linux的图形界面实在是太耗资源了,同时开几个虚拟机感觉已经hold不住了,赶紧把这些Linux服务器的图形界面都关掉。
CLI:command Line Interface,命令行界面。
现在的Linux发行版默认登陆界面几乎都是默认为GUI界面,如果按照旧版本的修改inittab文件,在一些比较新的版本是没有这个文件的(Linux的启动服务机制发生改变)
查看当前Linux内核的信息
root@gpc:/home/CTBuild# uname -r
4.9.0-6-rt-amd64
root@gpc:/home/CTBuild#
查看驱动编译时的内核
CTBuild@gpc:~/OneKeyGantryBuild/GantryMain_R001.11.0.788132.Re.20190521_T191319$ m driver
-------------------------------------------------------------------
clean driver tmp files.
rm -f *.o
rm -f *.ko
rm -f .*.cmd
rm -f *mod.c
rm -rf *.symvers
rm -rf *.order
-------------------------------------------------------------------
begin build driver
make -C /lib/modules/4.9.0-6-rt-amd64/build M=/home/CTBuild/OneKeyGantryBuild/GantryMain_R001.11.0.788132.Re.20190521_T191319/Code/sib/drivers/kernel modules
make[1]: Entering directory '/usr/src/linux-headers-4.9.0-6-rt-amd64'
CC [M] /home/CTBuild/OneKeyGantryBuild/GantryMain_R001.11.0.788132.Re.20190521_T191319/Code/sib/drivers/kernel/uiosib.o
Building modules, stage 2.
MODPOST 1 modules
CC /home/CTBuild/OneKeyGantryBuild/GantryMain_R001.11.0.788132.Re.20190521_T191319/Code/sib/drivers/kernel/uiosib.mod.o
LD [M] /home/CTBuild/OneKeyGantryBuild/GantryMain_R001.11.0.788132.Re.20190521_T191319/Code/sib/drivers/kernel/uiosib.ko
make[1]: Leaving directory '/usr/src/linux-headers-4.9.0-6-rt-amd64'
查看所有的内核信息
root@gpc:/home/CTBuild# ls -l /boot/
total 92164
-rw-r--r-- 1 root root 186567 May 8 2018 config-4.9.0-6-amd64
-rw-r--r-- 1 root root 186173 May 8 2018 config-4.9.0-6-rt-amd64
-rw-r--r-- 1 root root 186589 Oct 8 2018 config-4.9.0-8-amd64
drwxr-xr-x 5 root root 4096 May 21 06:24 grub
-rw-r--r-- 1 root root 23820224 Feb 15 11:08 initrd.img-4.9.0-6-amd64
-rw-r--r-- 1 root root 23854973 Apr 10 07:01 initrd.img-4.9.0-6-rt-amd64
-rw-r--r-- 1 root root 23825564 May 20 06:21 initrd.img-4.9.0-8-amd64
-rw-r--r-- 1 root root 3190138 May 8 2018 System.map-4.9.0-6-amd64
-rw-r--r-- 1 root root 3197657 May 8 2018 System.map-4.9.0-6-rt-amd64
-rw-r--r-- 1 root root 3193875 Oct 8 2018 System.map-4.9.0-8-amd64
-rw-r--r-- 1 root root 4224800 May 8 2018 vmlinuz-4.9.0-6-amd64
-rw-r--r-- 1 root root 4249888 May 8 2018 vmlinuz-4.9.0-6-rt-amd64
-rw-r--r-- 1 root root 4237088 Oct 8 2018 vmlinuz-4.9.0-8-amd64
删除0-8版本的内核
root@gpc:/boot# ls -l
total 61452
-rw-r--r-- 1 root root 186567 May 8 2018 config-4.9.0-6-amd64
-rw-r--r-- 1 root root 186173 May 8 2018 config-4.9.0-6-rt-amd64
drwxr-xr-x 5 root root 4096 May 22 15:27 grub
-rw-r--r-- 1 root root 23820224 Feb 15 11:08 initrd.img-4.9.0-6-amd64
-rw-r--r-- 1 root root 23854973 Apr 10 07:01 initrd.img-4.9.0-6-rt-amd64
-rw-r--r-- 1 root root 3190138 May 8 2018 System.map-4.9.0-6-amd64
-rw-r--r-- 1 root root 3197657 May 8 2018 System.map-4.9.0-6-rt-amd64
-rw-r--r-- 1 root root 4224800 May 8 2018 vmlinuz-4.9.0-6-amd64
-rw-r--r-- 1 root root 4249888 May 8 2018 vmlinuz-4.9.0-6-rt-amd64
更新grub
root@gpc:/home/CTBuild# update-grub
Generating grub configuration file ...
Found background image: /usr/share/images/desktop-base/desktop-grub.png
Found linux image: /boot/vmlinuz-4.9.0-6-rt-amd64
Found initrd image: /boot/initrd.img-4.9.0-6-rt-amd64
Found linux image: /boot/vmlinuz-4.9.0-6-amd64
Found initrd image: /boot/initrd.img-4.9.0-6-amd64
done
root@gpc:/home/CTBuild# reboot
查看驱动编译时的内核
CTBuild@gpc:~/OneKeyGantryBuild/GantryMain_R001.11.0.788132.Re.20190521_T191319$ m driver
-------------------------------------------------------------------
clean driver tmp files.
rm -f *.o
rm -f *.ko
rm -f .*.cmd
rm -f *mod.c
rm -rf *.symvers
rm -rf *.order
-------------------------------------------------------------------
begin build driver
make -C /lib/modules/4.9.0-6-amd64/build M=/home/CTBuild/OneKeyGantryBuild/GantryMain_R001.11.0.788132.Re.20190521_T191319/Code/sib/drivers/kernel modules
make[1]: Entering directory '/usr/src/linux-headers-4.9.0-6-amd64'
CC [M] /home/CTBuild/OneKeyGantryBuild/GantryMain_R001.11.0.788132.Re.20190521_T191319/Code/sib/drivers/kernel/uiosib.o
Building modules, stage 2.
MODPOST 1 modules
CC /home/CTBuild/OneKeyGantryBuild/GantryMain_R001.11.0.788132.Re.20190521_T191319/Code/sib/drivers/kernel/uiosib.mod.o
LD [M] /home/CTBuild/OneKeyGantryBuild/GantryMain_R001.11.0.788132.Re.20190521_T191319/Code/sib/drivers/kernel/uiosib.ko
make[1]: Leaving directory '/usr/src/linux-headers-4.9.0-6-amd64'
-------------------------------------------------------------------
copy driver to bin folder: /home/CTBuild/OneKeyGantryBuild/GantryMain_R001.11.0.788132.Re.20190521_T191319/UIH/bin
-------------------------------------------------------------------
clean driver tmp files.
rm -f *.o
rm -f *.ko
rm -f .*.cmd
rm -f *mod.c
rm -rf *.symvers
rm -rf *.order
CTBuild@gpc:~/OneKeyGantryBuild/GantryMain_R001.11.0.788132.Re.20190521_T191319$ ls -l UIH/bin/uiosib.ko
-rw-r--r-- 1 CTBuild CTBuild 430456 May 22 15:49 UIH/bin/uiosib.ko
CTBuild@gpc:~/OneKeyGantryBuild/GantryMain_R001.11.0.788132.Re.20190521_T191319$
修改Grub配置文件
打开grup配置文件
nano /etc/default/grub
内容展示
# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.
# For full documentation of the options in this file, see:
# info -f grub -n 'Simple configuration'
GRUB_DEFAULT="1>2"
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet"
GRUB_CMDLINE_LINUX="net.ifnames=0 biosdevname=0"
# Uncomment to enable BadRAM filtering, modify to suit your needs
# This works with Linux (no patch required) and with any kernel that obtains
# the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)
#GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"
# Uncomment to disable graphical terminal (grub-pc only)
#GRUB_TERMINAL=console
# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo'
#GRUB_GFXMODE=640x480
# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
#GRUB_DISABLE_LINUX_UUID=true
# Uncomment to disable generation of recovery mode menu entries
#GRUB_DISABLE_RECOVERY="true"
# Uncomment to get a beep at grub start
#GRUB_INIT_TUNE="480 440 1"
修改
GRUB_CMDLINE_LINUX=”” 为GRUB_CMDLINE_LINUX=”text”
更新grub
update-grub
更新系统服务管理器配置
systemctl set-default multi-user.target
重启:init 6
# If you change this file, run ‘update-grub’ afterwards to update
# /boot/grub/grub.cfg.
# For full documentation of the options in this file, see:
# info -f grub -n ‘Simple configuration’
GRUB_DEFAULT=0
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR=lsb_release -i -s 2> /dev/null || echo Debian
GRUB_CMDLINE_LINUX_DEFAULT="quiet"
GRUB_CMDLINE_LINUX="text"
# Uncomment to enable BadRAM filtering, modify to suit your needs
# This works with Linux (no patch required) and with any kernel that obtains
# the memory map information from GRUB (GNU Mach, kernel of FreeBSD …)
#GRUB_BADRAM=”0x01234567,0xfefefefe,0x89abcdef,0xefefefef”
# Uncomment to disable graphical terminal (grub-pc only)
#GRUB_TERMINAL=console
# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo’
#GRUB_GFXMODE=640x480
# Uncomment if you don’t want GRUB to pass “root=UUID=xxx” parameter to Linux
#GRUB_DISABLE_LINUX_UUID=true
# Uncomment to disable generation of recovery mode menu entries
#GRUB_DISABLE_RECOVERY=”true”
# Uncomment to get a beep at grub start
#GRUB_INIT_TUNE=”480 440 1”
解除debian root用户登陆限制
打开gdm配置文件:
nano /etc/gdm3/deamon.conf
配置安全设置:[security]
下一行添加 AllowRoot = ture
去除gdm登陆用户名检测:
打开文件 /etc/pam.d/gdm-autologin
,并其相关配置信息删除或注释掉:auth required pam_succeed_if.so user != root quiet_success
修改后的gdm-autologin文件:
#%PAM-1.0
auth requisite pam_nologin.so
#auth required pam_succeed_if.so user != root quiet_success
auth required pam_permit.so
@include common-account
# SELinux needs to be the first session rule. This ensures that any
# lingering context has been cleared. Without this it is possible
# that a module could execute code in the wrong domain.
session [success=ok ignore=ignore module_unknown=ignore default=bad] pam_selinux.so close
session required pam_loginuid.so
# SELinux needs to intervene at login time to ensure that the process
# starts in the proper default security context. Only sessions which are
# intended to run in the user’s context should be run after this.
session [success=ok ignore=ignore module_unknown=ignore default=bad] pam_selinux.so open
session optional pam_keyinit.so force revoke
session required pam_limits.so
session required pam_env.so readenv=1
session required pam_env.so readenv=1 envfile=/etc/default/locale
@include common-session
@include common-password
更多推荐
已为社区贡献4条内容
所有评论(0)