LFS 学习日记(第七章 syslogd 配置至本章结束 )

2010年10月19日 星期二
/LFS-BOOK-6.6-HTML/chapter07/sysklogd.html
Chapter 7. Setting Up System Bootscripts

todo: 读懂脚本  /etc/rc.d/init.d/sysklogd /LFS-BOOK-6.6-HTML/scripts/apds16.html

/LFS-BOOK-6.6-HTML/chapter07/inputrc.html
7.7. Creating the /etc/inputrc File

todo: 读懂配置文件: /etc/inputrc

/LFS-BOOK-6.6-HTML/chapter07/profile.html
7.8. The Bash Shell Startup Files

cat > /etc/profile << "EOF"
# Begin /etc/profile

export LANG=zh_CN.UTF-8

# End /etc/profile
EOF

“C” 和 "en_US" locale 是不一样的,前者是7位编码,会将含有高位的字符识别为无效字符。
UTF-8 编码现在还不能被许多程序很好的支持。

todo: 在 BLFS 中阅读理解 Locale Related Issues http://www.linuxfromscratch.org/blfs/view/svn/introduction/locale-issues.html

翻译bug:
The “C” (default) and “en_US” (the recommended one for United States English users) locales are different. “C” uses the US-ASCII 7-bit character set, and treats bytes with the high bit set as invalid characters. That's why, e.g., the ls command substitutes them with question marks in that locale. Also, an attempt to send mail with such characters from Mutt or Pine results in non-RFC-conforming messages being sent (the charset in the outgoing mail is indicated as “unknown 8-bit”). So you can use the “C” locale only if you are sure that you will never need 8-bit characters.
“C“(默认) 和 “en_US“(推荐美国英语用户使用) locale 是不同的。“C” 使用 US-ASCII 7-bit 字符集,把含有高位的字节视为无效字符。这就是像 ls 命令在那种 locale 里面用问号代替它们的原因。而且,试图从 Mutt 或者 Pine 发送这种字符集的邮件会导致发送不符合 RFC 规范的信息(发出邮件的字符集被标示为"unknown 8-bit")。所以,只有你确定你永远不需要 8-bit 字符才可以使用 “C“ locale。

2010年10月20日 星期三
/LFS-BOOK-6.6-HTML/chapter07/udev.html
7.9. Device and Module Handling on an LFS System

English: It is generally accepted that if device names are allowed to be configurable, then the device naming policy should be up to a system administrator, not imposed on them by any particular developer(s).

todo: 这一节比较陌生,读不太懂,有必要时再深入了解。

/LFS-BOOK-6.6-HTML/scripts/apds06.html
D.6. /etc/rc.d/init.d/udev

question: 为什么 Ubuntu 10.04 中的 /etc/mtab 里面有 /dev 目录呢?它就不怕 /dev 无效呢? 在 LFS 中 /dev 无效会有什么后果? 另:在 Ubuntu 10.04 中 sudo umount -a 会显示: umount: /dev: device is busy.
        (In some cases useful info about processes that use
         the device is found by lsof(8) or fuser(1))
之类的信息,/dev 仍然不能被卸载。

question:  # Udev handles uevents itself, so we don't need to have
        # the kernel call out to any binary in response to them
        echo > /proc/sys/kernel/hotplug

hotplug 的作用是什么?

question:  # Now traverse /sys in order to "coldplug" devices that have
        # already been discovered
        /sbin/udevadm trigger
什么作用?

/LFS-BOOK-6.6-HTML/chapter07/symlinks.html
7.10. Creating Custom Symlinks to Devices

1、因为有些软件有特殊的需要,所以要创建到设备的固定名称的链接。链接策略是 “by-id“ 或者 “by-path“。

2、像U盘之类的移动设备理所当然要选择“by-id“了。

3、要启动U盘之类的移动设备,现在使用 uuid 是最合适的了,因为这个标志是唯一的,就存在于磁盘中,到哪儿都不变。

4、在 Udev 中,内核识别的设备名称也许会改变,但是可以根据唯一性的标志编写规则文件,让一个固定的设备名称链接到固定的物理设备。

question: U盘和硬盘有 uuid,光盘有没有 uuid ? 如果没有是为什么?

bug: sed -i -e 's/write_cd_rules/& mode/' \
    /lib/udev/rules.d/75-cd-aliases-generator.rules
Because there is "write_cd_rules by_id" in file "/lib/udev/rules.d/75-cd-aliases-generator.rules" already, so this command will produce text such as "write_cd_rules by_path by_id".

2010年10月22日 星期五
/LFS-BOOK-6.6-HTML/chapter07/hostname.html
7.11. Configuring the localnet Script

/LFS-BOOK-6.6-HTML/scripts/apds14.html
D.14. /etc/rc.d/init.d/localnet

question: ip addr add 127.0.0.1/8 label lo dev lo
127.0.0.1/8 是否表示ip是127.0.0.1,255.0.0.0 的子网掩码?与用 ifconfig 设置网络有什么区别?
参见:从ip addr add和ifconfig的区别看linux网卡ip地址的结构
http://blog.chinaunix.net/u3/108940/showart_2236745.html

todo: 有必要时认真学习一下网络相关知识。

question: 192.168.1.0/24 与 192.168.1.0/25 的区别?
参见:http://zhidao.baidu.com/question/133311987

todo: 学习子网掩码
参考:http://baike.baidu.com/view/878.htm

/LFS-BOOK-6.6-HTML/chapter07/hosts.html
7.12. Customizing the /etc/hosts File

因为我的 lfs 不会对外外提供服务,所以 /etc/hosts 中的:
<192.168.1.1> <HOSTNAME.example.org> [alias1] [alias2 ...]
设为:
192.168.1.229 lfs

/LFS-BOOK-6.6-HTML/chapter07/network.html
7.13. Configuring the network Script

english: In some cases, after a reboot the cards get renumbered the other way around.

for NIC in /sys/class/net/* ; do
    INTERFACE=${NIC##*/} udevadm test --action=add $NIC
done

INTERFACE=${NIC##*/}
/abs-guide/parameter-substitution.html
${var#Pattern}, ${var##Pattern}
${var#Pattern}  Remove from $var  the shortest part of $Pattern that matches the front end of $var.
${var##Pattern} Remove from $var the longest part of $Pattern that matches the front end of $var.

example:
echo "$PWD" #/home/mdx/test
echo "${PWD##*/}" #test (*/ 作为移除的最大匹配部分是:/home/mdx/)
echo "${PWD#*/}" #home/mdx/test (*/ 作为移除的最小匹配部分是:最前面的/)

/etc/udev/rules.d/70-persistent-net.rules
DRIVERS=="?*"

/abs-guide/special-chars.html
?
    wild card. The ? character serves as a single-character "wild card" for filename expansion in globbing, as well as representing one character in an extended regular expression.

*
The * also represents any number (or zero) characters in a regular expression.

这个字段的意思是说:"DRIVERS"字段至少都有一个字符,不为空 This exists so that Udev will ignore VLAN or bridge sub-interfaces (because these sub-interfaces do not have drivers).

question:
ATTR{type}=="1" - This ensures the rule only matches the primary interface in the case of certain wireless drivers, which create multiple virtual interfaces.
什么是主接口(primary interface)?

KERNEL=="eth*" 有什么用?

question:
Which interfaces are brought up and down by the network script depends on the files and directories in the /etc/sysconfig/network-devices hierarchy.
在 LFS 里面,有关设置放在 /etc/sysconfig/network-devices/ 目录层次中,而在 Ubuntu 10.04 中,有关设置是放在 /etc/network/ 目录层次中,它们是通过哪个脚本进行控制的?这种控制是一个软件的标准还是各个系统各自不同的组织方式?

如果不使用网络,那么这节和相关的配置文件就没有必要的。

question:
如果完全不会使用网络,那么 /etc/hostname /etc/hosts 这些配置文件需要吗?是否取决于系统中要使用的程序吗?

/abs-guide/comparison-ops.html

-z
    string is null, that is, has zero length

-n
    string is not null.

todo:
有必要时读懂脚本:
/LFS-BOOK-6.6-HTML/scripts/apds25.html
D.25. /etc/sysconfig/network-devices/ifup

elif [ -d "${network_devices}/ifconfig.${1}" ]; then
    FILES=`echo ${network_devices}/ifconfig.${1}/*`

http://linux.about.com/od/bgb_guide/a/gdebgb56t01.htm 7.2.2. if/then/elif/else constructs

    if [ "${file}" != "${file%""~""}" ]; then
        continue
    fi

/abs-guide/parameter-substitution.html
${var%Pattern}, ${var%%Pattern}

    ${var%Pattern} Remove from $var the shortest part of $Pattern that matches the back end of $var.
    ${var%%Pattern} Remove from $var the longest part of $Pattern that matches the back end of $var.
举例:
mdx@eee:~$ L="sTEWFSTT"
mdx@eee:~$ echo ${L%T*}
sTEWFST
mdx@eee:~$ echo ${L%%T*}
s

但是上面为什么有两对双引号? ""~""

todo:
有必要时读懂脚本:
/LFS-BOOK-6.6-HTML/scripts/apds26.html
D.26. /etc/sysconfig/network-devices/ifdown

todo: 配置 /etc/resolv.conf 文件

cat > /etc/resolv.conf << "EOF"
# Begin /etc/resolv.conf

domain
nameserver 192.168.1.1

# End /etc/resolv.conf
EOF

因为我是本机使用,没有域名,所以 domain 留空,不知有问题没有?我看了一下 Ubuntu 10.04 的 /etc/resolv.conf 里面没有 domain 这个值。