配置你的 Linux 的 GRUB 启动背景

GRUB 背景( Splash )只不过是一张图像,在 Linux 系统启动的时候显示为背景。你可能知道 Grub (GRand Unified Bootloader 的简写) 是主流 Linux 发行版中广泛使用的启动装载程序 bootloader。以 RedHat 为例,你会发现它在系统启动之时显示为空白或者是一个黑色背景。

GRUB 背景( Splash )的相关定义在 grub.conf 文件中,并且 splash 背景图像应该存储在 /boot 分区中。如果你觉得默认的空白屏相当无趣,同时又想按照自己的意愿来修改它,那么赶紧阅读下方的每个步骤吧。

开始前需要哪些准备工作

  1. ImageMagick (仅在命令行中使用) 或者 GIMP (GUI 中使用)
  2. 一个样例图像

使用 GUI 修改 Grub 的 Splash 背景

首先然我们来使用 GUI 来进行操作吧,这里我们使用 GIMP 来作为图像编辑器。

步骤 1、 使用 GIMP 打开图像 (路径为:应用Applications --> 图像Graphics -->GIMP 程序GNU Image Manipulation Program)

步骤 2、 现在我们需要按实际情况将图像缩放到 640x480 大小。为此,需要点击 图像Image --> 缩放图像Scale Image。记住,要如下图参数进行设置。修改宽度为 640,高度为 480。其他保持不变。

点击 缩放Scale按钮

步骤 3、 然后,我们需要索引图像,让它仅使用 14 色。为此,点击 图像Image --> 模式Mode --> 索引Indexed。点选 生成最优调色板generate optimum palette 选项,并设置颜色最大值maximum number of colors 为 14 (如下)。

点击 转换convert按钮

步骤 4、 保存文件。这里以文件名为 “UxTechno.xpm” 来保存。

步骤 5、 以 Zip 方式压缩文件。为此,转到文件的保存位置 --> 右击并选择压缩Compress 选项,选择 gzip 方法来压缩。

步骤 6、 现在复制或移动 "UxTechno.xpm.gz" 到 /boot/grub/UxTechno.xpm.gz。

步骤 7、 这一步,打开 /boot/grub/grub.conf 文件编辑 splashimage 参数如下,并保存文件。

最后,文件的内容应该是像这样的:

# 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/sda2 # initrd
    /initrd-[generic-]version.img #boot=/dev/sda default=0 timeout=5
    splashimage=(hd0,0)/grub/UxTechno.xpm.gz
    hiddenmenu   
    title Red Hat Enterprise Linux (2.6.32-220.el6.x86_64)
    root (hd0,0)
    kernel /vmlinuz-2.6.32-220.el6.x86_64 ro root=UUID=1d8c5075-1a5b-4fdc-ba15-0458b65c6012 rd_NO_LUKS rd_NO_LVM LANG=en_US.UTF-8 rd_NO_MD quiet SYSFONT=latarcyrheb-sun16 rhgb
    crashkernel=auto KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM initrd
    /initramfs-2.6.32-220.el6.x86_64.img

当你重启服务器之后,你讲看到如下效果的 splash 背景图像:

使用命令行修改 Grub 的 Splash 背景

如果说你是命令行的超级粉丝,那就使用如下方法吧。

步骤 1、 开始之前,我们需要修改图像的像素分辨率。为此,我们还需要在 Linux 系统上安装好 ImageMagick。在 CentOS / RHEL 上使用如下命令来进行交叉检查。

# rpm -qa|grep -i ImageMagick

如果命令没有返回输出 (即空白),这意味这你的系统上还没有安装 ImageMagick。你必须运行下面的命令来安装它。

# yum install ImageMagick

安装好了重新复核一下,你会得到类似如下的输出:

# rpm -qa|grep -i ImageMagick

ImageMagick-6.5.4.7-5.el6.x86_64

然后,继续接下来的配置。这里我使用 UxTechno 的 logo 来做 splash 背景图像。

步骤 2、 使用如下命令来转换像素深度。

# convert -depth 8 -colors 14 -resize 640x480 uxtechno_logo.jpg uxtechno_logo.xpm

上述选项的意义如下:

  1. 最大使用 14 色
  2. 分辨率为 640x480
  3. 使用 xpm 格式

步骤 3、 以 Zip 方式压缩文件。

# gzip uxtechno_logo.xpm

步骤 4、 复制文件到 /boot 分区。

# cp uxtechno_logo.xpm.gz /boot/grub/

步骤 5、 在 /boot/grub/grub.conf 文件中修改 splashimage 参数如下,并保存文件。

splashimage=(hd0,0)/grub/uxtechno_logo.xpm

步骤 6、 最后,使用 reboot 命令重启服务器。启动界面将显示使用 GUI 方式第 7 步中的图像。

(题图原图在 wallconvert.com

何为 GRUB 背景( Splash )?

GRUB 背景( Splash )只不过是一张图像,在 Linux 系统启动的时候显示为背景。你可能知道 Grub (GRand Unified Bootloader 的简写) 是主流 Linux 发行版中广泛使用的启动装载程序bootloader。以 RedHat 为例,你会发现它在系统启动之时显示为空白或者是一个黑色背景。

GRUB 背景( Splash )的相关定义在 grub.conf 文件中,并且 splash 背景图像应该存储在 /boot 分区中。如果你觉得默认的空白屏相当无趣,同时又想按照自己的意愿来修改它,那么赶紧阅读下方的每个步骤吧。

开始前需要哪些准备工作

  1. ImageMagick (仅在命令行中使用) 或者 GIMP (GUI 中使用)
  2. 一个样例图像

使用 GUI 修改 Grub 的 Splash 背景

首先然我们来使用 GUI 来进行操作吧,这里我们使用 GIMP 来作为图像编辑器。

步骤 1、 使用 GIMP 打开图像 (路径为:应用Applications --> 图像Graphics -->GIMP 程序GNU Image Manipulation Program)

步骤 2、 现在我们需要按实际情况将图像缩放到 640x480 大小。为此,需要点击 图像Image --> 缩放图像Scale Image。记住,要如下图参数进行设置。修改宽度为 640,高度为 480。其他保持不变。

点击 缩放Scale按钮

步骤 3、 然后,我们需要索引图像,让它仅使用 14 色。为此,点击 图像Image --> 模式Mode --> 索引Indexed。点选 生成最优调色板generate optimum palette 选项,并设置颜色最大值maximum number of colors 为 14 (如下)。

点击 转换convert按钮

步骤 4、 保存文件。这里以文件名为 “UxTechno.xpm” 来保存。

步骤 5、 以 Zip 方式压缩文件。为此,转到文件的保存位置 --> 右击并选择压缩Compress 选项,选择 gzip 方法来压缩。

步骤 6、 现在复制或移动 "UxTechno.xpm.gz" 到 /boot/grub/UxTechno.xpm.gz。

步骤 7、 这一步,打开 /boot/grub/grub.conf 文件编辑 splashimage 参数如下,并保存文件。

最后,文件的内容应该是像这样的:

# 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/sda2 # initrd
    /initrd-[generic-]version.img #boot=/dev/sda default=0 timeout=5
    splashimage=(hd0,0)/grub/UxTechno.xpm.gz
    hiddenmenu   
    title Red Hat Enterprise Linux (2.6.32-220.el6.x86_64)
    root (hd0,0)
    kernel /vmlinuz-2.6.32-220.el6.x86_64 ro root=UUID=1d8c5075-1a5b-4fdc-ba15-0458b65c6012 rd_NO_LUKS rd_NO_LVM LANG=en_US.UTF-8 rd_NO_MD quiet SYSFONT=latarcyrheb-sun16 rhgb
    crashkernel=auto KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM initrd
    /initramfs-2.6.32-220.el6.x86_64.img

当你重启服务器之后,你讲看到如下效果的 splash 背景图像:

使用命令行修改 Grub 的 Splash 背景

如果说你是命令行的超级粉丝,那就使用如下方法吧。

步骤 1、 开始之前,我们需要修改图像的像素分辨率。为此,我们还需要在 Linux 系统上安装好 ImageMagick。在 CentOS / RHEL 上使用如下命令来进行交叉检查。

# rpm -qa|grep -i ImageMagick

如果命令没有返回输出 (即空白),这意味这你的系统上还没有安装 ImageMagick。你必须运行下面的命令来安装它。

# yum install ImageMagick

安装好了重新复核一下,你会得到类似如下的输出:

# rpm -qa|grep -i ImageMagick

ImageMagick-6.5.4.7-5.el6.x86_64

然后,继续接下来的配置。这里我使用 UxTechno 的 logo 来做 splash 背景图像。

步骤 2、 使用如下命令来转换像素深度。

# convert -depth 8 -colors 14 -resize 640x480 uxtechno_logo.jpg uxtechno_logo.xpm

上述选项的意义如下:

  1. 最大使用 14 色
  2. 分辨率为 640x480
  3. 使用 xpm 格式

步骤 3、 以 Zip 方式压缩文件。

# gzip uxtechno_logo.xpm

步骤 4、 复制文件到 /boot 分区。

# cp uxtechno_logo.xpm.gz /boot/grub/

步骤 5、 在 /boot/grub/grub.conf 文件中修改 splashimage 参数如下,并保存文件。

splashimage=(hd0,0)/grub/uxtechno_logo.xpm

步骤 6、 最后,使用 reboot 命令重启服务器。启动界面将显示使用 GUI 方式第 7 步中的图像。

猜你喜欢

转载自blog.csdn.net/yaxuan88521/article/details/131351234