archlinux自定义镜像

-
-
2026-01-05

采用archiso生成livecd镜像,在使用calamares开源安装程序,克隆live系统

参考链接arch-linux-calamares-installer · GitHub
可以选一个克隆,在基础上修改

archiso

首先安装 archiso

sudo pacman -Sy archiso

archiso需要的目录

├── airootfs  # 未来系统的文件目录,自定义添加需要的配置
├── bootstrap_packages.x86_64
├── grub # live镜像uefi引导的grub配置,uefi也可以选Systemd-boot
├── packages.x86_64 # 系统需要安装的包
├── pacman.conf # 包安装时使用的pacman配置文件
├── profiledef.sh # iso信息和配置
└── syslinux # biso引导配置

airootfs

未来系统的文件目录,自定义添加需要的配置

├── airootfs
│   ├── etc
│   ├── home
│   ├── media
│   ├── root
│   └── usr

预先设置

airootfs/etc/
├── default
├── environment
├── group #用户或者组配置
├── gshadow #用户或者组配置
├── hostname  # 设置主机名
├── locale.conf # 语言环境设置
├── locale.gen
├── localtime -> /usr/share/zoneinfo/UTC
├── mkinitcpio.conf
├── mkinitcpio.conf.d
├── mkinitcpio.d
├── modprobe.d
├── motd
├── ntp.conf
├── pacman.conf
├── pacman.d
├── pacman-more.conf
├── pam.d
├── passwd #用户或者组配置
├── plymouth
├── polkit-1
├── profile.d
├── resolv.conf -> /run/systemd/resolve/stub-resolv.conf
├── sddm.conf
├── sddm.conf.d
├── #shadow#
├── shadow #用户或者组配置
├── skel
├── ssh
├── sudoers.d #sudo配置
├── systemd # 服务配置,可以设置自启,添加对应软连接,可以在直接复制当前正在使用系统的
├── teamviewer #远程软件配置
├── vconsole.conf
├── vsftpd.conf #ftp配置
└── xdg

例如,添加用户bashrc和xfce桌面配置

airootfs/etc/skel
├── .bashrc
├── .config
│   └── xfce4
│       ├── desktop
│       │   ├── accels.scm
│       │   └── icons.screen0.yaml
│       ├── help.rc
│       ├── panel
│       │   ├── launcher-13
│       │   │   ├── 17633237721.desktop
│       │   │   └── 17637208851.desktop
│       │   ├── launcher-14
│       │   │   ├── 17633237722.desktop
│       │   │   └── 17637208852.desktop
│       │   ├── launcher-15
│       │   │   ├── 17633237723.desktop
│       │   │   └── 17637208853.desktop
│       │   ├── launcher-16
│       │   │   ├── 17633237724.desktop
│       │   │   └── 17637208864.desktop
│       │   └── xfce4-clipman-actions.xml
│       ├── xfconf
│       │   └── xfce-perchannel-xml
│       │       ├── displays.xml
│       │       ├── keyboard-layout.xml
│       │       ├── keyboards.xml
│       │       ├── ristretto.xml
│       │       ├── thunar-volman.xml
│       │       ├── thunar.xml
│       │       ├── xfce4-appfinder.xml
│       │       ├── xfce4-desktop.xml
│       │       ├── xfce4-keyboard-shortcuts.xml
│       │       ├── xfce4-notifyd.xml
│       │       ├── xfce4-panel.xml
│       │       ├── xfce4-power-manager.xml
│       │       ├── xfce4-screensaver.xml
│       │       ├── xfce4-session.xml
│       │       ├── xfce4-settings-editor.xml
│       │       ├── xfce4-settings-manager.xml
│       │       ├── xfce4-taskmanager.xml
│       │       ├── xfwm4.xml
│       │       └── xsettings.xml

live的grub背景或者主题

下载自己需要的主题,添加到此文件夹

├── grub
│   ├── background.png #背景图片
│   ├── fonts  # 字体
│   ├── grub.cfg 
│   ├── loopback.cfg
│   └── themes #主题

修改grub.cfg文件,修改开头的if里面,加载字体和设置主题

...
if loadfont "${archiso_device}/boot/grub/fonts/unicode.pf2" ; then
    loadfont "${archiso_device}/boot/grub/themes/tms/ubuntu_regular_20.pf2"
    loadfont "${archiso_device}/boot/grub/themes/tms/ubuntu_regular_17.pf2"
    loadfont "${archiso_device}/boot/grub/themes/tms/terminus-14.pf2"

    insmod all_video
    insmod gfxterm
    insmod png

    set gfxmode="auto"
    terminal_input console
    terminal_output gfxterm
    set theme="${archiso_device}/boot/grub/themes/tms/theme.txt"
fi

...

menu菜单修改成自己名称和对应图标

--class bbttms --class os  对应你主题里面的图标名称  --id 'bbttms' 对应上面的默认选择

# Set default menu entry
default=bbttms
timeout=15
timeout_style=menu

# Menu entries
menuentry "BBTTMS Linux install (%ARCH%, ${archiso_platform})" --class bbttms --class os --id 'bbttms' {
    set gfxpayload=keep
    linux /%INSTALL_DIR%/boot/%ARCH%/vmlinuz-linux archisobasedir=%INSTALL_DIR% archisosearchuuid=%ARCHISO_UUID% cow_spacesize=4G copytoram=n quiet splash plymouth.uuid=%ARCHISO_UUID%
    initrd /%INSTALL_DIR%/boot/%ARCH%/initramfs-linux.img
}

pacman.conf 使用镜像源和加入自定义源

包获取优先级自上往下,如果需要安装特定版本的包,可以加到自己的源里面,将在自定义源放在最上面,这样安装的时候,会优先使用自定义源里面的包。


[custom]
SigLevel = Optional TrustAll
Server = https://mirror.yuyujing.cn/archlinux/os/$arch

[core]
Include = /etc/pacman.d/mirrorlist

[extra]
Include = /etc/pacman.d/mirrorlist

# If you want to run 32 bit applications on your x86_64 system,
# enable the multilib repositories as required here.

#[multilib-testing]
#Include = /etc/pacman.d/mirrorlist

[multilib]
Include = /etc/pacman.d/mirrorlist

# An example of a custom package repository.  See the pacman manpage for
# tips on creating your own repositories.
#[custom]
#SigLevel = Optional TrustAll
#Server = file:///home/custompkgs

[archlinuxcn]
Server = https://mirrors.ustc.edu.cn/archlinuxcn/$arch

live的bios背景或者主题

更换对应图片就行

└── syslinux
   ├── archiso_head.cfg
   ├── archiso_pxe.cfg
   ├── archiso_pxe-linux.cfg
   ├── archiso_sys.cfg
   ├── archiso_sys-linux.cfg
   ├── archiso_tail.cfg
   ├── splash.png
   └── syslinux.cfg

开关机动画 plymouth

下载主题文件到此文件夹

└── usr
    └── share
        ├── backgrounds
        │   └── BBTTMS.png
        └── plymouth
            └── themes
                └── bbtlogo

修改airootfs/etc/default/grub 配置,添加 splash

GRUB_DEFAULT=0
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="Arch"
GRUB_CMDLINE_LINUX_DEFAULT="loglevel=3 quiet splash"
GRUB_CMDLINE_LINUX=""

修改mkinitcpio.conf,在udev后面添加plymouth

airootfs/etc/
├── mkinitcpio.conf
# 找到这一行,在udev后面添加plymouth
HOOKS=(base udev plymouth modconf kms memdisk archiso archiso_loop_mnt archiso_pxe_common archiso_pxe_nbd archiso_pxe_http archiso_pxe_nfs block filesystems keyboard)

修改biso引导菜单 在quiet后面添加splash plymouth.uuid=%ARCHISO_UUID%

└── syslinux
   ├── archiso_sys-linux.cfg
LABEL arch64
TEXT HELP
Boot the BBTTMS install medium on BIOS.
It allows you to install BBTTMS or perform system maintenance.
ENDTEXT
MENU LABEL BBTTMS install medium (x86_64, BIOS)
LINUX /%INSTALL_DIR%/boot/x86_64/vmlinuz-linux
INITRD /%INSTALL_DIR%/boot/x86_64/initramfs-linux.img
APPEND archisobasedir=%INSTALL_DIR% archisosearchuuid=%ARCHISO_UUID% cow_spacesize=4G copytoram=n quiet splash plymouth.uuid=%ARCHISO_UUID%

# Accessibility boot option
LABEL arch64speech
TEXT HELP
Boot the BBTTMS install medium on BIOS with speakup screen reader.
It allows you to install BBTTMS or perform system maintenance with speech feedback.
ENDTEXT
MENU LABEL BBTTMS install medium (x86_64, BIOS) with ^speech
LINUX /%INSTALL_DIR%/boot/x86_64/vmlinuz-linux
INITRD /%INSTALL_DIR%/boot/x86_64/initramfs-linux.img
APPEND archisobasedir=%INSTALL_DIR% archisosearchuuid=%ARCHISO_UUID% accessibility=on cow_spacesize=4G copytoram=n quiet splash plymouth.uuid=%ARCHISO_UUID%

修改uefi应对菜单在quiet后面添加splash plymouth.uuid=%ARCHISO_UUID%

# Menu entries
menuentry "BBTTMS Linux install (%ARCH%, ${archiso_platform})" --class bbttms --class os --id 'bbttms' {
    set gfxpayload=keep
    linux /%INSTALL_DIR%/boot/%ARCH%/vmlinuz-linux archisobasedir=%INSTALL_DIR% archisosearchuuid=%ARCHISO_UUID% cow_spacesize=4G copytoram=n quiet splash plymouth.uuid=%ARCHISO_UUID%
    initrd /%INSTALL_DIR%/boot/%ARCH%/initramfs-linux.img
}

calamares配置

获取calamares包

aur源安装calamares

yay -S calamares

或者下载源码自行编译安装

https://codeberg.org/Calamares/calamares.git

生成calamares包,加到自定义源中

calamares的配置文件

calamares的配置文件,可以将其打包成pacman的包,之后添加到packages.x86_64 中,之后会自动安装,calamares打开是会使用的你配置

git clone https://github.com/arch-linux-calamares-installer/alci-calamares-config.git

克隆仓库

修改对应的配置文件

├── etc
│   └── calamares
│       ├── branding #品牌,或者主题,自定义你的品牌展示
│       │   └── default
│       │       ├── 1-welcometo.png
│       │       ├── 2-BBTTMS.png
│       │       ├── BBTTMS.png
│       │       ├── branding.desc  #描述文件,修改实现你的主题
│       │       ├── lang
│       │       │   ├── calamares-default_ar.ts
│       │       │   ├── calamares-default_en.ts
│       │       │   ├── calamares-default_eo.ts
│       │       │   ├── calamares-default_fr.ts
│       │       │   └── calamares-default_nl.ts
│       │       ├── languages.png
│       │       ├── languages.png.license
│       │       ├── show.qml
│       │       ├── squid.png
│       │       └── stylesheet.qss
│       ├── modules # 模块设置
│       │   ├── bootloader.conf # 引导
│       │   ├── displaymanager.conf # 桌面图形化
│       │   ├── finished.conf # 最后,安装后是否重启
│       │   ├── grubcfg.conf # 可以设置gurb背景或者主题
│       │   ├── initcpio.conf
│       │   ├── locale.conf #设置时区
│       │   ├── mount.conf
│       │   ├── packages.conf # 包安装,可以在archiso制作阶段直接安装,或者在此处安装包,选择包安装,或者卸载某些安装环境才需要的包
│       │   ├── partition.conf #分区设置
│       │   ├── post-install-config.conf #系统安装后需要进行的操作,例如修改某些密码,或者其他安装后才能进行的操作
│       │   ├── preservefiles.conf
│       │   ├── removeuser.conf # 清理liveuser
│       │   ├── shellprocess-before.conf # 安装前脚本
│       │   ├── shellprocess-final.conf # 安装后脚本,此模块可以自动脚本,可多个
│       │   ├── unpackfs.conf
│       │   ├── users.conf # 用户设置模块,安装时是创建用户的规则
│       │   └── welcome.conf # 开始界面,检查配置和模块,是否符合需求
│       └── settings.conf  #总设置,决定使用那些模块
└── README.md

配置好之后,生成pacman包

makepkg -s

packages.x86_64添加包

...
calamares
alci-calamares-config
...

 

制作iso

配置都设置好之后,就可以使用 installation-scripts文件夹里面的脚本可以制作了

30-build-the-iso-the-first-time.sh
清空pacman缓存,重新下载,安装,制作
40-build-the-iso-local-again-use-custom-mkarchiso.sh

使用pacman缓存安装,缺少的包再下载,制作

多次制作建议使用40-build-the-iso-local-again-use-custom-mkarchiso.sh减少下载包的时间

sh  40-build-the-iso-local-again-use-custom-mkarchiso.sh

目录