背景
Linux Mint 官方原版 LiveCD 不支持 MacBook Pro, 键盘和网卡不能用,虽然可以外接键盘但是不够优雅,
于是本着不折腾会死、追求极致的本性,搜集并对比了各种资料,尝试了各种方法,废寝忘食,甚至好几天忘了打游戏,
在官方原版 ISO 的基础上做了一些定制, 解决在 MacBook Pro 上的一些问题,顺便更替了一些常用软件和配置
注意事项
- 仅供参考学习,部分组件需要额外的授权,除非你能友好的解决,否则,不要分发成品
- 每个步骤虽经过实际操作,但请根据实际情况 慎重选择 是否执行一些操作,否则可能会对某些 娇贵的 机器造成 永久性的硬件损伤
- 推荐在 Ext4 文件系统下操作,否则可能丢失文件的权限等信息
- 有任何意见和建议,请务必联系
环境 & 工具
- LinuxMint 19.1 (Kernel: 4.18.0-16-generic)
- VirtualBox
- 必备工具:
sudo apt install squashfs-tools xorriso isolinux
操作记录
初始化
sudo su
export V_KN_OLD=4.15.0-20
export V_KN_NEW=4.18.0-16
V_WORKSPACE=/home/zqq/some/custom-linuxmint
V_ISO_ORIGIN=/space/software/linuxmint-19.1-cinnamon-64bit.iso
V_MNT_ISO=/mnt/iso
V_CUSTOM_SRC=${V_WORKSPACE}/squashfs-root
V_ISO_SRC=${V_WORKSPACE}/iso-src
V_ISO_OUT=${V_WORKSPACE}/linuxmint-19.1-zqq.iso
V_ISO_TITLE="LINUXMINT_ZQQ"
准备 & 解压
mkdir -p ${V_WORKSPACE}
mkdir -p ${V_ISO_SRC}
mkdir -p ${V_MNT_ISO}
mount ${V_ISO_ORIGIN} ${V_MNT_ISO}
rsync -a --exclude=casper/filesystem.squashfs ${V_MNT_ISO}/ ${V_ISO_SRC}/
unsquashfs -d ${V_CUSTOM_SRC} ${V_MNT_ISO}/casper/filesystem.squashfs
umount ${V_MNT_ISO}
挂载 & chroot
mount --bind /var/cache/apt ${V_CUSTOM_SRC}/var/cache/apt
mount --bind /dev ${V_CUSTOM_SRC}/dev/
chroot ${V_CUSTOM_SRC}/
## 增加辨识
PS1="(chroot) $PS1"
LC_ALL=C
HOME=/root
export PS1 HOME LC_ALL
mount -t proc none /proc
mount -t sysfs none /sys
mount -t devpts none /dev/pts
mkdir -p /tmp/tools
mv /etc/resolv.conf /etc/resolv.conf.bak
echo 'nameserver 223.5.5.5' | tee /etc/resolv.conf
基本增删 (chroot)
## 先移除
apt purge thunderbird* rhythmbox* libreoffice-common transmission* tomboy hexchat* redshift xplayer-common xviewer xed-common
## 替换官方源
sed -i "s/http:\/\/packages.linuxmint.com/https:\/\/mirrors.tuna.tsinghua.edu.cn\/linuxmint/g" /etc/apt/sources.list.d/official-package-repositories.list
sed -i "s/http:\/\/archive.ubuntu.com\/ubuntu/http:\/\/mirrors.tuna.tsinghua.edu.cn\/ubuntu/g" /etc/apt/sources.list.d/official-package-repositories.list
## Ubuntu Kylin
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys D259B7555E1D3C58
echo "deb https://archive.ubuntukylin.com/ubuntukylin/ bionic main" > /etc/apt/sources.list.d/ubuntukylin.list
## Wine
dpkg --add-architecture i386
wget -q -O - https://dl.winehq.org/wine-builds/winehq.key | apt-key add -
echo "deb https://dl.winehq.org/wine-builds/ubuntu/ bionic main" > /etc/apt/sources.list.d/winehq.list
## Chrome
wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
echo "deb [arch=amd64] https://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google-chrome.list
## VS Code
wget -q -O - https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > /etc/apt/trusted.gpg.d/microsoft.gpg
echo "deb [arch=amd64] https://packages.microsoft.com/repos/vscode stable main" > /etc/apt/sources.list.d/vscode.list
apt update
apt dist-upgrade
apt autoremove
apt install linux-headers-${V_KN_NEW}-generic linux-image-${V_KN_NEW}-generic linux-modules-${V_KN_NEW}-generic linux-modules-extra-${V_KN_NEW}-generic linux-generic-hwe-18.04
apt purge linux-headers-${V_KN_OLD}-generic linux-image-${V_KN_OLD}-generic linux-modules-${V_KN_OLD}-generic linux-modules-extra-${V_KN_OLD}-generic
apt install \
tree \
vim \
git \
npm nodejs \
openjdk-8-jdk \
maven \
gedit \
meld \
code \
hardinfo \
autoconf automake libtool \
firefox-locale-zh-hans \
google-chrome-stable \
gimp gimp-help-en \
mint-meta-codecs \
vlc \
netease-cloud-music \
flameshot \
fcitx-ui-qimpanel fcitx-ui-classic fcitx-frontend-gtk2 fcitx-frontend-gtk3 fcitx-frontend-qt4 fcitx-frontend-qt5 fcitx-pinyin \
sogoupinyin \
wps-office \
bcmwl-kernel-source \
arc-theme \
fonts-noto-cjk fonts-noto-cjk-extra \
ttf-mscorefonts-installer \
language-pack-zh-hans language-pack-gnome-zh-hans \
dkms
apt install --install-recommends winehq-devel
## 更新 microcode
apt install intel-microcode amd64-microcode
## WPS 缺失的 symbol-fonts, 此处注意授权问题
wget -O /tmp/symbol-fonts_1.2_all.deb "http://linux.linuxidc.com/linuxconf/download.php?file=Li9saW51eGZpbGVzLzIwMTTE6tfKwc8vNNTCLzIwyNUvVWJ1bnR1IDE0LjA0ILCy17AgV1BTL3N5bWJvbC1mb250c18xLjJfYWxsLmRlYg=="
dpkg -i /tmp/symbol-fonts_1.2_all.deb
一些增加 (chroot)
安装字体: Adobe Source Code Pro
V_FONT_HOME=/usr/share/fonts/opentype/adobe-source-code-pro
mkdir -p $V_FONT_HOME
wget -P $V_FONT_HOME https://github.com/adobe-fonts/source-code-pro/releases/download/variable-fonts/SourceCodeVariable-Italic.otf
wget -P $V_FONT_HOME https://github.com/adobe-fonts/source-code-pro/releases/download/variable-fonts/SourceCodeVariable-Roman.otf
fc-cache -f -v "$V_FONT_HOME"
Arc Icons
cd /tmp/tools
git clone --depth 1 https://github.com/horst3180/arc-icon-theme.git && cd arc-icon-theme
./autogen.sh --prefix=/usr
make install
Applet: Cinnamenu
cd /tmp/tools
wget https://cinnamon-spices.linuxmint.com/files/applets/Cinnamenu@json.zip
unzip Cinnamenu@json.zip -d /usr/share/cinnamon/applets/
For Macbook Touchbar
cd /tmp/tools
echo -e "\n# applespi\napplespi\nspi_pxa2xx_platform\nintel_lpss_pci" >> /etc/initramfs-tools/modules
git clone --depth=1 https://github.com/roadrunner2/macbook12-spi-driver.git && cd ./macbook12-spi-driver
git checkout touchbar-driver-hid-driver
dkms add . && dkms install -m applespi -v 0.1
# lsinitramfs /boot/initrd.img-${V_KN_NEW}-generic | grep apple
# lib/modules/${V_KN_NEW}-generic/updates/dkms/applespi.ko
For Macbook Wifi
cd /tmp/tools
echo -e "\n# TP-LINK TL-WN722N\n8188eu" >> /etc/initramfs-tools/modules
git clone --depth=1 https://github.com/lwfinger/rtl8188eu.git && cd ./rtl8188eu
dkms add . && dkms install 8188eu/1.0
# lsinitramfs /boot/initrd.img-${V_KN_NEW}-generic | grep 8188eu
# lib/modules/${V_KN_NEW}-generic/kernel/drivers/net/wireless/8188eu.ko
Deepin Wine
最后务必要删除
/etc/apt/sources.list.d/deepin.list
## 事先安装冲突的包
apt install libxt6:i386
## 添加 Deepin 源
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 425956BB3E31DF51
echo "deb [by-hash=force] https://mirrors.tuna.tsinghua.edu.cn/deepin/ panda main contrib non-free" > /etc/apt/sources.list.d/deepin.list
apt update
## 之后千万不要 upgrade 或者安装其他任何组件,千万别手贱
apt install deepin-wine
V_TMP_DEEPIN_WINE=/tmp/deepin-wine-apps
mkdir -p ${V_TMP_DEEPIN_WINE}
cd ${V_TMP_DEEPIN_WINE}
wget https://mirrors.tuna.tsinghua.edu.cn/deepin/pool/non-free/d/deepin.com.thunderspeed/deepin.com.thunderspeed_7.10.35.366deepin18_i386.deb
wget https://mirrors.tuna.tsinghua.edu.cn/deepin/pool/non-free/d/deepin.com.weixin.work/deepin.com.weixin.work_2.4.16.1347deepin0_i386.deb
dpkg -i ${V_TMP_DEEPIN_WINE}/*.deb
## 修复依赖,如果遇到不一致的包,以 Linux Mint 为准,删掉包和源之后重试
apt install -f
## 删除源!!否则, 谁试一下告诉我会怎样。。。如果还活着。。。
rm /etc/apt/sources.list.d/deepin.list
apt-key remove 425956BB3E31DF51
apt update
修正首选应用程序
只是简单替换一下顺序,并不严谨 :-(
sed -i 's/gimp.desktop;pix.desktop;/pix.desktop;gimp.desktop;/g' /usr/share/applications/mimeinfo.cache
sed -i 's/gimp.desktop;xreader.desktop;/xreader.desktop;gimp.desktop;/g' /usr/share/applications/mimeinfo.cache
sed -i 's/vlc.desktop;netease-cloud-music.desktop;/netease-cloud-music.desktop;vlc.desktop;/g' /usr/share/applications/mimeinfo.cache
sed -i 's/gimp.desktop;pix.desktop;/pix.desktop;gimp.desktop;/g' /usr/share/applications/mimeinfo.cache
sed -i 's/google-chrome.desktop;firefox.desktop;/firefox.desktop;google-chrome.desktop;/g' /usr/share/applications/mimeinfo.cache
修正网易云音乐启动问题
参考:https://www.zhihu.com/question/277330447/answer/478510195
sed -i "s/Exec=netease-cloud-music %U/Exec=sh -c \"unset SESSION_MANAGER \&\& netease-cloud-music %U\"/g" /usr/share/applications/netease-cloud-music.desktop
更新配置
- 通用配置
- 可以使用
dconf dump /
dump 本机配置作为参考
mkdir -p /etc/dconf/profile/ /etc/dconf/db/local.d/
# 设置 dconf 配置
echo "
# custom dconf, by zqq
export DCONF_PROFILE=local
" > /etc/profile.d/50_dconf-local-custom.sh
echo "
user-db:user
system-db:local
" > /etc/dconf/profile/local
echo "
[org/cinnamon]
app-menu-icon-name='start-here-symbolic'
enabled-applets=['panel1:right:1:systray@cinnamon.org:0', 'panel1:left:3:grouped-window-list@cinnamon.org:3', 'panel1:right:2:keyboard@cinnamon.org:4', 'panel1:right:3:notifications@cinnamon.org:5', 'panel1:right:4:removable-drives@cinnamon.org:6', 'panel1:right:7:network@cinnamon.org:8', 'panel1:right:8:sound@cinnamon.org:9', 'panel1:right:9:power@cinnamon.org:10', 'panel1:right:10:calendar@cinnamon.org:11', 'panel1:left:0:Cinnamenu@json:12']
next-applet-id=13
favorite-apps=['firefox.desktop', 'netease-cloud-music.desktop', 'deepin.com.thunderspeed.desktop', 'vlc.desktop', 'deepin.com.weixin.work.desktop', 'gedit.desktop', 'code.desktop', 'meld.desktop', 'gnome-terminal.desktop', 'nemo.desktop', 'gimp.desktop', 'pix.desktop']
[org/cinnamon/desktop/interface]
font-name='Noto Sans CJK SC 10'
gtk-theme='Arc'
icon-theme='Arc'
[org/cinnamon/desktop/keybindings/media-keys]
terminal=['<Super>t']
[org/cinnamon/desktop/wm/preferences]
theme='Arc'
titlebar-font='Noto Sans CJK SC 8'
[org/cinnamon/theme]
name='Mint-Y-Dark-Aqua'
[org/gnome/desktop/interface]
document-font-name='Noto Sans CJK SC 11'
monospace-font-name='Source Code Variable 11'
[org/cinnamon/desktop/keybindings/custom-keybindings/custom0]
binding=['<Super>Print']
command='flameshot gui'
name='Flameshot'
[org/cinnamon/desktop/keybindings]
custom-list=['custom0']
[org/nemo/preferences]
show-open-in-terminal-toolbar=true
show-search-icon-toolbar=false
default-folder-viewer='list-view'
date-format='iso'
show-location-entry=true
[org/nemo/desktop]
computer-icon-visible=false
home-icon-visible=false
font='Noto Sans CJK SC 11'
[org/x/pix/browser]
thumbnail-list-visible=false
[org/nemo/plugins]
disabled-actions=['mint-artwork-cinnamon-thunderbird.nemo_action', 'set-as-background.nemo_action', 'send-by-mail.nemo_action', 'change-background.nemo_action']
[org/gnome/terminal/legacy/profiles:]
list=['b1dcc9dd-5262-4d8d-a863-c897e6d979b9']
[org/gnome/terminal/legacy/profiles:/:b1dcc9dd-5262-4d8d-a863-c897e6d979b9]
foreground-color='rgb(191,205,207)'
visible-name='default'
palette=['rgb(46,52,54)', 'rgb(204,0,0)', 'rgb(78,154,6)', 'rgb(196,160,0)', 'rgb(52,101,164)', 'rgb(117,80,123)', 'rgb(6,152,154)', 'rgb(211,215,207)', 'rgb(85,87,83)', 'rgb(239,41,41)', 'rgb(138,226,52)', 'rgb(252,233,79)', 'rgb(114,159,207)', 'rgb(173,127,168)', 'rgb(52,226,226)', 'rgb(238,238,236)']
default-size-columns=110
default-size-rows=32
use-system-font=false
use-transparent-background=true
use-theme-colors=false
font='Source Code Variable Medium 12'
use-theme-transparency=false
background-color='rgb(0,43,54)'
background-transparency-percent=4
" > /etc/dconf/db/local.d/50_custom_settings
rm /etc/dconf/db/local
dconf update
- User Dirs
mkdir -p /etc/skel/.config/ \
/etc/skel/Desktop/ \
/etc/skel/downloads/ \
/etc/skel/.templates/ \
/etc/skel/documents/ \
/etc/skel/public/ \
/etc/skel/music/ \
/etc/skel/pictures/ \
/etc/skel/videos/
echo '
XDG_DESKTOP_DIR="$HOME/Desktop"
XDG_DOWNLOAD_DIR="$HOME/downloads"
XDG_TEMPLATES_DIR="$HOME/.templates"
XDG_DOCUMENTS_DIR="$HOME/documents"
XDG_PUBLICSHARE_DIR="$HOME/public"
XDG_MUSIC_DIR="$HOME/music"
XDG_PICTURES_DIR="$HOME/pictures"
XDG_VIDEOS_DIR="$HOME/videos"
' > /etc/skel/.config/user-dirs.dirs
- 移除部分语言包的依赖
TODO: 升级可能导致被覆盖
sed -i "/ibus-table-wubi/d" /usr/share/language-selector/data/pkg_depends
sed -i "/fcitx-table-wubi/d" /usr/share/language-selector/data/pkg_depends
sed -i "/fcitx-module-cloudpinyin/d" /usr/share/language-selector/data/pkg_depends
sed -i "/fcitx-sunpinyin/d" /usr/share/language-selector/data/pkg_depends
sed -i "/fcitx-table-wubi/d" /usr/share/language-selector/data/pkg_depends
sed -i "/fonts-arphic-uming/d" /usr/share/language-selector/data/pkg_depends
sed -i "/fonts-arphic-ukai/d" /usr/share/language-selector/data/pkg_depends
- Firefox
TODO: 可能会被覆盖
sed -i "/browser.startup.homepage=/d" /usr/lib/firefox/distribution/distribution.ini
echo '
browser.startup.homepage="about:blank"
' >> /usr/lib/firefox/distribution/distribution.ini
echo '
pref("browser.uiCustomization.state", "{\"placements\":{\"widget-overflow-fixed-list\":[],\"nav-bar\":[\"back-button\",\"forward-button\",\"stop-reload-button\",\"urlbar-container\",\"search-container\",\"downloads-button\"],\"toolbar-menubar\":[\"menubar-items\"],\"TabsToolbar\":[\"tabbrowser-tabs\",\"new-tab-button\",\"alltabs-button\"],\"PersonalToolbar\":[\"personal-bookmarks\"]},\"seen\":[\"developer-button\"],\"dirtyAreaCache\":[\"nav-bar\",\"widget-overflow-fixed-list\"],\"currentVersion\":15,\"newElementCount\":4}");
pref("browser.startup.homepage", "about:blank");
pref("browser.tabs.drawInTitlebar", true);
pref("browser.uidensity", 1);
pref("browser.newtabpage.enabled", false);
' > /etc/firefox/syspref.js
收尾
重建 initrd
update-initramfs -u -k $(uname -r)
mkinitramfs -c lzma -o /tmp/initrd.lz
退出 chroot & 卸载
dpkg-query -W --showformat='${Package} ${Version}\n' > /tmp/filesystem.manifest
rm -rf /root/.wget-hsts /var/lib/dbus/machine-id
mv /etc/resolv.conf.bak /etc/resolv.conf
umount /dev/pts
umount /sys
umount /proc
exit
umount ${V_CUSTOM_SRC}/var/cache/apt
umount ${V_CUSTOM_SRC}/dev/
更新 Kernel & manifest
mv ${V_CUSTOM_SRC}/tmp/filesystem.manifest ${V_ISO_SRC}/casper/
## 保留 GParted,这么好用的工具怎么能删掉呢
sed -i '/gparted/d' ${V_ISO_SRC}/casper/filesystem.manifest-remove
rm ${V_CUSTOM_SRC}/boot/initrd.img-${V_KN_NEW}-generic.old-dkms
cp ${V_CUSTOM_SRC}/tmp/initrd.lz ${V_ISO_SRC}/casper/
cp ${V_CUSTOM_SRC}/boot/vmlinuz-${V_KN_NEW}-generic ${V_ISO_SRC}/casper/vmlinuz
打包 ISO
rm -rf ${V_CUSTOM_SRC}/tmp/* \
${V_CUSTOM_SRC}/root/.bash_history
rm ${V_ISO_SRC}/casper/filesystem.squashfs
mksquashfs ${V_CUSTOM_SRC} ${V_ISO_SRC}/casper/filesystem.squashfs
cd ${V_ISO_SRC}
find -type f -print0 | xargs -0 md5sum | grep -Ev "./MD5SUMS|./isolinux/" > ${V_ISO_SRC}/MD5SUMS
sudo xorriso -as mkisofs \
-r -V "${V_ISO_TITLE}" -R -l -o ${V_ISO_OUT} \
-c isolinux/boot.cat -b isolinux/isolinux.bin \
-no-emul-boot -boot-load-size 4 -boot-info-table \
-isohybrid-mbr /usr/lib/ISOLINUX/isohdpfx.bin \
-eltorito-alt-boot \
-e boot/grub/efi.img \
-no-emul-boot -isohybrid-gpt-basdat ${V_ISO_SRC}
Tips
- 可以使用 VirtualBox 测试生成的 ISO
- 不需要 “刻录” 到 U 盘, 强大的 EFI + Grub2 来帮你,硬盘安装就可以
menuentry "Install LinuxMint ZQQ" {
set isofile="/boot/iso/linuxmint-19.1-zqq.iso"
echo "Search $isofile ..."
search --file $isofile --set=root
echo "Loopback $isofile ..."
loopback loop $isofile
echo "vmlinuz ..."
linux (loop)/casper/vmlinuz persistent boot=casper iso-scan/filename="$isofile" acpi_osi="Linux" quiet splash locale=zh_CN.UTF-8 noprompt --
echo "initrd ..."
initrd (loop)/casper/initrd.lz
}
参考
更新记录
TODO
- feat: Firefox 搜索引擎
- feat: 修改 Applets 默认配置
- install preload ?
- Kernel 5.0
- install openconnect network-manager-openconnect
2019-03-12
- 变更: 使用 dconf system-db 的方式设置默认参数, 不再使用
/usr/share/glib-2.0/schemas/nn_mint-artwork-custom.gschema.override
的方式 - 配置:Terminal, Pix, Nemo 等
- 配置:全局快捷键
- 配置:应用收藏夹
- 新增:安装字体 Adobe Source Code Pro
2019-03-16
- 修复:网易云音乐无法启动问题
- 新增:安装 linux-generic-hwe-18.04
- 新增:安装 gimp-help-en
- 配置:设置 User Dirs
- 配置:移除部分语言包的依赖
- 配置:Terminal 字体