Linux操作系统之更改启动菜单的背景图实战案例

            Linux操作系统之更改启动菜单的背景图实战案例

                                      作者:尹正杰

版权声明:原创作品,谢绝转载!否则将追究法律责任。

 

一.制作图像并上传到服务器

1>.使用window 10操作系统自带的画图工具指定像素的图片并保存到本地(推荐报错为"JPEG"类型)

 

2>.安装Linux上传工具包

[root@yinzhengjie ~]# yum -y install lrzsz
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Install Process
Loading mirror speeds from cached hostfile
 * base: mirrors.huaweicloud.com
 * extras: mirrors.huaweicloud.com
 * updates: mirrors.huaweicloud.com
base                                                                                                                                                 | 3.7 kB     00:00     
extras                                                                                                                                               | 3.4 kB     00:00     
updates                                                                                                                                              | 3.4 kB     00:00     
Resolving Dependencies
--> Running transaction check
---> Package lrzsz.x86_64 0:0.12.20-27.1.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

============================================================================================================================================================================
 Package                               Arch                                   Version                                            Repository                            Size
============================================================================================================================================================================
Installing:
 lrzsz                                 x86_64                                 0.12.20-27.1.el6                                   base                                  71 k

Transaction Summary
============================================================================================================================================================================
Install       1 Package(s)

Total download size: 71 k
Installed size: 159 k
Downloading Packages:
lrzsz-0.12.20-27.1.el6.x86_64.rpm                                                                                                                    |  71 kB     00:00     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : lrzsz-0.12.20-27.1.el6.x86_64                                                                                                                            1/1 
  Verifying  : lrzsz-0.12.20-27.1.el6.x86_64                                                                                                                            1/1 

Installed:
  lrzsz.x86_64 0:0.12.20-27.1.el6                                                                                                                                           

Complete!
[root@yinzhengjie ~]# 
[root@yinzhengjie ~]# yum -y install lrzsz

3>.使用rz工具将我们制作好的图片上传到服务器上

[root@yinzhengjie ~]# rz
[root@yinzhengjie ~]# 
[root@yinzhengjie ~]# ll
total 96
-rw-r--r-- 1 root root 94446 Dec  3  2019 windows.jpg
[root@yinzhengjie ~]# 

 

二.使用convert工具(相当于windows中的PS软件)将双穿的图片进行压缩处理

1>.安装convert软件包

[root@yinzhengjie ~]# yum -y install ImageMagick
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Install Process
Loading mirror speeds from cached hostfile
 * base: mirrors.zju.edu.cn
 * extras: mirrors.zju.edu.cn
 * updates: mirrors.zju.edu.cn
Resolving Dependencies
--> Running transaction check
---> Package ImageMagick.x86_64 0:6.7.2.7-6.el6 will be installed
--> Processing Dependency: libwmflite-0.2.so.7()(64bit) for package: ImageMagick-6.7.2.7-6.el6.x86_64
--> Processing Dependency: libwmf-0.2.so.7()(64bit) for package: ImageMagick-6.7.2.7-6.el6.x86_64
--> Processing Dependency: libImath.so.6()(64bit) for package: ImageMagick-6.7.2.7-6.el6.x86_64
--> Processing Dependency: libIlmThread.so.6()(64bit) for package: ImageMagick-6.7.2.7-6.el6.x86_64
--> Processing Dependency: libIlmImf.so.6()(64bit) for package: ImageMagick-6.7.2.7-6.el6.x86_64
--> Processing Dependency: libIex.so.6()(64bit) for package: ImageMagick-6.7.2.7-6.el6.x86_64
--> Processing Dependency: libHalf.so.6()(64bit) for package: ImageMagick-6.7.2.7-6.el6.x86_64
--> Running transaction check
---> Package OpenEXR-libs.x86_64 0:1.6.1-8.1.el6 will be installed
---> Package ilmbase.x86_64 0:1.0.1-6.1.el6 will be installed
---> Package libwmf.x86_64 0:0.2.8.4-25.el6_7 will be installed
---> Package libwmf-lite.x86_64 0:0.2.8.4-25.el6_7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

============================================================================================================================================================================
 Package                                    Arch                                 Version                                           Repository                          Size
============================================================================================================================================================================
Installing:
 ImageMagick                                x86_64                               6.7.2.7-6.el6                                     base                               1.9 M
Installing for dependencies:
 OpenEXR-libs                               x86_64                               1.6.1-8.1.el6                                     base                               197 k
 ilmbase                                    x86_64                               1.0.1-6.1.el6                                     base                                72 k
 libwmf                                     x86_64                               0.2.8.4-25.el6_7                                  base                               132 k
 libwmf-lite                                x86_64                               0.2.8.4-25.el6_7                                  base                                51 k

Transaction Summary
============================================================================================================================================================================
Install       5 Package(s)

Total download size: 2.4 M
Installed size: 8.7 M
Downloading Packages:
(1/5): ImageMagick-6.7.2.7-6.el6.x86_64.rpm                                                                                                          | 1.9 MB     00:00     
(2/5): OpenEXR-libs-1.6.1-8.1.el6.x86_64.rpm                                                                                                         | 197 kB     00:00     
(3/5): ilmbase-1.0.1-6.1.el6.x86_64.rpm                                                                                                              |  72 kB     00:00     
(4/5): libwmf-0.2.8.4-25.el6_7.x86_64.rpm                                                                                                            | 132 kB     00:00     
(5/5): libwmf-lite-0.2.8.4-25.el6_7.x86_64.rpm                                                                                                       |  51 kB     00:00     
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                       3.3 MB/s | 2.4 MB     00:00     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : libwmf-lite-0.2.8.4-25.el6_7.x86_64                                                                                                                      1/5 
  Installing : ilmbase-1.0.1-6.1.el6.x86_64                                                                                                                             2/5 
  Installing : OpenEXR-libs-1.6.1-8.1.el6.x86_64                                                                                                                        3/5 
  Installing : libwmf-0.2.8.4-25.el6_7.x86_64                                                                                                                           4/5 
  Installing : ImageMagick-6.7.2.7-6.el6.x86_64                                                                                                                         5/5 
  Verifying  : libwmf-0.2.8.4-25.el6_7.x86_64                                                                                                                           1/5 
  Verifying  : ilmbase-1.0.1-6.1.el6.x86_64                                                                                                                             2/5 
  Verifying  : libwmf-lite-0.2.8.4-25.el6_7.x86_64                                                                                                                      3/5 
  Verifying  : ImageMagick-6.7.2.7-6.el6.x86_64                                                                                                                         4/5 
  Verifying  : OpenEXR-libs-1.6.1-8.1.el6.x86_64                                                                                                                        5/5 

Installed:
  ImageMagick.x86_64 0:6.7.2.7-6.el6                                                                                                                                        

Dependency Installed:
  OpenEXR-libs.x86_64 0:1.6.1-8.1.el6         ilmbase.x86_64 0:1.0.1-6.1.el6         libwmf.x86_64 0:0.2.8.4-25.el6_7         libwmf-lite.x86_64 0:0.2.8.4-25.el6_7        

Complete!
[root@yinzhengjie ~]# 
[root@yinzhengjie ~]# yum -y install ImageMagick

2>.查看conver命令的相关信息

[root@yinzhengjie ~]# which convert
/usr/bin/convert
[root@yinzhengjie ~]# 
[root@yinzhengjie ~]# rpm -qf /usr/bin/convert 
ImageMagick-6.7.2.7-6.el6.x86_64
[root@yinzhengjie ~]# 

3>.将上传的jpg格式转换成xpm格式

[root@yinzhengjie ~]# ll
total 96
-rw-r--r-- 1 root root 94446 Dec  3  2019 windows.jpg
[root@yinzhengjie ~]# 
[root@yinzhengjie ~]# convert -resize 640x480 -colors 14 windows.jpg windows.xpm      #指定像素为"640x480",指定颜色深度为14,将windows.jps转换成windows.xpm
[root@yinzhengjie ~]# 
[root@yinzhengjie ~]# ll
total 400
-rw-r--r-- 1 root root  94446 Dec  3  2019 windows.jpg
-rw-r--r-- 1 root root 309441 Dec  2 21:37 windows.xpm
[root@yinzhengjie ~]# 
[root@yinzhengjie ~]# file windows.xpm         #这是一个图片文件,内部信息如下图所示
windows.xpm: X pixmap image text
[root@yinzhengjie ~]# 

 

 

三.修改"/boot/grub/grub.conf"配置文件

1>.使用gzip命令将xpm格式文件进行压缩

[root@yinzhengjie ~]# ll
total 400
-rw-r--r-- 1 root root  94446 Dec  3  2019 windows.jpg
-rw-r--r-- 1 root root 309441 Dec  2 21:37 windows.xpm
[root@yinzhengjie ~]# 
[root@yinzhengjie ~]# gzip windows.xpm 
[root@yinzhengjie ~]# 
[root@yinzhengjie ~]# ll
total 172
-rw-r--r-- 1 root root 94446 Dec  3  2019 windows.jpg
-rw-r--r-- 1 root root 74636 Dec  2 21:37 windows.xpm.gz
[root@yinzhengjie ~]# 

2>.将"windows.xpm.gz"移动到"/boot/grub"目录并修改"/boot/grub/grub.conf"文件内容,将背景图片名称改为咱们自定义的图片即可

[root@yinzhengjie ~]# mv windows.xpm.gz /boot/grub/
[root@yinzhengjie ~]# 
[root@yinzhengjie ~]# ll /boot/grub/windows.xpm.gz 
-rw-r--r-- 1 root root 74636 Dec  2 21:37 /boot/grub/windows.xpm.gz
[root@yinzhengjie ~]# 
[root@yinzhengjie ~]# grep splashimage /boot/grub/grub.conf 
splashimage=(hd0,0)/grub/splash.xpm.gz
[root@yinzhengjie ~]# 
[root@yinzhengjie ~]# vim /boot/grub/grub.conf 
[root@yinzhengjie ~]# 
[root@yinzhengjie ~]# grep splashimage /boot/grub/grub.conf 
splashimage=(hd0,0)/grub/windows.xpm.gz
[root@yinzhengjie ~]# 
[root@yinzhengjie ~]# 

3>.重启操作系统,观察启动菜单背景是否更改成咱们自定义的图片即可

[root@yinzhengjie ~]# reboot 

Broadcast message from root@yinzhengjie
    (/dev/pts/0) at 21:51 ...

The system is going down for reboot NOW!
[root@yinzhengjie ~]# 

 

4>."/boot/grub/grub.conf"配置文件说明

[root@yinzhengjie ~]# cat /boot/grub/grub.conf 
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE:  You have a /boot partition.  This means that
#          all kernel and initrd paths are relative to /boot/, eg.
#          root (hd0,0)
#          kernel /vmlinuz-version ro root=/dev/mapper/vg_node200-lv_root
#          initrd /initrd-[generic-]version.img
#boot=/dev/sda
default=1                    #默认使用菜单1
timeout=5                    #指定超时时长为5秒
splashimage=(hd0,0)/grub/windows.xpm.gz  #指定背景图片
hiddenmenu                                #默认隐藏菜单选择执行默认的菜单1,当然我们只需要在启动操作系统时敲击任意键就会弹出菜单选项框,如果我们删除了该项,那么在启动操作系统时不管我们是否有按任意键都会弹出启动菜单,在指定的$timeout之内没有选择就会走选择$default菜单。

title CentOS
6 (2.6.32-754.el6.x86_64)    #菜单0 root (hd0,0) kernel /vmlinuz-2.6.32-754.el6.x86_64 ro root=/dev/mapper/vg_node200-lv_root nomodeset rd_NO_LUKS LANG=en_US.UTF-8 rd_LVM_LV=vg_node200/ lv_swap rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=128M rd_LVM_LV=vg_node200/lv_root KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet   initrd /initramfs-2.6.32-754.el6.x86_64.img
title CentOS
8 (4.6.32-754.el6.x86_64)    #菜单1 kernel (hd0,0)/vmlinuz-2.6.32-754.el6.x86_64 ro root=/dev/mapper/vg_node200-lv_root nomodeset rd_NO_LUKS LANG=en_US.UTF-8 rd_LVM_LV=vg_n ode200/lv_swap rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=128M rd_LVM_LV=vg_node200/lv_root KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM   initrd (hd0,0)/initramfs-2.6.32-754.el6.x86_64.img [root@yinzhengjie ~]#

 

posted @ 2019-11-22 22:39  尹正杰  阅读(600)  评论(0编辑  收藏  举报