LFS 学习日记(第八章 使 LFS 可以启动 )

2010年10月23日 星期六
/LFS-BOOK-6.6-HTML/chapter08/chapter08.html
8. Making the LFS System Bootable
/LFS-BOOK-6.6-HTML/chapter08/introduction.html
8.1. Introduction
/LFS-BOOK-6.6-HTML/chapter08/fstab.html
8.2. Creating the /etc/fstab File

question:
/dev/<xxx>     /            <fff>  defaults        1     1
一般的系统中的 dump (第5项)项都是设为0,不备份文件系统,为什么 LFS 这里要备份?是怎样备份的,难道要把整个 / 根文件系统都备份到某个地方,那怎样备份、备份到哪里又是怎么一回事?

question:
sysfs          /sys         sysfs  defaults        0     0
devpts         /dev/pts     devpts gid=4,mode=620  0     0
tmpfs          /dev/shm     tmpfs  defaults        0     0
为什么 Ubuntu 10.04 的 /etc/fstab 中没有这3个虚拟文件系统的挂载项?

/dev/pts/n: 虚拟终端(/dev/pts/n) 在Xwindows模式下的伪终端 (参考:终端 /dev/tty http://www.cnblogs.com/wangtianxj/archive/2009/08/27/1555296.html )

2010年10月26日 星期二
1、todo:
Please note that very little software currently uses POSIX-shared memory. Therefore, consider the /dev/shm mount point optional. For more information, see Documentation/filesystems/tmpfs.txt in the kernel source tree.
有必要时学习 tmpfs

2、挂载 MS-DOS 或源于 Windows 的文件系统需要注意的:
Filesystems with MS-DOS or Windows origin (i.e.: vfat, ntfs, smbfs, cifs, iso9660, udf) need the “iocharset” mount option in order for non-ASCII characters in file names to be interpreted properly.
The “codepage” option is also needed for vfat and smbfs filesystems.

例如:在 zh_CN.UTF-8 的 locale 下挂载一个 fat16,fat32 的 U 盘(用在 Windows 系统中)的参数可以为:
noauto,user,quiet,showexec,iocharset=utf8,codepage=936

3、可以在编译内核时指定默认的 codepage 和 iocharset,但是 ntfs 文件系统不能在编译内核时指定默认值
“Default NLS Option” (CONFIG_NLS_DEFAULT), “Default Remote NLS Option” (CONFIG_SMB_NLS_DEFAULT), “Default codepage for FAT” (CONFIG_FAT_DEFAULT_CODEPAGE), and “Default iocharset for FAT” (CONFIG_FAT_DEFAULT_IOCHARSET).

4、todo: 磁盘 NCQ

/LFS-BOOK-6.6-HTML/chapter08/kernel.html
8.3. Linux-2.6.32.8

1、建议从头创建 .config 内核配置文件
2、如果配置了模块,有可能需要配置 /etc/modprobe.d 下的配置文件

2010年10月27日 星期三
本书提到的编译内核更多的信息:
1、配置内核编译的一些考虑
http://www.linuxfromscratch.org/hints/downloads/files/kernel-configuration.txt
1)、
New kernel releases often introduce new config symbols.  Often more
    important, new kernel releases may rename config symbols.  When this
    happens, using a previously working .config file and running "make
    oldconfig" won't necessarily produce a working new kernel for you, so you
    may find that you need to see what NEW kernel symbols have been introduced.

    To see a list of new config symbols when using "make oldconfig", use

        cp user/some/old.config .config
        yes "" | make oldconfig > conf.new
        grep "(NEW)" conf.new

2、一些 BLFS 包需要特定内核编译选项支持的信息:
http://www.linuxfromscratch.org/blfs/view/svn/longindex.html#kernel-config-index
制作 LiveCD 可能需要的一些应用程序内核配置项:automounter, dbus, udf file system, support for Host-side USB

3、
english:
Allowing modules is not required.  They can be turned off with a kernel configuration
    option.  However, if this is done, it precludes using some proprietary modules
    like Nvidia or VMware drivers.
question: 这段话的意思不大懂。

4、LFS 推荐针对自己的硬件尽可能的不用模块

5、模块的加载涉及的两个配置文件 /etc/modprobe.conf /etc/sysconfig/modules

6、
english:
Additionally, modules can be loaded automatically by the
    LFS modules boot script when directed by its configuration file,
    /etc/sysconfig/modules.
question: 这段话的意思不大懂,上面的两个配置文件各自的作用是什么?

7、
i.  Device Drivers
This is one of the most important configuration areas.  

2010年10月29日 星期五

内核配置项记录:
一、
1、Executable file formats / Emulations
去掉默认的:
1)、Write ELF core dumps with partial segments
ELF core dump files describe each memory mapping of the crashed process, and can contain or omit the memory contents of each one.
不大懂,大概是调试崩溃的进程的,帮助中说不确定就选 No

2)、Kernel support for MISC binaries
Once you have registered such a binary class with the kernel, you can start one of  those programs simply by typing in its name at a shell prompt; Linux will automatically feed it to the correct interpreter.

这个大概是使执行 Java、Python、.NET 等程序更方便高效,我计划的系统不需要运行这些东西。

在 LFS 网站上的编译提示中也说 “Generally only ELF support is needed.”

2、Networking support
我不需要使用网络,去掉。

二、Device Drivers
3、question:
Memory Technology Device (MTD) support
 Memory Technology Devices are flash, RAM and similar chips, often used for solid state file systems on embedded devices.
这个选项不知道对U盘系统有没有影响?还是像固态硬盘需要它的支持?对手机内存卡和SD卡的识别有没有问题?帮助中说不确定就选 No,所以没有把它选择上,以后碰到 U 盘系统出问题或者手机内存卡、SD卡、固态硬盘不能识别的情况下可以重新编译把它选上。

4、Parallel port support 默认的并行端口没有选上(如并口打印机),我也不用打印机,不用更改。

5、Loopback device support 默认是编译入内核,
To use the loop device, you need the losetup utility, found in the util-linux package, see  <ftp://ftp.kernel.org/pub/linux/utils/util-linux/>.        

6、Promise SATA SX8 support
默认没选,也不知常用不,按默认不选

7、Low Performance USB Block driver
This driver supports certain USB attached storage devices such as flash keys. If you enable this driver, it is recommended to avoid conflicts with usb-storage by enabling USB_LIBUSUAL.
默认未选,http://lamp.linux.gov.cn/Linux/kernel_options.html(金步国 Linux 2.6.19.x 内核编译选项) 也说:它不是用来支持U盘的,不懂的就别选。没有选上

8、Support XIP filesystems on RAM block device
question: 什么是 XIP 文件系统?

9、Packet writing on CD/DVD media
默认没选,"金步国内核编译选项"上说是 CD/DVD刻录支持 ,看看不选能不能刻录。不知道为什么 writing 前面为什么要加上一个 Packet,难道还有不是 Packet 的 writing 吗?我准备定制的系统不用刻录。

10、Very old hard disk (MFM/RLL/IDE) driver
It is required for systems with ancient MFM/RLL/ESDI drives.
默认没选,保持没选。
question: 这里的老是老到什么程度?大概多少年前的?"金步国内核编译选项"上说:Old hard disk (MFM/RLL/IDE) driver 旧版本的MFM/RLL/IDE驱动,不建议使用
MFM( http://en.wikipedia.org/wiki/Modified_Frequency_Modulation )
RLL( http://en.wikipedia.org/wiki/Run_Length_Limited )
ESDI( http://en.wikipedia.org/wiki/Enhanced_Small_Disk_Interface )

11、TI Flash Media interface support (EXPERIMENTAL)
不知道什么东西,按默认不选。

12、EEPROM support
好像是用于风扇转速、主板温度之类传感器的东西,按默认,未选。

13、ENE CB710/720 Flash memory card reader support (NEW)
也许是不常见的闪存卡,按默认,未选。

14、所有的 Misc devices 都没选,所以这一总菜单原来是默认的选择编译入内核,这里改为不选。

15、ATA/ATAPI/MFM/RLL support
IDE硬盘及光驱等的支持,默认未选,因为可能会使用这些设备,把它选择编译入内核(Y)。帮助上也说不确定时选择 Y。

1)、Include IDE/ATAPI CDROM support
默认未选,但是可能使用 ATAPI 光驱,把它选择编译入内核(Y)。

2)、Platform driver for IDE interfaces (NEW)
帮助:This is the platform IDE driver, used mostly for Memory Mapped IDE devices, like Compact Flashes running in True IDE mode.
If unsure, say N.
“运行于真实 IDE 模式的压缩 Flash 设备”不知是什么设备?不知会不会碰到?以后如果比较普通再把它选择上。默认是未选的。

3)、Generic PCI IDE Chipset Support
默认未选,但是可能使用,把它选择编译入内核(Y)。

4)、AMD and nVidia IDE support,Intel PIIX/ICH chipsets support,VIA82CXXX chipset support,因为把上面的通用 PCI IDE 芯片组选上了,所以把我认为最常用的几种 IDE 芯片支持选上为模块支持(M)。这三种选项默认都是未选的。以后如果需要编译成通用内核,就把所有现在电脑可能用到的 IDE 芯片支持都选为模块支持。

现在只作尝试性的选择我认为最最常用的选项。

16、RAID Transport Class
默认未选,这里选为编译入内核(Y)

17、Serial ATA (prod) and Parallel ATA (experimental) drivers
不知道默认是选还是没选,反正这里必须选上。选为编译入内核(Y)
1)NVIDIA SATA support,VIA SATA support
是我认为比较多的类型,编译为模块(M)。默认未选。
2)其它保持默认。其中有很常见的 Intel、AMD 等等 SATA 的支持。

18、Multiple devices driver support (RAID and LVM)
1)  Linear (append) mode,RAID-0 (striping mode,RAID-1 (mirroring) mode,RAID-10 (mirrored striping) mode (EXPERIMENTAL),RAID-4/RAID-5/RAID-6 mode 这些默认都没有选,可以考虑到有可能使用这些存储系统,故这几项全部选为编译入模块( M )。

19、Input device support
1)、Provide legacy /dev/psaux device
不知道有什么用,先以为是为支持那种 ps 接口的圆口鼠标,结果后面还有一个Mice->PS/2 mouse。默认没选。这里也未选。

2)、Joysticks/Gamepads, Tablets, Touchscreens
默认选为编译入内核,这里都只准备在普通 PC 上使用这个编译的内核,这些设备都不会用,去掉为不选。

3)、Miscellaneous devices
(1)、PC Speaker support
不想使用声卡,我的定制系统可以使用 PC 喇叭报警,所以把它编译入内核。

20、Character devices
1)因为里面的虚拟终端和控制台也许在字符界面的情况下需要使用,故这方面的选项保持默认没动。
2)Serial drivers
不会用串行口,去掉里面默认选上的几项。

21、I2C support
我编译的内核不需要 I2C 之类的使用,所以去掉了里面所有的选项

22、SPI support
 MMC and SD cards can be accessed using SPI protocol; and for DataFlash cards used in MMC sockets, SPI must always be used.  
因为帮助中如上说,而上面那些东西是我编译的内核想支持,这里选为编译入内核。默认未选。

23、Watchdog Timer Support
不需要,去掉,默认是选为编译入内核的。

24、Graphics support
1)/dev/agpgart (AGP Support)
(1)ATI chipset support NVIDIA,nForce/nForce2 chipset support,VIA chipset support
把以上几个我认为常用的显卡类型选为编译为模块。默认未选。

2)、Direct Rendering Manager (XFree86 4.1.0 and higher DRI support)
因为我定制的系统不需要显示方面的硬件加速。Intel 830M, 845G, 852GM, 855GM, 865G (i915 driver)默认是编译入内核的,这里去掉编译入内核,改为不选。其它保持不选的默认的就行了。

3)、Support for frame buffer devices
(1)、VESA VGA graphics support
想主要使用 VESA 的驱动作为定制系统的图形界面,故选为编译入内核。默认未选。
(2)、nVidia Framebuffer Support,Intel 810/815 support (EXPERIMENTAL),ATI Radeon display support
把我认为常用的几个选上,不知有用没有?打算是在 VESA 驱动或许对它们无效时使用。

25、Sound card support
我定制的系统不需要声音,去掉选项。默认为编译入内核。

26、USB support
USB Printer support
不会使用,去掉选项。默认为编译入内核。

 USB Gadget Support
不知道在我定制的USB存储之类的系统中需要不?默认没有选,保持默认,以后出问题时再试试。

27、MMC/SD/SDIO card support
默认没选,我定制的系统必须,选为编译入内核。

1)并把下面全部的 MMC/SD/SDIO Host Controller Drivers 选为了编译入模块。默认应该全为不选。

28、Sony MemoryStick card support (EXPERIMENTAL)
默认没选,这里选为模块,并把下面可能用的都选为模块。

29、Real Time Clock,DMA Engine support,Auxiliary Display support,Userspace I/O drivers,TI VLYNQ,Staging drivers,X86 Platform Specific Device Drivers
以上不知是什么东西。保持默认。

30、File systems
1)、Second extended fs support,The Extended 4 (ext4) filesystem
编译入内核,默认为不选。
2)、Kernel automounter version 4 support (also supports v3)
不需要,去掉。默认为编译入内核。
3)、FUSE (Filesystem in Userspace) support
默认为不选。在CDLinux 看到使用这种文件系统(还不知道这种文件系统的作用),选择为编译为模块。
4)、CD-ROM/DVD Filesystems
(1)、UDF file system support
编译为模块。默认为不选。
5)、DOS/FAT/NT Filesystems
我的定制系统需要Windows文件系统的全面支持
分别设置如下:
(936) Default codepage for FAT
(cp936) Default iocharset for FAT(question: cp936和gb2312有什么区别?是不是前者是gbk的另一个名称?)
NTFS write support 选择为编译放内核,默认为不选。

6)、Miscellaneous filesystems
(1)、
Compressed ROM file system support (cramfs)
SquashFS 4.0 - Squashed file system support
以上两项默认都没有选,但是我定制的系统中可能需要这种压缩文件系统作为根文件系统所在的系统,故选择为编译入内核。另外,CDLinux 现在的根文件系统就是用的 cquashfs 文件系统(原来好像使用的是 cramfs 文件系统)。

(2)、ROM file system support
而 ROM file system support 我可能在把定制在 CD 上的系统安装到其它的U盘或硬盘上时要用到。到时要用的话再编译上。保持默认不选。

7)、Native language support
(1)、(cp936) Default NLS Option(默认的好像为cp437)

(2)、Simplified Chinese charset (CP936, GB2312),Traditional Chinese charset (Big5) 这两项默认为不选,这里改为编译入内核。

31、 Kernel hacking
除了下面这个选项,其它全部去掉了为不选。以后要用时再选上。
Enable verbose x86 bootup info messages 保留编译入内核的默认选项。以查看启动信息,以后不用时可以去掉。

32、  Security options,Cryptographic API,Virtualization,Library routines
因为不需要,全部去掉,但是其中Library routines的几个选项是去不掉的,也许是系统必须的,只能保留。

question: This option alone does not add any kernel code. 在内核编译配置中的帮助中的这句话是什么意思?难道其它的选项还会增加内核代码?

time { make; } 2>&1 | tee /backup/installlogs/8linux.make.log
real    3m31.552s
user    2m12.596s
sys    4m50.114s

time { make modules_install; } 2>&1 | tee /backup/installlogs/8linux.modules_install.log
real    0m1.984s
user    0m0.436s
sys    0m2.364s

question:
The headers in the system's include  directory should always be the ones against which Glibc was compiled, that is, the sanitised headers from this Linux kernel tarball.
什么意思?

2010年11月02日 星期二
/LFS-BOOK-6.6-HTML/chapter08/grub.html

1、
grub-mkrescue --image-type=floppy floppy.img
命令制作的急救软盘镜像可以在 Vmware 虚拟机中直接加载,是进入 Grub 命令行。

2、旧的 grub 程序的分区号从0开始,新版 grub ( grub2 )的磁盘号和分区号都是从1开始。

3、Grub 的磁盘编号会略过光驱

4、grub-install --grub-setup=/bin/true /dev/sda
We use --grub-setup=/bin/true for now to prevent updating the Master Boot Record (MBR).
/bin/true 命令只是返回执行成功的状态代码,实际上它什么也没做,所以这里实际并没有真正使用 grub-setup 把 grub 安装到启动扇区。

5、question:
Grub2 中 search 命令设置的分区( fs-uuid 指定的那个分区)是指定后面内核映像文件所在的分区吗?如:原来的 Ubuntu 根分区安装在 sda1 ( boot 目录也在这个分区中),现在的 LFS 根分区在 sdb1 ( boot 目录也在这个分区中 ),在 LFS 中的 Grub2 配置菜单中针对 Ubuntu 指定了 search 命令,那么其后面的内核映像文件所在的分区就是这个 search 命令所指定的分区吗? search 命令所指定的分区是不是会覆盖由上面 set root=(hd0,2) 类似的命令指定的映像文件所在分区呢?

2010年11月04日 星期四
今天,测试了一下新安装在 Vmware 虚拟机里的 LFS ,不能启动,报告 CPU 被虚拟机 guest 系统禁止,虚拟机 guest 系统需要重启或关闭,点击确认后,控制台内容卡在找不到 root 所在的分区。

在宿主机上查看磁盘驱动为:00:10.0 SCSI storage controller: LSI Logic / Symbios Logic 53c1030 PCI-X Fusion-MPT Dual Ultra320 SCSI (rev 01)
Kernel driver in use: mptspi
故重新把 [*] Fusion MPT device support 选上编译入内核,并把下面的几个驱动统统编译入内核(先试过编译为模块,启动时仍然不能找到根分区,可见,至少根分区所在的磁盘驱动必须编译入内核,否则可能就必须使用 initrd 映像文件完成?)。默认是不选 Fusion MPT 设备支持的。

2010年11月05日 星期五
在用前面制作的恢复软盘镜像测试新安装的 LFS 的时候,仍然不能启动,卡在执行初始化脚本 /etc/rc.d/init.d/udev 中的 /sbin/udevd --daemon 上,现象是 udevd 不能初始化各种系统设备(除了把 /lib/udev/devices/ 里的静态设备节点拷到 /dev 下面),报告:“error initializing control socketerror getting socket: Address family not supported by protocol”。然后报告找不到 /etc/fstab 中要求加载的根分区和交换分区。(见后附图一、附图二)

在用 Ubuntu 10.04 的内核映像和 initrd 文件测试中比较正常,LFS 系统可以启动并工作。

初步判定是内核编译的问题。原来把“Networking support”中的项目全部去掉了(不小心还留了一个对我没有用的 Wireless),现在把 Packet socket, Unix domain sockets,TCP/IP networking 三项重新加入编译入内核,在测试中可以正常启动 LFS 了。正如内核编译帮助中所说,就是系统不需要联网,有些选项针对一些应用程序也还是必须的。这也许是 Linux 的系统跟网络支持方面联系比较紧密吧?

2010年11月08日 星期一
1、
在 Vmware 中有两个虚拟磁盘,/dev/sda 是宿主系统 Ubuntu 10.04,/dev/sdb 是新编译的 LFS 6.6,把宿主系统的 grub.cfg 配置加入 LFS 的 grub.cfg 后,在用 chroot 进入 LFS后或者用急救软盘启动进入LFS,执行 grub-setup '(hd0)' ,报告“error: the symbol 'grub_puts_' not found”,在网上搜了一下,可能是 LFS 新安装的 grub 跟原来的宿主系统的 grub 有冲突。把 grub 启动信息安装入 LFS 所在的磁盘(grub-setup '(hd1)'),并在 Vmware 的 BIOS 中将第一启动设备设置为 LFS 所在的硬盘。一切正常。(见后附图三)

2、
要使用 root=UUID=194a8da1-e86c-4344-ad75-4e16b31a9a9c 根分区参数,必须加载虚拟引导磁盘(即 initrd.img 文件)。Grub 引导程序是不能直接使系统加载 UUID 的根分区。

3、
set root=(hd1,1) 和 search --no-floppy ... 的功能是重复的,但是这里 Grub 程序是可以识别 --fs-uuid --set 并根据 uuid 找到正确的引导文件所在的分区(vmlinux-2.6.* 和 initrd.img-* 等文件)
question:
不知道为什么 Grub 可以识别 uuid 从而找到正确的引导文件的分区,那为什么它必须加载虚拟磁盘文件(initrd.img-*)才能加载根分区?
— Command: linux file ...

    Load a Linux kernel image from file. The rest of the line is passed verbatim as the kernel command-line. Any initrd must be reloaded after using this command (see initrd).

答:加载根分区是内核负责的,而内核识别 uuid 是在内核加载完成以后才可以的,所以,如果使用了UUID设备根分区,则必须在 Grub 的 linux 命令后面执行 initrd 命令以重载虚拟映像磁盘文件以设置内核所需的各种参数?但是有没有可能直接把 Grub 识别到的 UUID 所在的分区信息传给内核直接使用呢?这样就可以省去了 initrd 文件?
 
4、
在 Lfs 的 grub 引导菜单中关于 Ubuntu 的引导项,最简可为:
menuentry 'Ubuntu Linux 2.6.32-25-generic' --class ubuntu --class gnu-linux --class gnu --class os {
        linux   (hd1,1)/boot/vmlinuz-2.6.32-25-generic root=UUID=4d8ec044-1233-40f8-94c6-67d04a1b6c3b ro text
        initrd  (hd1,1)/boot/initrd.img-2.6.32-25-generic
}

关于 LFS 的引导项,最简可为:
menuentry "GNU/Linux, with Linux 2.6.32.8-lfs-6.6" {
        linux   /boot/vmlinux-2.6.32.8-lfs-6.6 root=/dev/sdb1 ro
}
这可能是因为 Grub 默认引导文件为它所安装的分区,所以在这里即使不用设置引导分区(set root='(hd0,1)' 或 search --no-floppy --fs-uuid --set 也可以引导系统,这里 --set 是“If the --set option is used, the first device found is set as the value of environment variable var. The default variable is ‘root’. ”,用于设置引导文件所在的分区的,跟前面的set root= 是一样的作用 参见: http://www.gnu.org/software/grub/manual/grub.html#search )

5、
如果根分区的文件系统没有编译入内核,那么就必须添加 initrd 虚拟引导磁盘,使得内核可以识别根分区文件系统。

附图一:

附图二:

附图三:

One thought on “LFS 学习日记(第八章 使 LFS 可以启动 )”

  1. Hi,你这篇文章的图片 我一张都看不见,我用的浏览器是firefox3.6的,联通的网

Comments are closed.