显示标签为“ts”的博文。显示所有博文
显示标签为“ts”的博文。显示所有博文

星期二, 十二月 18, 2007

postfix inet_interfaces 问题

一个报警脚本,发邮件出现问题,重定向输出中包含如下报错:
send-mail: fatal: parameter inet_interfaces: no local interface found for 124.74.193.221
,/var/log/maillog 中的记录为:
Dec 16 12:09:24 www2 postfix/pickup[30784]: fatal: parameter inet_interfaces: no local interface found for 124.74.193.221
Dec 16 12:09:25 www2 postfix/master[23234]: warning: process /usr/libexec/postfix/pickup pid 30784 exit status 1
Dec 16 12:09:25 www2 postfix/master[23234]: warning: /usr/libexec/postfix/pickup: bad command startup -- throttling
重启 postfix,即 /etc/init.d/postfix restart 失败,/var/log/maillog 中的输出为:
Dec 18 10:28:16 www2 postfix/master[23234]: terminating on signal 15
Dec 18 10:28:17 www2 postfix/sendmail[11621]: fatal: parameter inet_interfaces: no local interface found for 124.74.193.221
Dec 18 10:28:25 www2 postfix[11627]: fatal: parameter inet_interfaces: no local interface found for 124.74.193.221
Dec 18 10:28:26 www2 postfix/sendmail[11629]: fatal: parameter inet_interfaces: no local interface found for 124.74.193.221
Dec 18 10:28:27 www2 postfix[11630]: fatal: parameter inet_interfaces: no local interface found for 124.74.193.221
Dec 18 10:28:29 www2 postfix/sendmail[11632]: fatal: parameter inet_interfaces: no local interface found for 124.74.193.221
但是这台主机的 IP 地址是 124.74.193.211,为什么会出现 221 呢?

因为前两天因为发邮件,将原来指向该主机的一个域名重新定向到了 124.74.193.221,在 /etc/postfix/main.cf 中的配置为:
myhostname = mail.groups.shopex.cn
inet_interfaces = $myhostname, localhost, 124.74.193.211, 192.168.0.211
而此时 mail.groups.shopex.cn 已经解析到 124.74.193.221,这样 postfix 会先做解析,结果就不对了。

postfix inet_interfaces 有参数可以指定不使用 DNS,应该是加 [] 的方式。

星期三, 十月 31, 2007

"Permission Denied" when load php module (SELinux)

Cannot load /usr/local/apache2/modules/libphp4.so into server: /usr/local/apache2/modules/libphp4.so : cannot restore segment prot after reloc: Permission Denied
这个错误是因为打开了 RedHat 的 SELinux,关闭就可以了。

另外,在编译 php 时使用了 --enable-gd-native-ttf 和 --with-gd=/usr/local 参数,待同样报告类似的错误:
/usr/local/lib/libgd.so.2: cannot restore segment prot after reloc: Permission Denied
,同样也是 SELinux 造成的。

星期二, 十月 09, 2007

数据库连接与 /etc/hosts 设置

上次数据库出问题后更换了主机,但之后时常出现"Can not connect to database"的错误,考虑了若干中可能,但最有效的还是先查看系统日志 /var/log/message:
Oct  9 10:49:31 shopex mysqld: gethostby*.getanswer: asked for "210.0.168.192.in-addr.arpa IN PTR", got type "A"
...
Oct 9 10:49:32 shopex mysqld: gethostby*.getanswer: asked for "210.0.168.192.in-addr.arpa IN PTR", got type "A"
这说明是地址解析的问题,mysqld 中设置了反向 DNS 解析。一般只需要在 /etc/hosts 中增加相应的记录即可:
192.168.0.210   www

星期六, 九月 29, 2007

福无双至,祸不单行

Prima 的那一套东西实在不敢恭维。本来软件的一个目的就是要和硬件分离,结果他们搞的许可证和硬件绑在一起,令人深受其害。而且其可管理性也不好,只能按单个主机的方式排列,如果想要实现真正的集群,那似乎是没有希望了。

昨天下午 wdwd 重启了一次(搬机器的时候掉电了),本来已经忙了一天了——早上肚子里还在翻江倒海,数据库的硬盘就坏了,想找个替手的人都没有(就我一个 SA),急急忙忙处理了备份恢复,检测确诊,写笔记,中间还时不时抛过来一些杂七杂八的事情,然后又要和机房联系,急急忙忙跑过去把损坏的硬盘拿出来,在机房磨了两个小时,做 ts,——晚上回去还没进门,同事打电话跟我说发现所有的新的订单都变成“待处理”,听说上线的消息已经在各大网站发布(反正没给我说过,也没有接到过消息,反正是他们这些老板出钱,又有关系,他们想怎么干就怎么干好了,何必问我们)。 Prima 没有其他报警机制,只好回去查后台和日志,发现"License not match"。但这个 license 是昨天刚刚申请的正式授权证书,之前是运行“正常”的!

我尝试重新上载那个授权证书,结果报告“序列号不符”。解开证书的压缩包,查看 license.info 中的 serial,确实与 /usr/prima/bin/print_serial 的结果不一样。再次重启这台主机,发现序列号又变了!

从昨天晚上折腾到今天下午(晚上别指望能找到人),最后查出来原因是主机每次启动的时候,板载的那块网卡会自动改变 MAC 地址!!!而 Prima 的许可证要根据所谓 CPU 个数、频率和网卡 MAC 地址来生成序列号,然后授权证书要用到这个序列号,一套很复杂的设置,晕 @_@~~~

最后,只好在系统 /etc/rc.d/rc.local 里面每次启动时自动改一下 MAC 地址:
/sbin/ifconfig eth0 hw ether 00:00:6C:92:4E:19
我后来问 Prima 是不是我更换网卡后把新网卡的 MAC 地址设置和以前一样就可以,回复说没有测过。没有测过!!!其实他们没有测过的东西也不少了,耗了我不少时间精力。我个人感觉 Prima 就是一个坑,一台主机什么都干的单主机排列的方式不利于实现集群和扩展,而且这种许可证方法使得高可用的代价更高了,和硬件绑定也不是什么好事 ... 商业软件,反而让人更不放心。

其实不仅他们没有严格测过,我们现在在生产线上的那些东西,其实大多也都没有严格测过,很多都是急急忙忙逼着上线,最多手工运行看看。大家都在急功近利,想着怎么尽快捞钱,成本就转嫁给下面的人去扛着就是了,用户在分担一点,他们自己就安心了。真正能静下心来做点事情的没几个。

星期五, 九月 28, 2007

trouble shooting for ext3fs with disk error

今天放数据库的主机不能正常运行了,因为以前出过文件系统错误,当时我把数据磁盘 umount,再做 fsck.ext3 /dev/sdb1 后就直接从 journal 恢复了。但今天却不行,当运行 fsck.ext3 /dev/sdb1 的时候,出现
(Attempt to read block from filesystem resulted in short read).  Ignore error?
这样的错误。

于是检查一下系统日志 /var/log/message
Sep 23 04:07:38 db kernel: EXT3-fs error (device sdb1) in start_transaction: Journal has aborted
Sep 23 04:09:31 db kernel: EXT3-fs error (device sdb1) in start_transaction: Journal has aborted
Sep 23 04:28:51 db kernel: EXT3-fs error (device sdb1) in start_transaction: Journal has aborted
Sep 23 04:31:38 db kernel: EXT3-fs error (device sdb1) in start_transaction: Journal has aborted
Sep 23 04:34:01 db kernel: EXT3-fs error (device sdb1) in start_transaction: Journal has aborted
Sep 23 04:37:40 db kernel: EXT3-fs error (device sdb1) in start_transaction: Journal has aborted
......
Sep 23 12:07:13 db kernel: EXT3-fs error (device sdb1) in start_transaction: Journal has aborted
Sep 23 12:07:36 db kernel: EXT3-fs error (device sdb1) in start_transaction: Journal has aborted
Sep 23 12:40:05 db kernel: __journal_remove_journal_head: freeing b_frozen_data
Sep 23 12:40:05 db kernel: __journal_remove_journal_head: freeing b_committed_data
Sep 23 12:40:05 db kernel: __journal_remove_journal_head: freeing b_frozen_data
Sep 23 12:40:59 db kernel: kjournald starting. Commit interval 5 seconds
Sep 23 12:40:59 db kernel: EXT3 FS on sdb1, internal journal
Sep 23 12:40:59 db kernel: EXT3-fs: mounted filesystem with ordered data mode.
Sep 27 02:34:00 db kernel: (scsi1:A:1:0): Unexpected busfree in Data-in phase
Sep 27 02:34:00 db kernel: SEQADDR == 0x82
Sep 27 02:34:00 db kernel: SCSI error : <1 0 1 0> return code = 0x10000
Sep 27 02:34:00 db kernel: end_request: I/O error, dev sdb, sector 272737767
Sep 27 02:34:01 db kernel: SCSI error : <1 0 1 0> return code = 0x10000
Sep 27 02:34:01 db kernel: end_request: I/O error, dev sdb, sector 272737775
Sep 27 02:34:01 db kernel: SCSI error : <1 0 1 0> return code = 0x10000
Sep 27 02:34:01 db kernel: end_request: I/O error, dev sdb, sector 272737783
Sep 27 02:34:01 db kernel: SCSI error : <1 0 1 0> return code = 0x10000
Sep 27 02:34:01 db kernel: end_request: I/O error, dev sdb, sector 272737791
Sep 27 02:34:01 db kernel: SCSI error : <1 0 1 0> return code = 0x10000
Sep 27 02:34:01 db kernel: end_request: I/O error, dev sdb, sector 272737799
Sep 27 02:34:02 db kernel: SCSI error : <1 0 1 0> return code = 0x10000
......
Sep 27 02:34:14 db kernel: SCSI error : <1 0 1 0> return code = 0x8000002
Sep 27 02:34:14 db kernel: Info fld=0x0, Current sdb: sense key Aborted Command
Sep 27 02:34:14 db kernel: end_request: I/O error, dev sdb, sector 272737767
Sep 27 02:34:14 db kernel: (scsi1:A:1): 160.000MB/s transfers (80.000MHz DT, offset 127, 16bit)
Sep 27 02:34:15 db kernel: (scsi1:A:1:0): Unexpected busfree in Data-in phase
Sep 27 02:34:15 db kernel: SEQADDR == 0x56
Sep 27 02:34:15 db kernel: SCSI error : <1 0 1 0> return code = 0x10000
Sep 27 02:34:15 db kernel: end_request: I/O error, dev sdb, sector 272872423
Sep 27 02:34:16 db kernel: SCSI error : <1 0 1 0> return code = 0x10000
Sep 27 02:34:16 db kernel: end_request: I/O error, dev sdb, sector 272872431
......
Sep 27 02:34:30 db kernel: SCSI error : <1 0 1 0> return code = 0x8000002
Sep 27 02:34:30 db kernel: Info fld=0x0, Current sdb: sense key Aborted Command
Sep 27 02:34:30 db kernel: end_request: I/O error, dev sdb, sector 272872639
Sep 27 02:34:30 db kernel: (scsi1:A:1): 160.000MB/s transfers (80.000MHz DT, offset 127, 16bit)
Sep 28 02:35:10 db kernel: (scsi1:A:1:0): Unexpected busfree in Data-in phase
Sep 28 02:35:10 db kernel: SEQADDR == 0x53
Sep 28 02:35:10 db kernel: scsi1:A:15: parity error detected while idle. SEQADDR(0x1) SCSIRATE(0xc2)
Sep 28 02:35:10 db kernel: No terminal CRC packet recevied
Sep 28 02:35:10 db kernel: SCSI error : <1 0 1 0> return code = 0x10000
Sep 28 02:35:10 db kernel: end_request: I/O error, dev sdb, sector 270637663
......
Sep 28 02:35:27 db kernel: SCSI error : <1 0 1 0> return code = 0x8000002
Sep 28 02:35:27 db kernel: Info fld=0x0, Current sdb: sense key Aborted Command
Sep 28 02:35:27 db kernel: end_request: I/O error, dev sdb, sector 120062031
Sep 28 02:35:27 db kernel: EXT3-fs error (device sdb1): ext3_get_inode_loc: unable to read inode block - inode=7503878, block=15007746
Sep 28 02:35:27 db kernel: Aborting journal on device sdb1.
Sep 28 02:35:27 db kernel: SCSI error : <1 0 1 0> return code = 0x8000002
Sep 28 02:35:27 db kernel: Info fld=0x0, Current sdb: sense key Aborted Command
Sep 28 02:35:27 db kernel: end_request: I/O error, dev sdb, sector 273146143
......
Sep 28 02:35:29 db kernel: SCSI error : <1 0 1 0> return code = 0x8000002
Sep 28 02:35:29 db kernel: Info fld=0x0, Current sdb: sense key Aborted Command
Sep 28 02:35:29 db kernel: end_request: I/O error, dev sdb, sector 63
Sep 28 02:35:29 db kernel: EXT3-fs error (device sdb1) in ext3_reserve_inode_write: IO failure
Sep 28 02:35:29 db kernel: SCSI error : <1 0 1 0> return code = 0x8000002
Sep 28 02:35:29 db kernel: Info fld=0x0, Current sdb: sense key Aborted Command
Sep 28 02:35:29 db kernel: end_request: I/O error, dev sdb, sector 272573927
Sep 28 02:35:29 db kernel: SCSI error : <1 0 1 0> return code = 0x8000002
Sep 28 02:35:29 db kernel: Info fld=0x0, Current sdb: sense key Aborted Command
Sep 28 02:35:29 db kernel: end_request: I/O error, dev sdb, sector 272574783
Sep 28 02:35:29 db kernel: ext3_abort called.
Sep 28 02:35:29 db kernel: EXT3-fs error (device sdb1): ext3_journal_start_sb: Detected aborted journal
Sep 28 02:35:29 db kernel: Remounting filesystem read-only
Sep 28 02:35:29 db kernel: EXT3-fs error (device sdb1) in start_transaction: Journal has aborted
Sep 28 02:35:29 db kernel: EXT3-fs error (device sdb1) in start_transaction: Journal has aborted
Sep 28 02:35:29 db kernel: (scsi1:A:1): 160.000MB/s transfers (80.000MHz DT, offset 127, 16bit)
Sep 28 02:35:29 db kernel: EXT3-fs error (device sdb1) in ext3_dirty_inode: IO failure
Sep 28 02:35:29 db kernel: EXT3-fs error (device sdb1) in start_transaction: Journal has aborted
Sep 28 02:35:29 db kernel: __journal_remove_journal_head: freeing b_frozen_data
Sep 28 02:35:29 db kernel: __journal_remove_journal_head: freeing b_frozen_data
Sep 28 02:35:55 db kernel: EXT3-fs error (device sdb1) in start_transaction: Journal has aborted
Sep 28 02:41:25 db kernel: EXT3-fs error (device sdb1) in start_transaction: Journal has aborted
Sep 28 03:10:40 db kernel: EXT3-fs error (device sdb1) in start_transaction: Journal has aborted
Sep 28 03:42:08 db kernel: EXT3-fs error (device sdb1) in start_transaction: Journal has aborted
Sep 28 03:51:37 db kernel: EXT3-fs error (device sdb1) in start_transaction: Journal has aborted
Sep 28 03:54:38 db kernel: EXT3-fs error (device sdb1) in start_transaction: Journal has aborted
......
基本上,可以肯定是磁盘损坏了,出现了坏道!

因为这里是没有使用 RAID 设施的,所以只能使用 rescue 主机替代,这属于高可用(HA: High Availability)的问题了,这里不讨论。回过头来,需要检查和确认这块磁盘的问题。

首先使用另外一个 IP 启动这台主机(因为 HA 已经使用了原来的 IP 地址)。在这里我遇到的情况是在重启时第二块磁盘(/dev/sdb)还是被“正常”挂载了(/dev/sdb1),这意味着你仍然可以从里面把数据拷贝出来,当然最好是只读使用!——运气不错,不是吗?但这并不意味着这块磁盘就没有问题了,需要先进行检查:
sh# fsck.ext3 /dev/sdb1
e2fsck 1.35 (28-Feb-2004)
/dev/sdb1: clean, 39195/17924096 files, 22706784/35843015 blocks
好像没有问题?但真的是这样吗?

应该使用其他的超级块检查一下,因为很可能这个超级块本身就有问题。从 Ext3 文件系统使用磁盘的基本原理上看,一个磁盘被分成若干 groups,每个 groups 包含很多物理 blocks(通常为 4KB,和内存的一个 page 的大小一致。注意,这里和使用 fdisk 是显示的 Blocks 是不一样的,后者是以 1KB 为单元的),通常一个 group 可能包含 8192/16384/32768 个 blocks,取决于磁盘的大小或创建分区文件系统时的设置,而每一个 group 上面都有一个超级块(super block),只有第一个 group 的超级块被实际使用,其他 group 的超级块都作为备用。因此,尝试使用另外一个超级块:
sh# fsck.ext3 -b 8192 /dev/sdb1
e2fsck 1.35 (28-Feb-2004)
fsck.ext3: Bad magic number in super-block while trying to open /dev/sdb1

The superblock could not be read or does not describe a correct ext2
filesystem. If the device is valid and it really contains an ext2
filesystem (and not swap or ufs or something else), then the superblock
is corrupt, and you might try running e2fsck with an alternate superblock:
e2fsck -b 8193

sh# fsck.ext3 -b 8193 /dev/sdb1
e2fsck 1.35 (28-Feb-2004)
fsck.ext3: Bad magic number in super-block while trying to open /dev/sdb1

The superblock could not be read or does not describe a correct ext2
filesystem. If the device is valid and it really contains an ext2
filesystem (and not swap or ufs or something else), then the superblock
is corrupt, and you might try running e2fsck with an alternate superblock:
e2fsck -b 8193
两者都不行!这说明一个 group 的大小不是 8192,第二个 super block 不在第 8193 个 block 上,那么可以通过 tune2fs 来获得文件系统的信息,进而找到下一个超级块。
sh# tune2fs -l /dev/sdb1
tune2fs 1.35 (28-Feb-2004)
Filesystem volume name:
Last mounted on:
Filesystem UUID: 204a2d09-12d5-4623-bb0d-75b2e340401d
Filesystem magic number: 0xEF53
Filesystem revision #: 1 (dynamic)
Filesystem features: has_journal resize_inode filetype sparse_super large_file
Default mount options: (none)
Filesystem state: clean
Errors behavior: Continue
Filesystem OS type: Linux
Inode count: 17924096
Block count: 35843015
Reserved block count: 1792150
Free blocks: 13136231
Free inodes: 17884901
First block: 0
Block size: 4096
Fragment size: 4096
Reserved GDT blocks: 1024
Blocks per group: 32768
Fragments per group: 32768
Inodes per group: 16384
Inode blocks per group: 512
Filesystem created: Sun Jan 7 15:50:06 2007
Last mount time: Fri Sep 28 10:05:06 2007
Last write time: Fri Sep 28 11:01:56 2007
Mount count: 1
Maximum mount count: 35
Last checked: Fri Sep 28 10:05:05 2007
Check interval: 15552000 (6 months)
Next check after: Wed Mar 26 10:05:05 2008
Reserved blocks uid: 0 (user root)
Reserved blocks gid: 0 (group root)
First inode: 11
Inode size: 128
Journal inode: 8
Default directory hash: tea
Directory Hash Seed: dd1084ed-a28f-489e-8e47-c4a3a49f5e6d
Journal backup: inode blocks
可以看出每个块组拥有 32768 个 blocks,所以应该指定 -b 32768 来进行检查:
sh# fsck.ext3 -b 32768 /dev/sdb1
e2fsck 1.35 (28-Feb-2004)
/dev/sdb1 contains a file system with errors, check forced.
Pass 1: Checking inodes, blocks, and sizes
Duplicate blocks found... invoking duplicate block passes.
Pass 1B: Rescan for duplicate/bad blocks
Duplicate/bad block(s) in inode 311389: 712136
Duplicate/bad block(s) in inode 311425: 680600 680633 680634 680635 680636 680637 680638 680639 680641 680642 680643 680644 680645 680646 680647 680665 680666 680667 680668 680669 680670 680671 680673 681752 682704 684104 684352 685688 686064
Duplicate/bad block(s) in inode 311560: 657856 658872 662192 665192 669600 686504 689824 694104 696144 696904 698816 703032
Duplicate/bad block(s) in inode 344144: 705776 706088 706784
Duplicate/bad block(s) in inode 344151: 708952
Duplicate/bad block(s) in inode 344170: 709200
Duplicate/bad block(s) in inode 377354: 810496
Error reading block 22872266 (Attempt to read block from filesystem resulted in short read). Ignore error?
已经报告出现了 bad blocks。

short read 通常意味着文件系统中的一个 i 节点指向一个不能再读取的块,或者关于文件系统的某个元数据位于一个或者几个不能读取的块。对于日志文件系统,如果文件系统的日志的任何一部分存储在一个坏块上,也会出现这个错误,因为不能读取事务。

如果运气不够好,磁盘分区完全不能挂载和读取,可以先尝试把日志删除,再尝试挂接和访问数据。先用 debugfs 来看看文件系统的特性:
sh# debugfs /dev/sdb1
debugfs 1.35 (28-Feb-2004)
debugfs: features
Filesystem features: has_journal resize_inode filetype sparse_super large_file
debugfs: open /dev/sdb1
open: Filesystem /dev/sdb1 is still open. Close it first.
debugfs: open /dev/sdb1
open: Filesystem /dev/sdb1 is still open. Close it first.
debugfs: close /dev/sdb1
close: Usage: close_filesys
debugfs:
debugfs: open /dev/sdb1
open: Filesystem /dev/sdb1 is still open. Close it first.
debugfs: quit
可以看到 has_journal 特性。使用 tune2fs 可以设置和清除文件系统特性。下面的命令删除日志:
sh# tune2fs -f -O ^has_journal /dev/sdb1
tune2fs 1.35 (28-Feb-2004)
sh# debugfs /dev/sdb1
debugfs 1.35 (28-Feb-2004)
debugfs: features
Filesystem features: resize_inode filetype sparse_super large_file
debugfs: open /dev/sdb1
open: Filesystem /dev/sdb1 is still open. Close it first.
debugfs: quit
has_journal 特性已经被清除。这时候,再次运行 fsck.ext3,不使用 -b 指定 super block,也可以看到报错信息:
e2fsck 1.35 (28-Feb-2004)
/dev/sdb1 contains a file system with errors, check forced.
Pass 1: Checking inodes, blocks, and sizes
Error reading block 35750122 (Attempt to read block from filesystem resulted in short read) while doing inode scan. Ignore error?
总之,要从一个损坏的磁盘上恢复数据总是没有保证的,所以备份至关重要——"热镜像 + 轮转拷贝"才是根本之道。

参考:《LINUX SERVER HACKS 卷二》, Hacks #94 "从崩溃的磁盘恢复数据"。

另外,我的项目 cutils包含了 mirrord/fs_mirror 镜像和轮转工具。

星期四, 九月 20, 2007

RHEL5 部分内存无法使用?

因为装 RAID1 + LVM,使用了一块技嘉的板子,nvidia GeForce 6100/nForce 430 芯片,结果原来的 RHEL4 没有它的 SATA 驱动,下载的 sata_nv 驱动也始终装不上,只好换用了 RHEL5,很顺利的安装成功了。

但进入系统后,使用 free 发现 4G 的内存,却只显示 3.4GB 左右。在 BIOS 中对于显卡的 frame buffer 的设置最大也只有 256MB,不可能差这边大。

从 dmesg 的记录来看,在 Linux 启动的时候有一个 Warning 信息,
 BIOS-e820: 00000000f0000000 - 00000000f2000000 (reserved)
BIOS-e820: 00000000fec00000 - 0000000100000000 (reserved)
BIOS-e820: 0000000100000000 - 0000000120000000 (usable)
Warning only 4GB will be used.
Use a PAE enabled kernel.
3200MB HIGHMEM available.
896MB LOWMEM available.
found SMP MP-table at 000f4ad0
Using x86 segment limits to approximate NX protection
On node 0 totalpages: 1048576
DMA zone: 4096 pages, LIFO batch:0
Normal zone: 225280 pages, LIFO batch:31
HighMem zone: 819200 pages, LIFO batch:31
DMI 2.3 present.
这个警告信息比较奇怪,应该是说明了问题所在。结合以前遇到过的关于 4GB 内存不能启动的问题,估计应该是内核对大内存支持的问题。于是重新下载内核源代码并进行编译,学者处理器的内存支持为 64GB,重启后就 OK 了。

在内核 config 文件中的定义是:
CONFIG_HIGHMEM4G=y
# CONFIG_HIGHMEM64G is not set
变为
# CONFIG_HIGHMEM4G is not set
CONFIG_HIGHMEM64G=y
这里对 HIGHMEM 我还不是太清楚其含义,最近正在看《LINUX 内核解析》,应该能够得到说明。

星期一, 三月 05, 2007

smbfs/cifs for fs_backup

备份的目标比较大,压缩后的档案超过两个G,使用了 smbfs 文件系统:
sh# mount
//store/homes on /mnt/host type smbfs (rw,mand)
但是执行完全备份时出现如下报错:
sh# fs_backup at_pages

gzip: stdout: File too large
tar: /mnt/host/fs_backup/at_pages/at_pages.full.20070301-010003.tgz: Wrote only 2048 of 10240 bytes
tar: Error is not recoverable: exiting now

bzip2: I/O or other error, bailing out. Possible reason follows.
bzip2: File too large
Input file = (stdin), output file = (stdout)
tar: /mnt/host/fs_backup/at_pages/at_pages.full.20070301-145957.tgz: Wrote only 8192 of 10240 bytes
tar: Error is not recoverable: exiting now
首先看看本地备份是否会有问题,改变 datadir = /var/fs_backup,重新运行完全备份,没有问题。说明限制不再 gzip/bzip2 上面,只可能是 samba 的问题。

从查找资料的情况来看,时间上就是由于 smbfs 有 2GB 的限制,使用 cifs 来代替 smbfs 即可:
sh# mount
//store/homes on /mnt/host type cifs (rw,mand)
在 /etc/fstab 做相应更改就可以了。

星期一, 二月 05, 2007

RHEL4 kernel 4G MEM && SMP "冲突"问题

宝德的服务器,安装的 RHEL4,内核编译中是支持大内存的(64G),支持 SMP 对称多处理。但换上4条三星的 1G 内存后,系统启动出错:
target 0:0:0: FAST-80 WIDE SCSI 168.0MB/s DT(12.5ns, offset 62)
sym0:0: ERROR(20:0) (d-2d-2f) (3e/18/80) @ (scripta 7f0:150003d8)
sym0: script cmd = 88080000
sym0: regdump: ...
sym0: RCI STATUS = 0x2000
sym0: SCSI BUS reset detected
sym0: SCSI BUS has been reset
......
以上信息反复出现,系统无法启动。但使用单处理器的内核却可以启动系统!而且使用 Windows 也是可以启动的,在 BIOS 中也是可以正常识别的。

所以只可能是系统本身的问题。为此查看内核的 config 文件:
sh# grep -i 'MEM' config
......
# CONFIG_HIGHMEM4G is not set
CONFIG_HIGHMEM64G=y
CONFIG_HIGHMEM=y
......
可以看到有 HIGHMEM4G 和 HIGHMEM64G,在 make menuconfig 的 "Process type and features" ->"High Memory Support"中也可以看到。既然已经有 64G 的支持,为什么还需要 4G 呢?这是一个疑点,也是一个突破点。通过查看 help,大致可以了解,如果内存在 1~4G 之间,最好使用 4G 支持,如果内存多于 4G,则应使用 64G。

按此思路重新编译内核后,OK。

星期三, 一月 31, 2007

Apache 1.3 to 2.0 VirtualHost

原来的 Apache 1.3,其虚拟主机的设定如下:
NameVirtualHost *:80
"<"VirtualHost *">"
...
但把虚拟主机的那些配置拷贝到 Apache 2.0 中的配置文件之后,启动 Apache 得到报错"No VirtualHost found for NameVirtualHost *:80"。

排错,将所有的 VirtualHost * 替换为 VirtualHost *:80 即可。

星期六, 十二月 09, 2006

ALSA

...(未完)...

在安装了 alsa-lib 和 alsa-utils 以及一些 multimedia lib 之后,LFS 仍然没有声音。使用 mplayer 等会提示没有 /dev/dsp 等设备。于原来的主系统进行比较(Fedora Core 6,当然原来的主系统也没有声音),可以看到原来的系统是有 /dev/dsp 和 /dev/audio 的。

查看主系统上的 lspci 输出:
# sed '/^\t/d;/^$/d' lspci.log
00:00.0 Host bridge: Intel Corporation Mobile 915GM/PM/GMS/910GML Express Processor to DRAM Controller (rev 04)
00:02.0 VGA compatible controller: Intel Corporation Mobile 915GM/GMS/910GML Express Graphics Controller (rev 04) (prog-if 00 [VGA])
00:02.1 Display controller: Intel Corporation Mobile 915GM/GMS/910GML Express Graphics Controller (rev 04)
00:1b.0 Audio device: Intel Corporation 82801FB/FBM/FR/FW/FRW (ICH6 Family) High Definition Audio Controller (rev 04)
00:1c.0 PCI bridge: Intel Corporation 82801FB/FBM/FR/FW/FRW (ICH6 Family) PCI Express Port 1 (rev 04) (prog-if 00 [Normal decode])
00:1d.0 USB Controller: Intel Corporation 82801FB/FBM/FR/FW/FRW (ICH6 Family) USB UHCI #1 (rev 04) (prog-if 00 [UHCI])
00:1d.1 USB Controller: Intel Corporation 82801FB/FBM/FR/FW/FRW (ICH6 Family) USB UHCI #2 (rev 04) (prog-if 00 [UHCI])
00:1d.2 USB Controller: Intel Corporation 82801FB/FBM/FR/FW/FRW (ICH6 Family) USB UHCI #3 (rev 04) (prog-if 00 [UHCI])
00:1d.3 USB Controller: Intel Corporation 82801FB/FBM/FR/FW/FRW (ICH6 Family) USB UHCI #4 (rev 04) (prog-if 00 [UHCI])
00:1d.7 USB Controller: Intel Corporation 82801FB/FBM/FR/FW/FRW (ICH6 Family) USB2 EHCI Controller (rev 04) (prog-if 20 [EHCI])
00:1e.0 PCI bridge: Intel Corporation 82801 Mobile PCI Bridge (rev d4) (prog-if 01 [Subtractive decode])
00:1f.0 ISA bridge: Intel Corporation 82801FBM (ICH6M) LPC Interface Bridge (rev 04)
00:1f.2 IDE interface: Intel Corporation 82801FBM (ICH6M) SATA Controller (rev 04) (prog-if 80 [Master])
00:1f.3 SMBus: Intel Corporation 82801FB/FBM/FR/FW/FRW (ICH6 Family) SMBus Controller (rev 04)
01:0c.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL-8139/8139C/8139C+ (rev 10)


当前系统的 lspci 输出:
# lspci
00:00.0 Host bridge: Intel Corp.: Unknown device 2590 (rev 04)
00:02.0 VGA compatible controller: Intel Corp.: Unknown device 2592 (rev 04)
00:02.1 Display controller: Intel Corp.: Unknown device 2792 (rev 04)
00:1b.0 Class 0403: Intel Corp.: Unknown device 2668 (rev 04)
00:1c.0 PCI bridge: Intel Corp.: Unknown device 2660 (rev 04)
00:1d.0 USB Controller: Intel Corp.: Unknown device 2658 (rev 04)
00:1d.1 USB Controller: Intel Corp.: Unknown device 2659 (rev 04)
00:1d.2 USB Controller: Intel Corp.: Unknown device 265a (rev 04)
00:1d.3 USB Controller: Intel Corp.: Unknown device 265b (rev 04)
00:1d.7 USB Controller: Intel Corp.: Unknown device 265c (rev 04)
00:1e.0 PCI bridge: Intel Corp. 82801BAM/CAM PCI Bridge (rev d4)
00:1f.0 ISA bridge: Intel Corp.: Unknown device 2641 (rev 04)
00:1f.2 IDE interface: Intel Corp.: Unknown device 2653 (rev 04)
00:1f.3 SMBus: Intel Corp.: Unknown device 266a (rev 04)
01:0c.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL-8139/8139C/8139C+ (rev 10)

我开始怀疑是不是 udev 的规则写得不对。差不多把 udev 的资料都翻了一遍,udev 是差不多了解个大概了,声卡的问题还没有解决。考虑一下 sysfs 的知识,查看一下 /sys 的内容,因为硬件设备应该会把自己的信息导出到 /sys 下。

主系统:
# find /sys | grep 'dsp'
/sys/class/sound/dsp
/sys/class/sound/dsp/device
/sys/class/sound/dsp/dev
/sys/class/sound/dsp/uevent
/sys/class/sound/dsp/subsystem
/sys/class/sound/adsp
/sys/class/sound/adsp/device
/sys/class/sound/adsp/dev
/sys/class/sound/adsp/uevent
/sys/class/sound/adsp/subsystem
/sys/devices/pci0000:00/0000:00:1b.0/sound:dsp
/sys/devices/pci0000:00/0000:00:1b.0/sound:adsp

当前系统:
# find /sys | grep 'dsp'
没有输出。

另外,运行:
# alsaconf
which: no dialog in (/usr/local/sbin:/usr/local/bin:/bin:/usr/bin:/sbin:/usr/sbin:/usr/X11R6/bin)
which: no whiptail in (/usr/local/sbin:/usr/local/bin:/bin:/usr/bin:/sbin:/usr/sbin:/usr/X11R6/bin)
Error, dialog or whiptail not found.
alsaconf "Error, dialog or whiptail not found"
每次我运行了 alsaconf 后,所有的模块都不在了,必须重新加载。

但是查看 /proc/asound/cards:
# cat /proc/asound/cards
 0 [Intel          ]: HDA-Intel - HDA Intel
HDA Intel at 0xffe38000 irq 169
而且还有:
# modinfo soundcore
filename:       /lib/modules/2.6.18.1/kernel/sound/soundcore.ko
alias: char-major-14-*
license: GPL
author: Alan Cox
description: Core sound module
srcversion: 69B73D502EF87CE567454E1
depends:
vermagic: 2.6.18.1 SMP mod_unload PENTIUMM REGPARM 4KSTACKS gcc-4.0
这说明声卡驱动是有的,声卡应该已经被识别了呀。

google "No /dev/dsp",可以找到一些资料,说明是 OSS(Open Sound System) compatible 的问题,很多程序都需要使用 oss 的接口。于是安装 alsa-oss,但重启后仍然没有 /dev/dsp 和 /dev/audio。这是因为没有加载相应的 oss 内核模块:
# modprobe snd-mixer-oss
# modprobe snd-pcm-oss
# modprobe snd-seq-oss
不用重启,即可以看到 /dev/dsp 和 /dev/audio 了。

# find /sys | grep 'dsp'
/sys/module/snd_pcm_oss/parameters/dsp_map
/sys/module/snd_pcm_oss/parameters/adsp_map
/sys/class/sound/dsp
/sys/class/sound/dsp/device
/sys/class/sound/dsp/dev
/sys/class/sound/dsp/uevent
/sys/class/sound/dsp/subsystem
/sys/class/sound/adsp
/sys/class/sound/adsp/device
/sys/class/sound/adsp/dev
/sys/class/sound/adsp/uevent
/sys/class/sound/adsp/subsystem
/sys/devices/pci0000:00/0000:00:1b.0/sound:dsp
/sys/devices/pci0000:00/0000:00:1b.0/sound:adsp

http://lists.ibiblio.org/pipermail/sm-discuss/2004-May/006802.html
http://www.mail-archive.com/alsa-user@lists.sourceforge.net/msg17891.html
http://www.linuxsir.org/bbs/showthread.php?t=282216
http://www.xxlinux.com/linux/article/accidence/internet/20061122/5945.html
Alsa-sound-mini-HOWTO

/dev/mixer:访问声卡中内置的mixer,调整音量大小,选择音源。
/dev/dsp, /dev/dspW, /dev/audio:读这个设备就相当于录音,写这个设备就相当于放音。/dev/dsp 与 /dev/audio 之间的区别在于采样的编码不同,/dev/audio 使用μ律编码,/dev/dsp 使用8-bit(无符号)线性编码,/dev/dspW 使用16-bit(有符号)线形编码。/dev/audio 主要是为了与 SunOS 兼容,所以尽量不要使用。


对于非 OSS compatible,其设备为 /dev/snd/*。

但是仍然不能发声!但内核已经编译了 ALSA,从前面的 /proc/asound/cards 也可以看到驱动应该已经识别呀?

我开始考虑是不是驱动的问题。因为前面使用的是系统内建的驱动,这次使用 alsa-driver 看看。因为编译时提示必须使用没有增加 ALSA 支持的内核,所以又重新编译了内核,去除了 ALSA。然后启动到新的内核来编译 alsa-driver -- 这时发生了很奇怪的事 -- 扬声器竟然可以发出"嘟嘟"的蜂鸣声了!

但是当我编译好 alsa-driver,再次重启后,又没有任何声音了!而且似乎每次重启后音量设置就无效了。即使安装了 blfs-bootscripts 的 alsa 脚本!

alsa-driver 的 make install 提示了
cat WARNING

WARNING!!! The mixer channels for the ALSA driver are muted by default!!!
**************************************************************************
You would use some ALSA or OSS mixer to set the appropriate volume.
于是使用 alsamixer/aumix 来调整音量,但毫无用处。

我又参照 ALSA 官方网站的
Intel ICH southbridge HD-audio and modem
一文进行了编译,并设置 /etc/modprobe.conf 如下:
$ cat /etc/modprobe.conf
alias eth0 8139too
alias scsi_hostadapter ata_piix
alias scsi_hostadapter1 ahci

# ALSA portion
alias char-major-116 snd
alias snd-card-0 snd-hda-intel
# module options should go here

# OSS/Free portion
alias char-major-14 soundcore
alias sound-slot-0 snd-card-0

# card #1
alias sound-service-0-0 snd-mixer-oss
alias sound-service-0-1 snd-seq-oss
alias sound-service-0-3 snd-pcm-oss
alias sound-service-0-8 snd-seq-oss
alias sound-service-0-12 snd-pcm-oss

# remove snd-hda-intel { /usr/sbin/alsactl store 0 >/dev/null 2>&1 || : ; }; /sbin/modprobe -r --ignore-remove snd-hda-intel
结果仍然无效。声卡就是不发声!

alsaconf "Error, dialog or whiptail not found"

运行 alsaconf 得到报错:
which: no dialog in (/usr/local/sbin:/usr/local/bin:/bin:/usr/bin:/sbin:/usr/sbin:/usr/X11R6/bin)
which: no whiptail in (/usr/local/sbin:/usr/local/bin:/bin:/usr/bin:/sbin:/usr/sbin:/usr/X11R6/bin)
Error, dialog or whiptail not found.
google it,知道这是因为没有 dialog 这个程序。有一个 dialog 程序在内核代码中:
/sources/linux-2.6.18.1/scripts/kconfig/lxdialog
make menuconfig 使用的就是这个程序。但是似乎也有其他专门的 dialog 项目:
http://hightek.org/dialog/

其他的 shell script 也可以使用它,这样可以避免写复杂的 ncurses 程序。alsaconf 使用的也是它。所以直接拷贝到系统中:
# cp lxdialog /usr/bin
# cd /usr/bin
# ln lxdialog -s dialog
这就可以用了。

但实际情况是,使用这种方法有问题。我运行 alsaconf 是提示找不到 PnP/PCI card。然后我安装了 dialog 项目的程序,却可以正常运行,正确的找到了声卡。

http://javascript:void(0)www.linuxsir.org/bbs/archive/index.php/t-144938.html
http://docs.chinalinuxpub.com/read.php?wid=98

Linux Apprentice: Improve Bash Shell Scripts Using Dialog

星期四, 十二月 07, 2006

compile gaim with nss for MSN

安装 gaim 之后运行连接 MSN,提示需要 SSL 支持,configure 如下:
$ ./configure
......
SSL Library/Libraries......... : None
......

查看 gaim 的 SSL FAQ 中关于从源代码编译的部分,说明需要 mozilla nss 和 GnuTLS 两者之一来支持 SSL,选择 mozilla nss。但开始安装 nss-3.9.2 无法通过编译,查看 BLFS development 有 nss 的安装,使用 nss-3.11.3:
$ cat /usr/src/nss/.config
pkgname = "nss";
version = "3.11.3";
user = "nss";
groups = "";
group = "nss";
archive = "nss-3.11.3-with-nspr-4.6.3.tar.gz";
patch = "nss-3.11.3-with-nspr-4.6.3-fedora_fixes-1.patch";
command = "tar xfz nss-3.11.3-with-nspr-4.6.3.tar.gz";
command = "cd nss-3.11.3";
command = "patch -Np1 -i ../nss-3.11.3-with-nspr-4.6.3-fedora_fixes-1.patch";
command = "cd mozilla/security/nss";
command = "make BUILD_OPT=1 nss_build_all";
command = "make BUILD_OPT=1 install";
command = "mkdir /usr/include/nspr";
command = "find ../../dist/*/lib -type l \( -name "*.so" -o -name "*.chk" \) -exec cp -L {} /usr/lib \;";
command = "cp -Lr ../../dist/public/* /usr/include";
command = "cp -Lr ../../dist/*/include/* /usr/include/nspr";
command = "cd ../../../../";
command = "rm -rf nss-3.11.3";
time = "20061207 18:32:26 Thu";
这里并没有万全参照 BLFS 文档,而是将:
FAQ-SSL-Gaim
安装 nss 的后面的部分加过来,将 $HOME 替换为 /usr。

然后重新编译 gaim:
# upm i -f /blfs/gaim-1.5.0.tar.bz2
crablfs> cmd tar xfj gaim-1.5.0.tar.bz2
crablfs> cmd cd gaim-1.5.0
crablfs> cmd ./configure --with-nss-includes=/usr/include/nss --with-nspr-includes=/usr/include/nspr --with-nss-libs=/usr/lib --with-nspr-libs=/usr/lib
......
SSL Library/Libraries......... : Mozilla NSS
......
crablfs> cmd make
crablfs> cmd make install
crablfs> cmd cd ..
crablfs> cmd rm -rf gaim-1.5.0
crablfs> cmt

mozilla NSS 是一个 library,而在其底层可以使用 SSLv3, SSLv2, TSL 等加密机制。

星期六, 十一月 25, 2006

LFS compile Xorg for i180(915GM) trouble shooting

这是安装 BLFS 的一部分,首先按照文档安装 Xorg-6.8.2,但是在编译时出错,出错信息如下:
fbmmx.c: In function 'negate':
fbmmx.c:107: error: incompatible type for argument 1
of '__builtin_ia32_pxor'
fbmmx.c:107: error: incompatible type for argument 2
of '__builtin_ia32_pxor'
fbmmx.c: In function 'expand_alpha':
fbmmx.c:166: error: incompatible type for argument 1
of '__builtin_ia32_por'
fbmmx.c:166: error: incompatible type for argument 2
of '__builtin_ia32_por'
fbmmx.c:166: error: incompatible types in assignment
fbmmx.c:168: error: incompatible type for argument 1
of '__builtin_ia32_por'
fbmmx.c:168: error: incompatible type for argument 2
of '__builtin_ia32_por'
fbmmx.c:168: error: incompatible types in assignment
fbmmx.c: In function 'expand_alpha_rev':
fbmmx.c:181: error: incompatible type for argument 1
of '__builtin_ia32_por'
fbmmx.c:181: error: incompatible type for argument 2
of '__builtin_ia32_por'
fbmmx.c:181: error: incompatible types in assignment
fbmmx.c:183: error: incompatible type for argument 1
of '__builtin_ia32_por'
fbmmx.c:183: error: incompatible type for argument 2
of '__builtin_ia32_por'
fbmmx.c:183: error: incompatible types in assignment
fbmmx.c: In function 'invert_colors':
fbmmx.c:195: error: incompatible type for argument 1
of '__builtin_ia32_pand'
fbmmx.c:195: error: incompatible type for argument 2
of '__builtin_ia32_pand'
fbmmx.c:195: error: incompatible types in assignment
fbmmx.c:196: error: incompatible type for argument 1
of '__builtin_ia32_pand'
fbmmx.c:196: error: incompatible type for argument 2
of '__builtin_ia32_pand'
fbmmx.c:196: error: incompatible types in assignment
fbmmx.c:197: error: incompatible type for argument 1
of '__builtin_ia32_pand'
fbmmx.c:197: error: incompatible type for argument 2
of '__builtin_ia32_pand'
fbmmx.c:197: error: incompatible types in assignment
fbmmx.c:202: error: incompatible type for argument 1
of '__builtin_ia32_por'
fbmmx.c:202: error: incompatible type for argument 2
of '__builtin_ia32_por'
fbmmx.c:202: error: incompatible types in assignment
fbmmx.c:203: error: incompatible type for argument 1
of '__builtin_ia32_por'
fbmmx.c:203: error: incompatible type for argument 2
of '__builtin_ia32_por'
fbmmx.c:203: error: incompatible types in assignment
fbmmx.c: In function 'over_rev_non_pre':
fbmmx.c:237: error: incompatible type for argument 1
of '__builtin_ia32_por'
fbmmx.c:237: error: incompatible type for argument 2
of '__builtin_ia32_por'
fbmmx.c: In function 'expand565':
fbmmx.c:300: warning: ISO C90 forbids mixed
declarations and code
fbmmx.c:303: error: incompatible type for argument 1
of '__builtin_ia32_por'
fbmmx.c:303: error: incompatible type for argument 2
of '__builtin_ia32_por'
fbmmx.c:303: error: incompatible types in assignment
fbmmx.c:304: error: incompatible type for argument 1
of '__builtin_ia32_por'
fbmmx.c:304: error: incompatible type for argument 2
of '__builtin_ia32_por'
fbmmx.c:304: error: incompatible types in assignment
fbmmx.c:305: error: incompatible type for argument 1
of '__builtin_ia32_pand'
fbmmx.c:305: error: incompatible type for argument 2
of '__builtin_ia32_pand'
fbmmx.c:305: error: incompatible types in assignment
fbmmx.c: In function 'pack565':
fbmmx.c:327: error: incompatible type for argument 1
of '__builtin_ia32_pand'
fbmmx.c:327: error: incompatible type for argument 2
of '__builtin_ia32_pand'
fbmmx.c:327: error: incompatible types in assignment
fbmmx.c:328: error: incompatible type for argument 1
of '__builtin_ia32_pand'
fbmmx.c:328: error: incompatible type for argument 2
of '__builtin_ia32_pand'
fbmmx.c:328: error: incompatible types in assignment
fbmmx.c:329: error: incompatible type for argument 1
of '__builtin_ia32_pand'
fbmmx.c:329: error: incompatible type for argument 2
of '__builtin_ia32_pand'
fbmmx.c:329: error: incompatible types in assignment
fbmmx.c:336: error: incompatible type for argument 1
of '__builtin_ia32_pand'
fbmmx.c:336: error: incompatible type for argument 2
of '__builtin_ia32_pand'
fbmmx.c:336: error: incompatible types in assignment
fbmmx.c:338: error: incompatible type for argument 1
of '__builtin_ia32_pand'
fbmmx.c:338: error: incompatible type for argument 2
of '__builtin_ia32_pand'
fbmmx.c:338: error: incompatible types in assignment
fbmmx.c:340: error: incompatible type for argument 1
of '__builtin_ia32_pand'
fbmmx.c:340: error: incompatible type for argument 2
of '__builtin_ia32_pand'
fbmmx.c:340: error: incompatible types in assignment
fbmmx.c:342: error: incompatible type for argument 1
of '__builtin_ia32_pand'
fbmmx.c:342: error: incompatible type for argument 2
of '__builtin_ia32_pand'
fbmmx.c:342: error: incompatible types in assignment
fbmmx.c:344: error: incompatible type for argument 1
of '__builtin_ia32_por'
fbmmx.c:344: error: incompatible type for argument 2
of '__builtin_ia32_por'
fbmmx.c:344: error: incompatible types in assignment
fbmmx.c:345: error: incompatible type for argument 1
of '__builtin_ia32_por'
fbmmx.c:345: error: incompatible type for argument 2
of '__builtin_ia32_por'
fbmmx.c:345: error: incompatible types in assignment
fbmmx.c:347: error: incompatible type for argument 1
of '__builtin_ia32_por'
fbmmx.c:347: error: incompatible type for argument 2
of '__builtin_ia32_por'
fbmmx.c: In function
'fbCompositeSolidMask_nx8x8888mmx':
fbmmx.c:652: warning: ISO C90 does not support 'long
long'
fbmmx.c:695: warning: ISO C90 does not support 'long
long'
fbmmx.c: In function
'fbCompositeSolidMask_nx8x0565mmx':
fbmmx.c:758: warning: ISO C90 does not support 'long
long'
fbmmx.c:818: warning: ISO C90 does not support 'long
long'
make[5]: *** [fbmmx.o] Error 1
make[5]: Leaving directory
`/usr/src/Xorg/xc/programs/Xserver/fb'
make[4]: *** [fb] Error 2
make[4]: Leaving directory
`/usr/src/Xorg/xc/programs/Xserver'
make[3]: *** [all] Error 2
make[3]: Leaving directory
`/usr/src/Xorg/xc/programs'
make[2]: *** [all] Error 2
make[2]: Leaving directory `/usr/src/Xorg/xc'
make[1]: *** [World] Error 2
make[1]: Leaving directory `/usr/src/Xorg/xc'
make: *** [World] Error 2
这里:
http://linuxfromscratch.org/pipermail/blfs-support/2006-August/060856.html
http://linuxfromscratch.org/pipermail/blfs-support/2006-August/060858.html
提供了解决方法,就是使用 Xorg-6.9.0。

于是编译安装 Xorg-6.9.0 成功,但是安装安装提示运行:
# Xorg -configure
时出错:
Fatal server error:
Cannot open log file "/var/log/Xorg.0.log"

Please consult the The X.Org Foundation support
at http://wiki.X.Org
for help.
/var/log 的权限是没有问题的,问题出在 /usr/X11R6/bin/Xorg 上,因为是基于用户的包管理,所以其属主是 Xorg,但 X 需要 root+suid,所以运行时属主变成了 Xorg,当然没有权限写 /var/log/

于是更改 Xorg 属主:
# chown root /usr/X11R6/bin/Xorg
# chmod u+s /usr/X11R6/bin/Xorg

再次运行,得到如下的错误:
(II) LoadModule: "apm"
(II) Loading /usr/X11R6/lib/modules/drivers/apm_drv.so
dlopen: /usr/X11R6/lib/modules/drivers/apm_drv.so: undefined symbol: XvRTPort
(EE) Failed to load /usr/X11R6/lib/modules/drivers/apm_drv.so
(II) UnloadModule: "apm"
(EE) Failed to load module "apm" (loader failed, 7)
使用 X -config /root/xorg.conf.new 则黑屏,键盘无反应,只能关机。

如果仅从上面的提示来提示来看,则会步入误区,因为实际上 apm 模块并没有实质性的影响,它是电源管理的一部分:
Xorg wiki FAQ

正确的做法是,耐心查看由于运行 startx(Xorg -config ~/xorg.conf.new) 而产生的 /var/log/Xorg.0.log,查找其中所有"error","failed"等可能会是一个比较快捷的方式。因为问题很可能是出在芯片组的驱动上。

log 的内容比较多,但是其中可以看到如下几行:
drmOpenDevice: Open failed
[drm] failed to load kernel module "i915"
(II) I810(0): [drm] drmOpen failed
(EE) I810(0): [dri] DRIScreenInit failed. Disabling DRI.
...
Fatal server error:
Caught signal 11. Server aborting

提示找不到内核的 i915 模块,虽然 /lib/modules 中实际上是有这个模块的。因为之前的内核是我直接从主系统拷贝过去的,包括 initrd-$kernel.img 和 /lib/modules/$kernel 以及 /etc/modprobe.conf,所以问题可能就出在这里。

于是重新编译内核。注意在主系统下用 chroot 来进行编译和启动到 LFS 系统下进行编译可能会有差异,我两次都试过,用 md5sum 校验发现不同。建议启动到 LFS 系统进行编译。可能 Xorg 也需要重新编译,移除原来的 /usr/X11R6/bin/Xorg,运行:
# userpack install -a Xorg-6.9.0
即可。

编译内核时,LFS 没有 initrd,所以一些重要模块如 ext3, jbd, scsi 等需要编译到内核中,我写在了这里:
LFS kernel compling

这次启动 X 没有彻底黑屏,键盘还有响应,也可以按 3 键(CTRL+ALT+DEL)重启,但总的来说还是没有成功。有如下报错:
# Xorg -configure
dlopen: /usr/X11R6/lib/modules/drivers/apm_drv.so: undefined symbol: XvRTPort
(EE) Failed to load /usr/X11R6/lib/modules/drivers/apm_drv.so
(EE) Failed to load module "apm" (loader failed, 7)
(++) Using config file: "/root/xorg.conf.new"
(WW) I810: No matching Device section for instance (BusID PCI:0:2:1) found
(WW) ****INVALID MEM ALLOCATION**** b: 0xffe80000 e: 0xffefffff correcting^G
(WW) ****INVALID MEM ALLOCATION**** b: 0xffe40000 e: 0xffe7ffff correcting^G


Xorg detected your mouse at device /dev/mouse.
Please check your config if the mouse is still not
operational, as by default Xorg tries to autodetect
the protocol.

Your xorg.conf file is /root/xorg.conf.new

To test the server, run 'X -config /root/xorg.conf.new'

# X -config ~/xorg.conf.new
...
drmOpenDevice: node name is /dev/dri/card0
drmOpenDevice: open result is -1, (No such device or address)
drmOpenDevice: open result is -1, (No such device or address)
drmOpenDevice: Open failed
drmOpenDevice: node name is /dev/dri/card0
drmOpenDevice: open result is -1, (No such device or address)
drmOpenDevice: open result is -1, (No such device or address)
drmOpenDevice: Open failed
drmOpenByBusid: Searching for BusID pci:0000:00:02.0
drmOpenDevice: node name is /dev/dri/card0
drmOpenDevice: open result is 11, (OK)
drmOpenByBusid: drmOpenMinor returns 11
drmOpenByBusid: drmGetBusid reports pci:0000:00:02.0
...
(WW) I810(0): Extended BIOS function 0x5f05 failed.
...
Fatal server error:
Caught signal 11. Server aborting

"(WW) I810: No matching Device section for instance (BusID PCI:0:2:1) found"这个错误并没有什么关系,可以看这里:
Xorg wiki FAQ
用 lspci 可以看到这一点:
00:00.0 Host bridge: Intel Corporation Mobile 915GM/PM/GMS/910GML Express Processor to DRAM Controller (rev 04)
00:02.0 VGA compatible controller: Intel Corporation Mobile 915GM/GMS/910GML Express Graphics Controller (rev 04)
00:02.1 Display controller: Intel Corporation Mobile 915GM/GMS/910GML Express Graphics Controller (rev 04)
所以虽然 0:2:1 找不到,但 0:2:0 可以,如果真的找不到,一般会报告"No screen found"的错误。

只能换一种思路。现尝试编辑配置文件,将 i810 换成 vesa 试试:
# vi /etc/X11/xorg.conf
Section"Device"
Identifier "Card0"
Driver "vesa"
# Driver "i810"
VendorName "Intel Corporation"
BoardName "Mobile 915GM/GMS/910GML Express Graphics Controller"
BusID "PCI:0:2:0"
EndSection
这时候是可以启动 X 的,但只能以 root 身份运行,并且不能解决宽屏问题(915resolution)。

再尝试通过运行 xorgconfig 来获得一个配置文件(先将原来的文件备份),将其 Driver 改成 i810,在运行 915resolution 49 1280 768 之后,startx 竟然可以看到正确的长宽比,但之后就基本上没有什么响应了,twm 的窗口无法正常显示,点击鼠标只显示一些绿色的条纹。

我开始估计是窗口管理器的问题,于是接着安装其他的包,直到将 xfce4 安装之后,再进入 startx,这次可以看到正确的显示了,包括上下两个 panel,但是机器却好像越来越慢,点出来的菜单无法再隐藏,直至最后失去响应。

再使用 vesa 模块,基本上可以,但仍然不能以普通用户身份运行 startx。

所以现在是两个问题:
(1) i810 driver 或 vesa 1280x768
(2) normal user startx 的问题


(1)的 Xorg.0.log:
Could not init font path element /usr/X11R6/lib/X11/fonts/CID/, removing from list!
Could not init font path element /usr/X11R6/lib/X11/fonts/local/, removing from list!
ADVANCE_LP_RING: outring (0x27) isn't on a QWord boundary(WW) I810(0): Fixing display offsets.
ADVANCE_LP_RING: outring (0x2f) isn't on a QWord boundary(WW) I810(0): Fixing display offsets.
ADVANCE_LP_RING: outring (0x37) isn't on a QWord boundaryADVANCE_LP_RING: outring (0x3f) isn't on a QWord boundaryADVANCE_LP_RING: outring
(0x57) isn't on a QWord boundaryADVANCE_LP_RING: outring (0x5f) isn't on a QWord boundary(WW) I810(0): Fixing display offsets.
ADVANCE_LP_RING: outring (0x67) isn't on a QWord boundaryADVANCE_LP_RING: outring (0x87) isn't on a QWord boundaryADVANCE_LP_RING: outring
(0x8f) isn't on a QWord boundaryADVANCE_LP_RING: outring (0xaf) isn't on a QWord boundaryADVANCE_LP_RING: outring (0xb7) isn't on a QWord
boundaryADVANCE_LP_RING: outring (0xcf) isn't on a QWord boundaryADVANCE_LP_RING: outring (0xe7) isn't on a QWord boundaryADVANCE_LP_RING
: outring (0xff) isn't on a QWord boundaryADVANCE_LP_RING: outring (0x117) isn't on a QWord boundaryADVANCE_LP_RING: outring (0x12f) isn't
on a QWord boundaryADVANCE_LP_RING: outring (0x147) isn't on a QWord boundaryADVANCE_LP_RING: outring (0x15f) isn't on a QWord boundaryAD
VANCE_LP_RING: outring (0x177) isn't on a QWord boundaryADVANCE_LP_RING: outring (0x18f) isn't on a QWord boundaryADVANCE_LP_RING: outring
(0x1a7) isn't on a QWord boundaryADVANCE_LP_RING: outring (0x1bf) isn't on a QWord boundaryADVANCE_LP_RING: outring (0x1d7) isn't on a QW
ord boundaryADVANCE_LP_RING: outring (0x1ef) isn't on a QWord boundaryADVANCE_LP_RING: outring (0x207) isn't on a QWord boundaryADVANCE_LP
_RING: outring (0x21f) isn't on a QWord boundaryADVANCE_LP_RING: outring (0x237) isn't on a QWord boundaryADVANCE_LP_RING: outring (0x24f)
isn't on a QWord boundaryADVANCE_LP_RING: outring (0x267) isn't on a QWord boundaryADVANCE_LP_RING: outring (0x27f) isn't on a QWord boun
daryADVANCE_LP_RING: outring (0x297) isn't on a QWord boundaryADVANCE_LP_RING: outring (0x2af) isn't on a QWord boundaryADVANCE_LP_RING: o
utring (0x2c7) isn't on a QWord boundaryADVANCE_LP_RING: outring (0x2df) isn't on a QWord boundaryADVANCE_LP_RING: outring (0x2f7) isn't o
n a QWord boundaryADVANCE_LP_RING: outring (0x30f) isn't on a QWord boundaryADVANCE_LP_RING: outring (0x327) isn't on a QWord boundaryADVA
NCE_LP_RING: outring (0x33f) isn't on a QWord boundaryADVANCE_LP_RING: outring (0x357) isn't on a QWord boundaryADVANCE_LP_RING: outring (
0x36f) isn't on a QWord boundaryADVANCE_LP_RING: outring (0x387) isn't on a QWord boundaryADVANCE_LP_RING: outring (0x39f) isn't on a QWor
d boundaryADVANCE_LP_RING: outring (0x3b7) isn't on a QWord boundaryADVANCE_LP_RING: outring (0x3cf) isn't on a QWord boundaryADVANCE_LP_R
ING: outring (0x3e7) isn't on a QWord boundaryADVANCE_LP_RING: outring (0x3ff) isn't on a QWord boundaryADVANCE_LP_RING: outring (0x417) i
sn't on a QWord boundaryADVANCE_LP_RING: outring (0x42f) isn't on a QWord boundaryADVANCE_LP_RING: outring (0x447) isn't on a QWord bounda
ryADVANCE_LP_RING: outring (0x45f) isn't on a QWord boundaryADVANCE_LP_RING: outring (0x467) isn't on a QWord boundary(WW) I810(0): Fixing
display offsets.
ADVANCE_LP_RING: outring (0x46f) isn't on a QWord boundary(WW) I810(0): Fixing display offsets.
ADVANCE_LP_RING: outring (0x477) isn't on a QWord boundary(WW) I810(0): Fixing display offsets.
ADVANCE_LP_RING: outring (0x47f) isn't on a QWord boundary(WW) I810(0): Fixing display offsets.
ADVANCE_LP_RING: outring (0x487) isn't on a QWord boundary(WW) I810(0): Fixing display offsets.
ADVANCE_LP_RING: outring (0x48f) isn't on a QWord boundary(WW) I810(0): Fixing display offsets.
ADVANCE_LP_RING: outring (0x497) isn't on a QWord boundary(WW) I810(0): Fixing display offsets.
ADVANCE_LP_RING: outring (0x49f) isn't on a QWord boundary(WW) I810(0): Fixing display offsets.
ADVANCE_LP_RING: outring (0x4a7) isn't on a QWord boundary(WW) I810(0): Fixing display offsets.
ADVANCE_LP_RING: outring (0x4af) isn't on a QWord boundary(WW) I810(0): Fixing display offsets.
ADVANCE_LP_RING: outring (0x4b7) isn't on a QWord boundaryADVANCE_LP_RING: outring (0x7) isn't on a QWord boundary


(2)的 Xorg.0.log:
(==) VESA(0): Write-combining range (0xd0fa0000,0x10000)
(==) VESA(0): Write-combining range (0xd0f80000,0x30000)
(==) VESA(0): Write-combining range (0xd0f00000,0xb0000)
(==) VESA(0): Write-combining range (0xd0e00000,0x1b0000)
(==) VESA(0): Write-combining range (0xd0c00000,0x3b0000)
(==) VESA(0): Write-combining range (0xd0800000,0x7b0000)
(WW) VESA(0): Failed to set up write-combining range (0xd0000000,0xfb0000)
(II) VESA(0): virtual address = 0xb6c2b000,
physical address = 0xd0000000, size = 16449536
...
Could not init font path element /usr/X11R6/lib/X11/fonts/CID/, removing from list!
Could not init font path element /usr/X11R6/lib/X11/fonts/local/, removing from list!
FreeFontPath: FPE "/usr/X11R6/lib/X11/fonts/misc/" refcount is 2, should be 1; fixing.


(2)的解决
首先推测是不是程序权限的问题,就像前面出现过的,因为使用的是基于用户的包管理。于是运行:
# userpack files Xorg-6.9.0 >/usr/src/xorg.files
# cat !$ | xargs chown root.root
# chmod u+s /usr/X11R6/bin/Xorg
然后以普通用户登录运行 startx,出现一样的问题,所以不是这个原因,改回权限:
# cat /usr/src/xorg.file | xargs chown Xorg.Xorg
# chmod u+s /usr/X11R6/bin/Xorg

这是注意到一个问题,LFS 没有给这个普通用户创建 $HOME 目录,是否会是这个原因?创建 HOME 目录,将 /root/.xinitrc 拷贝到 ~,在运行 startx。OK。

(1)的解决
始终没有成功的配置好 i810 driver,于是只好用 vesa driver:
# gtf 1280x768 60
1280x768 @ 60.00 Hz (GTF) hsync: 47.70 kHz; pclk: 80.14 MHz
Modeline "1280x768_60.00" 80.14 1280 1344 1480 1680 768 769 772 795 -HSync +Vsync
然后复制这一行到 /etc/X11/xorg.conf 的 Monitor 段(一说要将"1280x768_60.00"改为"1280x768"),编辑 Screen 段的 Modes 为 "1280x768"。

然后运行 915resulotion:
# 915resolution 49 1280 768
之后 startx。

配置文件如下(主体是由 xorgconfig 产生的,做了一些修改:
# cat /etc/X11/xorg.conf
# File generated by xorgconfig.

#
# Copyright 2004 The X.Org Foundation
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# The X.Org Foundation BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
# OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
# Except as contained in this notice, the name of The X.Org Foundation shall
# not be used in advertising or otherwise to promote the sale, use or other
# dealings in this Software without prior written authorization from
# The X.Org Foundation.
#

# **********************************************************************
# Refer to the xorg.conf(5x) man page for details about the format of
# this file.
# **********************************************************************

# **********************************************************************
# Module section -- this section is used to specify
# which dynamically loadable modules to load.
# **********************************************************************
#
Section "Module"

# This loads the DBE extension module.

Load "dbe" # Double buffer extension

# This loads the miscellaneous extensions module, and disables
# initialisation of the XFree86-DGA extension within that module.
SubSection "extmod"
Option "omit xfree86-dga" # don't initialise the DGA extension
EndSubSection

# This loads the font modules
Load "type1"
# Load "speedo"
Load "freetype"
# Load "xtt"

# This loads the GLX module
# Load "glx"
# This loads the DRI module
# Load "dri"

# Load "bitmap"
# Load "ddc"
# Load "i2c"
# Load "int10"
# Load "vbe"
# Load "record"

EndSection

# **********************************************************************
# Files section. This allows default font and rgb paths to be set
# **********************************************************************

Section "Files"

# The location of the RGB database. Note, this is the name of the
# file minus the extension (like ".txt" or ".db"). There is normally
# no need to change the default.

RgbPath "/usr/X11R6/lib/X11/rgb"

# Multiple FontPath entries are allowed (which are concatenated together),
# as well as specifying multiple comma-separated entries in one FontPath
# command (or a combination of both methods)
#
#

FontPath "/usr/X11R6/lib/X11/fonts/misc/"
FontPath "/usr/X11R6/lib/X11/fonts/TTF/"
FontPath "/usr/X11R6/lib/X11/fonts/Type1/"
FontPath "/usr/X11R6/lib/X11/fonts/CID/"
FontPath "/usr/X11R6/lib/X11/fonts/75dpi/"
FontPath "/usr/X11R6/lib/X11/fonts/100dpi/"
FontPath "/usr/X11R6/lib/X11/fonts/local/"
# FontPath "/usr/X11R6/lib/X11/fonts/Speedo/"
# FontPath "/usr/X11R6/lib/X11/fonts/TrueType/"
# FontPath "/usr/X11R6/lib/X11/fonts/freefont/"

# The module search path. The default path is shown here.

# ModulePath "/usr/X11R6/lib/modules"

EndSection

# **********************************************************************
# Server flags section.
# **********************************************************************

Section "ServerFlags"

# Uncomment this to cause a core dump at the spot where a signal is
# received. This may leave the console in an unusable state, but may
# provide a better stack trace in the core dump to aid in debugging

# Option "NoTrapSignals"

# Uncomment this to disable the VT switch sequence
# (where n is 1 through 12). This allows clients to receive these key
# events.

# Option "DontVTSwitch"

# Uncomment this to disable the server abort sequence
# This allows clients to receive this key event.

# Option "DontZap"

# Uncomment this to disable the / mode switching
# sequences. This allows clients to receive these key events.

# Option "Dont Zoom"

# Uncomment this to disable tuning with the xvidtune client. With
# it the client can still run and fetch card and monitor attributes,
# but it will not be allowed to change them. If it tries it will
# receive a protocol error.

# Option "DisableVidModeExtension"

# Uncomment this to enable the use of a non-local xvidtune client.

# Option "AllowNonLocalXvidtune"

# Uncomment this to disable dynamically modifying the input device
# (mouse and keyboard) settings.

# Option "DisableModInDev"

# Uncomment this to enable the use of a non-local client to
# change the keyboard or mouse settings (currently only xset).

# Option "AllowNonLocalModInDev"

EndSection

# **********************************************************************
# Input devices
# **********************************************************************

# **********************************************************************
# Core keyboard's InputDevice section
# **********************************************************************

Section "InputDevice"

Identifier "Keyboard1"
Driver "kbd"

# For most OSs the protocol can be omitted (it defaults to "Standard").
# When using XQUEUE (only for SVR3 and SVR4, but not Solaris),
# uncomment the following line.

# Option "Protocol" "Xqueue"

Option "AutoRepeat" "500 30"

# Specify which keyboard LEDs can be user-controlled (eg, with xset(1))
# Option "Xleds" "1 2 3"

# Option "LeftAlt" "Meta"
# Option "RightAlt" "ModeShift"

# To customise the XKB settings to suit your keyboard, modify the
# lines below (which are the defaults). For example, for a non-U.S.
# keyboard, you will probably want to use:
# Option "XkbModel" "pc105"
# If you have a US Microsoft Natural keyboard, you can use:
# Option "XkbModel" "microsoft"
#
# Then to change the language, change the Layout setting.
# For example, a german layout can be obtained with:
# Option "XkbLayout" "de"
# or:
# Option "XkbLayout" "de"
# Option "XkbVariant" "nodeadkeys"
#
# If you'd like to switch the positions of your capslock and
# control keys, use:
# Option "XkbOptions" "ctrl:swapcaps"

# These are the default XKB settings for Xorg
# Option "XkbRules" "xorg"
# Option "XkbModel" "pc105"
# Option "XkbLayout" "us"
# Option "XkbVariant" ""
# Option "XkbOptions" ""

# Option "XkbDisable"

Option "XkbRules" "xorg"
Option "XkbModel" "pc105"
Option "XkbLayout" "us"

EndSection


# **********************************************************************
# Core Pointer's InputDevice section
# **********************************************************************

Section "InputDevice"

# Identifier and driver

Identifier "Mouse1"
Driver "mouse"
Option "Protocol" "Auto" # Auto detect
Option "Device" "/dev/mouse"

# When using XQUEUE, comment out the above two lines, and uncomment
# the following line.

# Option "Protocol" "Xqueue"

# Mouse-speed setting for PS/2 mouse.

# Option "Resolution" "256"

# Baudrate and SampleRate are only for some Logitech mice. In
# almost every case these lines should be omitted.

# Option "BaudRate" "9600"
# Option "SampleRate" "150"

# Mouse wheel mapping. Default is to map vertical wheel to buttons 4 & 5,
# horizontal wheel to buttons 6 & 7. Change if your mouse has more than
# 3 buttons and you need to map the wheel to different button ids to avoid
# conflicts.

Option "ZAxisMapping" "4 5 6 7"

# Emulate3Buttons is an option for 2-button mice
# Emulate3Timeout is the timeout in milliseconds (default is 50ms)

Option "Emulate3Buttons"
# Option "Emulate3Timeout" "50"

# ChordMiddle is an option for some 3-button Logitech mice

# Option "ChordMiddle"

EndSection

Section "InputDevice"
Identifier "Synaptics"
Driver "synaptics"
Option "Device" "/dev/input/mice"
Option "Protocol" "auto-dev"
Option "Emulate3Buttons" "yes"
EndSection


# **********************************************************************
# Other input device sections
# this is optional and is required only if you
# are using extended input devices. This is for example only. Refer
# to the xorg.conf man page for a description of the options.
# **********************************************************************
#
# Section "InputDevice"
# Identifier "Mouse2"
# Driver "mouse"
# Option "Protocol" "MouseMan"
# Option "Device" "/dev/mouse2"
# EndSection
#
# Section "InputDevice"
# Identifier "spaceball"
# Driver "magellan"
# Option "Device" "/dev/cua0"
# EndSection
#
# Section "InputDevice"
# Identifier "spaceball2"
# Driver "spaceorb"
# Option "Device" "/dev/cua0"
# EndSection
#
# Section "InputDevice"
# Identifier "touchscreen0"
# Driver "microtouch"
# Option "Device" "/dev/ttyS0"
# Option "MinX" "1412"
# Option "MaxX" "15184"
# Option "MinY" "15372"
# Option "MaxY" "1230"
# Option "ScreenNumber" "0"
# Option "ReportingMode" "Scaled"
# Option "ButtonNumber" "1"
# Option "SendCoreEvents"
# EndSection
#
# Section "InputDevice"
# Identifier "touchscreen1"
# Driver "elo2300"
# Option "Device" "/dev/ttyS0"
# Option "MinX" "231"
# Option "MaxX" "3868"
# Option "MinY" "3858"
# Option "MaxY" "272"
# Option "ScreenNumber" "0"
# Option "ReportingMode" "Scaled"
# Option "ButtonThreshold" "17"
# Option "ButtonNumber" "1"
# Option "SendCoreEvents"
# E

# **********************************************************************
# Monitor section
# **********************************************************************

# Any number of monitor sections may be present

Section "Monitor"
Identifier "Monitor0"

# HorizSync is in kHz unless units are specified.
# HorizSync may be a comma separated list of discrete values, or a
# comma separated list of ranges of values.
# NOTE: THE VALUES HERE ARE EXAMPLES ONLY. REFER TO YOUR MONITOR'S
# USER MANUAL FOR THE CORRECT NUMBERS.

### HorizSync 31.5 - 48.5

# HorizSync 30-64 # multisync
# HorizSync 31.5, 35.2 # multiple fixed sync frequencies
# HorizSync 15-25, 30-50 # multiple ranges of sync frequencies

# VertRefresh is in Hz unless units are specified.
# VertRefresh may be a comma separated
# comma separated list of ranges of values.
# NOTE: THE VALUES HERE ARE EXAMPLES ONLY. REFER TO YOUR MONITOR'S
# USER MANUAL FOR THE CORRECT NUMBERS.

### VertRefresh 50-90

# 1280x768 @ 60.00 Hz (GTF) hsync: 47.70 kHz; pclk: 80.14 MHz
### Modeline "1280x768_60.00" 80.14 1280 1344 1480 1680 768 769 772 795 -HSync +Vsync
Modeline "1280x768" 80.14 1280 1344 1480 1680 768 769 772 795 -HSync +Vsync

EndSection


# **********************************************************************
# Graphics device section
# **********************************************************************

# Any number of graphics device sections may be present

# Standard VGA Device:

Section "Device"
Identifier "Standard VGA"
VendorName "Unknown"
BoardName "Unknown"

# The chipset line is optional in most cases. It can be used to override
# the driver's chipset detection, and should not normally be specified.

# Chipset "generic"

# The Driver line must be present. When using run-time loadable driver
# modules, this line instructs the server to load the specified driver
# module. Even when not using loadable driver modules, this line
# indicates which driver should interpret the information in this section.

Driver "vga"
# The BusID line is used to specify which of possibly multiple devices
# this section is intended for. When this line isn't present, a device
# section can only match up with the primary video device. For PCI
# devices a line like the following could be used. This line should not
# normally be included unless there is more than one video device
# intalled.

# BusID "PCI:0:10:0"

# VideoRam 256

# Clocks 25.2 28.3

EndSection

# Device configured by xorgconfig:

Section "Device"
Identifier "Card0"
# Driver "vga"
Driver "vesa"
# unsupported card
#VideoRam 16384
# Insert Clocks lines here if appropriate
Option "HWCursor" "false"
EndSection


# **********************************************************************
# Screen sections
# **********************************************************************

# Any number of screen sections may be present. Each describes
# the configuration of a single screen. A single specific screen section
# may be specified from the X server command line with the "-screen"
# option.
Section "Screen"
Identifier "Screen 1"
Device "Card0"
Monitor "Monitor0"
DefaultDepth 24

Subsection "Display"
Depth 8
Modes "1280x768" "1280x1024" "1024x768" "800x600" "640x480"
ViewPort 0 0
EndSubsection
Subsection "Display"
Depth 16
Modes "1280x800" "1280x768" "1280x1024" "1024x768"
ViewPort 0 0
EndSubsection
Subsection "Display"
Depth 24
# Modes "1280x768" "1280x1024" "1024x768" "800x600" "640x480"
Modes "1280x768"
ViewPort 0 0
EndSubsection
EndSection

# **********************************************************************
# ServerLayout sections.
# **********************************************************************

# Any number of ServerLayout sections may be present. Each describes
# the way multiple screens are organised. A specific ServerLayout
# section may be specified from the X server command line with the
# "-layout" option. In the absence of this, the first section is used.
# When now ServerLayout section is present, the first Screen section
# is used alone.

Section "ServerLayout"

# The Identifier line must be present
Identifier "Simple Layout"

# Each Screen line specifies a Screen section name, and optionally
# the relative position of other screens. The four names after
# primary screen name are the screens to the top, bottom, left and right
# of the primary screen. In this example, screen 2 is located to the
# right of screen 1.

Screen 0 "Screen 1" 0 0

# Each InputDevice line specifies an InputDevice section name and
# optionally some options to specify the way the device is to be
# used. Those options include "CorePointer", "CoreKeyboard" and
# "SendCoreEvents".

InputDevice "Mouse1" "CorePointer"
InputDevice "Keyboard1" "CoreKeyboard"

EndSection

# Section "DRI"
# Mode 0666
# EndSection
很奇怪的事,开始就是不行,但后来突然可以了,在此之前只做过(2)的解决,不知道为什么。但至少保留这个可用的配置文件吧,应该是没什么问题了。

星期四, 十一月 23, 2006

LFS kernel compling

之前构建 LFS 时直接使用了老系统的内核,将 vmlinuz 和 initrd.img 直接拷贝过去再编辑 grub.conf 的,系统可以启动。

但现在编译 Xorg-6.9.0 却有问题,在日志中有如下信息:
drmOpenDevice: node name is /dev/dri/card0
drmOpenDevice: open result is -1, (No such device or address)
drmOpenDevice: open result is -1, (No such device or address)
drmOpenDevice: Open failed
drmOpenDevice: node name is /dev/dri/card0
drmOpenDevice: open result is -1, (No such device or address)
drmOpenDevice: open result is -1, (No such device or address)
drmOpenDevice: Open failed
[drm] failed to load kernel module "i915"
(II) I810(0): [drm] drmOpen failed
(EE) I810(0): [dri] DRIScreenInit failed. Disabling DRI.

推测可能和内核有关,于是重新编译内核。将原理系统的 .config 文件拷贝过来。但 LFS 本身是没有 initrd 的,所以有几个模块必须编译到内核中才能保证系统可以启动。解档 initrd(initrd.img解档)后可以查看 lib 下的几个模块,这几个模块需要注意:
ahci.ko
ata_piix.ko
ext3.ko
jbd.ko
libata.ko
scsi_mod.ko
sd_mod.ko

在 make menuconfig 时将 SCSI disk support 和 ext3 file system 编译到内核中,但是 ahci.ko, ata_piix.ko 和 libata 不知道是哪个子选项,于是直接编辑 .config 文件:
# sed -i 's/CONFIG_SCSI_ATA_PIIX=m/CONFIG_SCSI_ATA_PIIX=y/' .config
# sed -i 's/CONFIG_SCSI_SATA=m/CONFIG_SCSI_SATA=y/' .config
# sed -i 's/CONFIG_SCSI_SATA_AHCI=m/CONFIG_SCSI_SATA_AHCI=y/' .config

星期日, 十一月 19, 2006

FC6 误删 /usr/lib/python2.4 之 rpm 恢复

Fedora Core 6 下调试 BLFS 时误删了 /usr/lib/python2.4,很多程序都不能跑了,可以如下方式恢复:

# cd
# mkdir pkg && cd pkg
# for pkg in `rpm -qa`; do echo $pkg; rpm -V $pkg >$pkg; done
// 校验所有的包
# for pkg in `du * | grep -v '^0' | awk '{print $2}'`; do echo "$pkg"; rpm -ivh /mnt/iso/Fedora/RPMS/$pkg.i386.rpm --force; done
// 如果记录非空,说明该包有问题,则重新安装之
// 有少数包是 noarch,手工安装一下即可

星期四, 十一月 16, 2006

jhalfs-1.0 LFS trouble shooting

参照:
http://chowroc.blogspot.com/2006/10/jhalfs-clfs.html
进行配置,注意这里是 LFS 而不是 CLFS。所以运行:
# ./lfs -B 6.2 -D /mnt/lfs -K ~lfs/skeleton/linux-kernel-config -F ~lfs/skeleton/etc/fstab -G -T 0 -M

但是编译 028-binutils-pass1 时出错,gcc 报告 /tools/bin/ld 的 --hash-style=gnu 无效:
gcc -W -Wall -Wstrict-prototypes -Wmissing-prototypes -g -O2 -o ld-new ldgram.o ldlex.o lexsup.o ldlang.o mri.o ldctor.o ldmain.o ldwrite.o ldexp.o ldemul.o ldver.o ldmisc.o ldfile.o ldcref.o eelf_i386.o ei386linux.o ../bfd/.libs/libbfd.a ../libiberty/libiberty.a
/tools/bin/ld: unrecognized option '--hash-style=gnu'
/tools/bin/ld: use the --help option for usage information
collect2: ld returned 1 exit status
make[2]: *** [ld-new] Error 1
make[2]: Leaving directory `/mnt/lfs/sources/binutils-build/ld'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/mnt/lfs/sources/binutils-build/ld'
make: *** [all-recursive-am] Error 2
make: Leaving directory `/mnt/lfs/sources/binutils-build/ld'

再次编译,configure 报告 compiler 不能 work,"can't create executables":
checking for gcc... gcc
checking whether the C compiler (gcc ) works... no
configure: error: installation or configuration problem: C compiler cannot create executables.

于是排错,发现 $LFS/jhalfs/lfs-commands/chapter04/022-addinguser 有 useradd 和 groupadd 命令,但之前已经创建了用户,所以肯定会出错,那么后面的:
chown -v lfs $LFS/tools
chown -v lfs $LFS/sources
两个命令就无法运行,权限检查的结果也是如此,$LFS/sources的属主没有被更改。

进一步,发现 $LFS/jhalfs/lfs-commands/chapter04/023-settingenvironment 没有产生实际的效果,在 ~lfs 下没有相应的 .bashrc 和 .bash_profile。显然,set +h 没有运行,所以这可能是导致报告 ld --hash-style=gnu 无法识别的原因吗?

于是手工添加了 ~lfs/.bashrc 和 ~/.bash_profile,再在 $LFS/jhalfs 下运行 make,但结果好像是整个进程挂起了,编译 binutils 一小时都没有结果,而手工编译却只要几分钟就结束了。查看进程树得到如下显示:
mlterm
\_ bash
\_ su -
\_ -bash
\_ make
\_ /bin/sh -c ( time { su - lfs -c "source /home/lfs/.bashrc && /mnt/lfs/jhalfs/lfs-commands/chapter05/028-binutils-pass1" >>logs/028-binutils-pass1 2>&1 ; } ) 2>>logs/028-binutils-pass1 && \?echo -e "\nKB: `du -skx --exclude=jhalfs /mnt/lfs`\n" >>logs/028-binutils-pass1
\_ /bin/sh -c ( time { su - lfs -c "source /home/lfs/.bashrc && /mnt/lfs/jhalfs/lfs-commands/chapter05/028-binutils-pass1" >>logs/028-binutils-pass1 2>&1 ; } ) 2>>logs/028-binutils-pass1 && \?echo -e "\nKB: `du -skx --exclude=jhalfs /mnt/lfs`\n" >>logs/028-binutils-pass1
\_ su - lfs -c source /home/lfs/.bashrc && /mnt/lfs/jhalfs/lfs-commands/chapter05/028-binutils-pass1
\_ /bin/bash
/bin/bash ./progress_bar.sh 028-binutils-pass1
\_ sleep .12
好像是启动了一个 /bin/bash 但没有调用任何命令。

目录树是用如下方法得到的:
$ echo "roc 15754 0.0 0.5 10588 1344 ? S 16:16 0:01" | wc
1 10 65
$ ps auxf | cut -b 65-
(当然也可以用 pstree)

这是在 Fedora Core 6 环境下构建的,之后尝试 jhalfs-1.0 CLFS i386 却可以通过 binutils-pass1 这一段;并且最后通过使用 lfs-livecd 完成了安装!

所以只能推测是版本或平台的问题,可能是 FC6 太新,gcc-4.1.1 于 binutils-2.16.1 不能正确匹配(livecd 是 gcc-4.0.3)的原因。