Debian Live 是一款制作可从移动介质直接启动的 Linux 系统的工具,支持生成 iso 镜像,USB 磁盘镜像和 NFS 镜像。
Debian Live 定制性很强,下面简单介绍几项定制内容:
1. 定制 Debian Mirror 地址
如果你的工作机无法访问官方 mirror,一定要通过下面 lh_config 的 5 个参数,配置可以访问的 mirror:
lh_config
[-m|--mirror-bootstrap URL]
[--mirror-binary URL]
[--mirror-binary-security URL]
[--mirror-chroot URL]
[--mirror-chroot-security URL]
2. 定制 syslinux splash 图像
syslinux 使用一种特殊的图像格式(RLE 或 LSS),需要用下面的方法准备:
- 用 GIMP 编辑图像,不要超过 640×400。
- 设置为 14 Indexed Color。如果图像已经为 Indexed Color,但超过 14 种,应该先转换成 RGB 格式,再转换回 14 Indexed Color
- 另存为 PPM 格式
- 使用 syslinux 包中的 ppmtolss16,将 PPM 图像转换成 LSS
ppmtolss16 '#d0d0d0=7' < splash.ppm > splash.rle
得到 LSS 格式的图像之后,需要:
- 放入 config/binary_syslinux/ 下,假设文件名为 splash.rle
- 同时修改 config/binary,设置:
LH_SYSLINUX_SPLASH="config/binary_syslinux/splash.rle"
然后 lh_clean && lh_build 生成新的镜像。
3. 定制默认用户配置
Debian 以及其他 Linux 发行版在创建新用户时,会将 /etc/skel 目录下的所有文件复制到新用户 HOME 目录下。借助这一特色,可以通过将配置文件放在 /etc/skel 目录下,起到默认配置的作用。
Debian Live 系统每次启动时会生成全新用户 HOME 目录,同样会拷贝 /etc/skel 目录下的所有文件。因此需要将配置文件放入 Debian Live 系统的 /etc/skel 目录下。
在 config/chroot_local-includes/ 目录下,创建 etc/skel 子目录,在生成 binary 时,这些文件会自动拷贝到文件系统上。
lh_clean && lh_build 生成新的镜像。
4. 定制 splashy
splashy 可以在系统启动时,显示图形化的进度栏。splashy 的定制过程如下:
- 创建 config/chroot_local-hooks/01-splash.sh:
#!/bin/sh
splashy_config -s debian-moreblue || true
update-initramfs -u -k all
- chmod +x config/chroot_local-hooks/01-splash.sh
- 修改 config/chroot 文件,LH_PACKAGES 后增加两个包:splashy splashy-themes
最后,lh_clean && lh_build 生成新的镜像。
5. 定制 usplash
usplash 与 splash 类似,同样可以显示图形化启动进度。由于 splashy 不支持 initramfs,有一部分启动过程无法图形化,而 usplash 能弥补这一缺陷。
- 参照 splashy 前两步,生成同样的 01-splash.sh 可执行脚本
- 修改config/chroot 文件,LH_PACKAGES 后增加两个包:usplashy usplash-theme-debian
最后,lh_clean && lh_build 生成新的镜像。
6. 最小化生成 image
通常减少 Debian/Linux 系统空间的方法无外乎:1 删除不用的 locale 信息,2 删除 APT 缓存。可以参照上面定制过程,在 config/chroot_local-hooks/ 目录下,创建 hooks 脚本实现。
- 首先,修改config/chroot 文件,LH_PACKAGES 后添加 localepurge
- 创建 config/chroot_local-hooks/99-clean.sh 文件:
#!/bin/sh
rm -r /var/lib/apt/lists/mirror.ivic.org.cn*
rm -r /var/cache/apt/*.bin
debconf-set-selections <<EOF
debconf localepurge/nopurge select en, en_US.UTF-8
debconf localepurge/nopurge seen true
debconf localepurge/mandelete select true
debconf localepurge/mandelete seen true
debconf localepurge/dontbothernew select false
debconf localepurge/dontbothernew seen true
debconf localepurge/showfreedspace select true
debconf localepurge/showfreedspace seen true
debconf localepurge/verbose select false
debconf localepurge/verbose seen true
debconf localepurge/quickndirtycalc select true
debconf localepurge/quickndirtycalc seen true
EOF
dpkg-reconfigure -u -phigh localepurge
- chmod +x config/chroot_local-hooks/99-clean.sh
最后 lh_clean && lh_build 生成新的镜像。
7. 使用 fluxbox
fluxbox 是一款小巧的 X Window Manager。生成使用 fluxbox 的 Debian Live 系统的过程如下:
- 修改config/chroot 文件,LH_PACKAGES_LISTS 后添加 fluxbox(替换 xfce/gnome/kde 等)
- 创建 chroot_local-packageslists/fluxbox,内容如下:
## LH: Fluxbox
#include <standard-x11>
fluxbox gdm
##desktop-base
最后 lh_clean && lh_build 生成新的镜像。
debconf 是 Debian 使用的一种软件包配置方法。支持 debconf 的软件在安装时,会弹出对话框,要求用户输入一定配置参数。
在非交互式环境下安装这类软件,用户无法在线提供软件的配置项。因此用户需要通过 dpkg-preconfigure 预先指定软件配置。
目前 dpkg-preconfigure 的用法比较奇怪。没有非常完美的用法,总觉得怪怪的。下面这个方案应该是我从网上可以找到,综合比较靠谱的。
1. 导入 debconf 模板
debconf 模板包含软件的配置项的名称、说明、默认值等内容。一般来说 debconf 模板是包含在 deb 包中。由于需要在安装 deb 时自动提供软件配置,所以需要在安装 deb 包之前,提前导入 debconf 模板。过程如下。
- apt-get clean (清除 apt/cache 中缓存的 Debian 包)
- apt-get install -d mysql-server-5.0 (下载 mysql-server-5.0,不安装)
- dpkg-preconfigure /var/cache/apt/archives/mysql-server-5.0*.deb (导入 debconf 模板)
不完美的地方就在这里:导入一个软件的配置项,竟然要用三个命令。总觉得应该一个命令搞定。。。
2. 指定 debconf 配置
模板导入之后,可以使用 debconf-set-selections 设置软件配置。用下面的命令:
# debconf-set-selections
debconf mysql-server-5.0/start_on_boot select true
debconf mysql-server-5.0/start_on_boot seen true
(ctrl+d)
上面命令将 mysql-server-5.0/start_on_boot 设置为 true,并且设置配置项已经显示(区分配置项的值是默认值,还是用户输入值)。一般来说,软件安装时,只会显示 seen 为 false 的那些配置参数。
如果不知道软件有哪些配置选项,可以用 debconf-show 看到:
# debconf-show mysql-server-5.0
mysql-server/root_password_again: (password omitted)
* mysql-server/root_password: (password omitted)
mysql-server-5.0/really_downgrade: false
mysql-server-5.0/need_sarge_compat: false
mysql-server-5.0/start_on_boot: true
mysql-server/error_setting_password:
mysql-server-5.0/nis_warning:
mysql-server-5.0/postrm_remove_databases: false
mysql-server-5.0/need_sarge_compat_done: true
mysql-server/password_mismatch:
上面每行输出中第一个 * 表示 seen 为 true,没有星号表示 seen 为 false;每行输出中,冒号前面配置项,冒号后是值。
3. 安装软件
如果所有的 debconf 选项都通过上面的方法设置完毕。用下面的方法安装
apt-get install mysql-server-5.0
此时应该不会显示 debconf 的对话框。
设置 Thunderbird 的参数,适合显示 Plaintext 邮件。
Account Settings
- Copies & Folders -> Place a copy in -> "Sent" Folder on -> Local Folders
- Bcc these email addresses
- Composition & Addressing
- Compose message in HTML format
- Automatically quote the original message when replying -> start my reply above the quote
- Junk Settings -> Trust junk mail headers set by -> SpamAssassin
Menu View
- Sort by -> Threaded
- Message Body As -> Simple HTML
- Character Encoding -> Auto-Detect -> Simplified Chinese
Tools –> Options –> Display -> Formatting
- Background Color -> Grey
- Plain Text Messages
- Display emoticons as graphics -> off
- Size -> Smaller
- Fonts & Encodings -> Fonts -> Character Encodings
- Fonts for -> Western
- Proportional Size (pixels) -> 13
- Monospace Szie (pixels) -> 13
- Minimum font size -> 12
- Allow message to use other fonts
- Outgoing Mail -> UTF-8
- Incoming Mail -> GBK
Tools –> Options –> Compositions -> General
- Forward messages -> As Inline
- HTML -> Fonts -> Fixed Width
- Send Options -> Text Format -> Convert the message to plain text
Tools –> Options –> Advanced
- Network & Disk space -> Offline
- Send unsent messages when going online -> Yes
- Download messages for offline use when going off line -> No
- General -> Config Editor
- mailnews.display.disable_format_flowed_support -> true
- mailnews.send_plaintext_flowed -> false
- font.name.monospace.x-western -> 宋体
如果发现 ssh 连接主机很慢,一般来说并不是公钥认证的过程耗时,最有可能的原因是 sshd 试图对 remote client address 做一次 DNS 反解析。
可以修改 /etc/ssh/sshd_config 文件,在文件最后加上一行(如果已存在 UseDNS 这个选择则修改)
UseDNS no
然后重启 ssh 即可
/etc/init.d/ssh restart
iPhone 和 PSP 都支持播放 MP4 格式的视频。MP4 基于 Apple 的 QuickTime MOV 视频格式标准,是目前支持度最高的一种视频格式,多数的手机和移动设备,在播放 MP4 视频的时候都具有硬件优化。
但 iPhone 和 PSP 支持的视频要求略有不同。在视频转换的时候,如果不加以注意,生成的视频往往只能在一种设备上播放。
这给同时具有PSP、iPod Touch 和 PC 机的我带来很大的视频管理难题:同样一部影片,需要下载、保存三份:PSP、iPhone,再加上 PC。不但浪费空间,浪费下载带宽和时间,而且考虑到现在 MP4 视频的下载没有像 HDTV、DVDRip 那样成熟的下载渠道,更是加剧了这方面的困难。
如果可以生成 MP4 视频,使得 PSP,iPhone/iPod Touch,还有电脑(显然)都可以播放,就可以一举解决这个问题。
为了完成上述目标,我用 ffmpeg 写了一个转换脚本(用文件名替换%1)。生成的 MP4 文件属性如下
- 分辨率:480×272。这是 PSP 和 iPhone 都能播放的最高分辨率。(其实两种设备都支持 640×480 分辨率,但该分辨率下,无法保证 PSP 和 iPhone 都兼容)
- 视频编码:420kbps H.264。
- 音频编码:16位双声道,64kbps
- PSP 兼容参数:refs=2 (PSP 最多支持两个参考帧)
- iPhone 兼容参数:coder=0 bf=0 flags2=-wpred-dct8x8 (iPhone 不支持熵编码,不支持 B 帧)
ffmpeg -i %1 -r 25 -threads 2 -s 480x272 -y -vcodec libx264 -an -pass 1 -flags +loop -cmp +chroma -partitions -parti8x8-parti4x4-partp8x8-partp4x4-partb8x8 -me_method dia -subq 1 -me_range 16 -g 250 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -b_strategy 1 -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 -directpred auto -trellis 0 -level 21 -coder 0 -bf 0 -flags2 -wpred-dct8x8 -refs 2 -b 420k -bt 420k -ab 64k -ar 48000 -ac 2 -f mp4 pass1.tmp
ffmpeg -i %1 -r 25 -threads 2 -s 480x272 -y -vcodec libx264 -acodec libfaac -pass 2 -flags +loop -cmp +chroma -partitions +parti8x8+parti4x4+partp8x8+partb8x8 -me_method umh -subq 8 -me_range 16 -g 250 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -b_strategy 2 -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 -directpred 3 -trellis 1 -level 21 -coder 0 -bf 0 -flags2 -wpred-dct8x8 -refs 2 -b 420k -bt 420k -ab 64k -ar 48000 -ac 2 -f mp4 %1.mp4
现在绿坝争论的关键分歧在于:大众认为绿坝是强制安装的,因此认为自己的权利受到了侵害;而官方一再强调,用户可以自行卸载该软件,因此不认为该软件具有强制性。
因此这根本不是一场争锋相对的辩论,双方基于上述假设的论点都打在了空处。
我觉得在争论中,应着重强调两点:
- 首先,“绿坝可卸载”这一事实有待商榷。有人说普通的卸载操作仍然会在系统中留下残留文件。现在已经出现了若干绿坝专杀。
- 其次,即使“绿坝可卸载”,仍然不能捆绑安装。
下面解释:为什么不能捆绑安装。
原因很简单:系统安全。已经有研究人员在半天时间内,发现绿坝中多处包含的易受缓冲区溢出攻击的漏洞。
这一事实表明,绿坝的开发人员缺乏系统软件方面的编程经验,缺乏开发符合一定安全要求的软件的素养,导致漏洞百出。
如果允许用户自行安装绿坝,黑客或许很难发现哪些机器因安装了绿坝而易受攻击。但捆绑销售这类漏洞百出的软件,将会造成更大的危害。因为所有计算机都是黑客的攻击目标。
因此,不光是绿坝,所有捆绑销售的软件,由于其预装在系统中这一特性,其漏洞特别容易被黑客或者病毒利用而被攻破,应该用操作系统级别的安全规范去要求这些软件。除非绿坝能够像微软看齐,软件开发中避免不安全的函数调用,定期出安全公告和安全更新,不断修改固化软件的功能。否则不应该捆绑销售这类软件。
Recent Comments