2007年6月21日星期四

最胆大的飞机乘客

今天,也不知道是有幸还是不幸,我见识了自打开始坐飞机以来,最胆大的乘客。

我坐在9B,左边是9A,9A靠窗,坐着一个中年男子,年龄看上去在40正负5岁的样子,上身穿红色T恤,下身穿米色长裤,头发有些花白,上飞机之前打电话操一口听不明白的口音。

飞机即将降落,乘务员广播请大家收起小桌板调直坐椅靠背打开遮阳板。不一会儿,飞机从云中钻了下来,可以看见地面景物了。正在这时,9A从裤子口袋里拿出手机,按了一下,随即放了回去。我心里一惊,“不会吧......”。再过了一会儿,飞机开始调整姿势对准跑道,9A再次拿出手机,我偷偷瞟了一眼,手机屏幕上显示着“您有三个新短消息”。这时飞机已经开始对着跑道俯冲,9A打开短消息,都是些“某地移动欢迎您”之类的。随即在飞机着陆的那一霎那,9A开始删消息,然后打电话联系出租车来接。

还好,谢天谢地,飞机毕竟最后还是安全着陆了。

2007年6月10日星期日

把Linux作为日常使用的操作系统(2) 在外置USB盘上安装Fedora 7

0. Introduction
0. 介绍
One of the many inconvenient things about Windows is that, you can not just detach a hard drive with Windows from one computer and put it into use on another computer, not to mention doing it with an external USB drive.

Linux makes a lot of differences. You can install Linux to an external USB drive, and then attach this drive to any other computer. You only need to setup the BIOS to boot from USB, and then, most likely, the Linux on USB drive can recognize most of the hardware devices of the computer and can work smoothly.

Think about it, get an external USB drive, install Linux on it, then take it around with you, whenever you need Linux, attach the drive to USB port of nearly any computer and boot from it. Cool? Yes. And the most important is that you don't need to change any data on the internal drive of any computer, not even a single bit.

In fact, installing Linux to external USB hard disk drive and installing to USB flash pen/stick are slightly different. The former is more suitable for a whole blown operation system and applications that you may want to use in daily life or work.

That's all for the background introduction, I will now show you how to install Fedora 7 to an external USB hard disk drive and setup computer to boot from it.
Windows有一个很不方便的地方,就是它一旦被安装到某台机器上,你很难直接把硬盘拿下来然后装到另一台机器上去用,更不用说安装到一个外置的USB硬盘上了。

而Linux不同,你可以把它安装到一个外置的硬盘上,然后把这个硬盘接到随便哪台计算机的USB口上。你只需要设置计算机从USB盘启动,就行了,Linux可以自动识别出大部分的设备,并且工作正常。

设想一个,找一个USB移动硬盘,把Linux装上,然后带着它到另一个地方,接到计算机上,从USB启动,就可以进你的Linux了。很酷吧?呵呵。关键是你根本不需要改变计算机内置硬盘上的任何数据,毫发不损。

事实上,把Linux安装到USB外置移动硬盘和USB Flash盘稍有区别,前者更适合于安装可以日常使用的完整操作系统和应用程序。

接下来,我将介绍如何把Fedora 7安装到一个外置移动硬盘上,并且设置从这块外置移动硬盘启动。
1. Start normal installation
1. 开始正常的安装
Installing Linux to external USB drive is not much different with installing to internal IDE disk. I downloaded DVD image of Fedora 7, and burned a bootable installation DVD. The first step is to boot from the DVD, and choose to install a new system.
安装到USB外置硬盘与安装到内置硬盘没太大区别。我下载了Fedora 7的DVD映像文件,然后刻了张盘,从DVD盘启动,选择安装新的系统就行了。
2. Setup the partitions
2. 设置分区
When it's time to setup the partitions, remember to setup it manually. The installation program of Fedora tends to setup partitions managed by LVM, but if you want to boot from your USB drive, you should avoid to use LVM.

In fact, when booting from external USB drive, LVM is okay for Fedora 6, but trouble for Fedora 7.
当需要设置磁盘分区的时候,记住要选择自选的分区设置。Fedora安装程序似乎偏向于使用LVM来管理分区,假设你想从USB外置硬盘启动,那么不要用LVM。

事实上,当需要从外置的USB移动硬盘启动的时候,LVM对于Fedora Core 6没问题,对于Fedora 7,就成问题了。
Fedora Core 6 and previous versions recognize internal IDE disks as hda, hdb, hdc etc, and recognize external USB drives as sda, sdb, sdc etc. In fact, since the first time I used Linux, the first IDE disk had been hda.

But now Fedora 7 comes, with disk drivers changed. All the disks, whatever IDE or SCSI, or USB, are recognized as sda, sdb, sdc etc. This change has a wide range of influence, and deserves to be taken special notice.

My desktop computer has a 80GB internal IDE disk (brand: Western Digital), and I attached a 80GB USB drive (brand: Hitachi) to it.The two drives were recognized as sda and sdb during installation.

There were three FAT32 partitions in my USB drive: sdb1, sdb2 and sdb3. I want to install Linux to the 30GB spcace of sdb1, so I need to delete sdb1 first.
Fedora Core 6以及以前版本,会把内置的IDE硬盘识别为hda, hdb, hdc等等,然后把外置的USB盘识别为sda, sdb, sdc等等。事实上自从我第一次用Linux,第一块IDE盘就一直是hda。

而到了Fedora 7,由于驱动程序换了,所有的硬盘,不论是IDE的还是SCSI的,还是USB的,全都被识别为sda, sdb, sdc等等。这是一个影响很大的变化,需要特别注意。

我的机器有一块80GB的内置IDE硬盘(Western Digital牌子的),然后外接了一块80GB的USB外置硬盘(Hitachi牌子的),他们分别被安装程序识别为sda和sdb。

我的USB外置硬盘原先有三个FAT32分区,分别是sdb1, sdb2和sdb3。我想把Linux安装到原先sdb1所用的30GB空间中,所以先要删除原有的sdb1分区。

After partition sdb1 deleted, we need to create at least two partitions in this 30GB space, one for root, one for swap. And of course, if you like, you can create more sophisticated partition layout. Avoid to use LVM, or you may not be able to boot from USB drive at last.
删除掉原来的sdb1之后,至少需要在这30GB的空间里创建两个分区,一个供根目录用,一个供SWAP用。当然,如果你喜欢,也可以作更复杂的分区设置。避免用LVM,否则最后可能会启动不了。
It is easy to create a paritition for root.
为根目录创建分区很简单:
It is also easy to create a swap partition.
(I don't want the swap partition to be an extended partition, so I chosen "Force to be a primary partition", that's only my personal preference, not anything required. If you are not familiar with partition table, avoid choosing this option.)
为SWAP创建分区也不难。
(我为了不让SWAP所处的这个分区成为扩展分区中的一个,所以选择了“Force to be a primary partition”,但是这只是个人爱好,不是必须的。如果你对分区表的原理不太熟悉,尽量不要选择这项。)
At last, the partition layout is like this:
最后的分区设置是这样的:
3. Install GRUB
3. 安装GRUB
Don't choose installing GRUB during the installation process, we will install GRUB manually later.
不要在安装过程中选择安装GRUB,而应该在安装完成之后手工去做。
After the installation of Fedora completed, boot from installation DVD again, and enter rescue mode.
安装完成后,再次从光盘启动,选择进入应急修复。
Then let the installation program automatically mount the Linux we just installed to /mnt/sysimage.
然后让安装程序自动地将刚安装好的系统mount到/mnt/sysimage。
At last, install GRUB manually.
最后,手工安装GRUB。
It is not enough only to install GRUB, we need to prepare a configuration file for it. The configuration file need to be put in /boot/grub, and named grub.conf. This is the grub.conf I used, you can take this as a reference:
GRUB光安装是不够的,还需要给它准备一个配置文件。配置文件需要放在/boot/grub目录下,文件名叫做grub.conf。这是我的grub.conf,可供参考:
default=0
timeout=30
splashimage=(hd0,0)/boot/grub/splash.xpm.gz

title Fedora 7
root (hd0,0)
kernel /boot/vmlinuz-2.6.21-1.3194.fc7 ro root=LABEL=/ rhgb quiet acpi=force
initrd /boot/initrd-2.6.21-1.3194.fc7.img

title Fedora 7 (/dev/sda1)
root (hd0,0)
kernel /boot/vmlinuz-2.6.21-1.3194.fc7 ro root=/dev/sda1 rhgb quiet acpi=force
initrd /boot/initrd-2.6.21-1.3194.fc7.img

title Fedora 7 (verbose)
root (hd0,0)
kernel /boot/vmlinuz-2.6.21-1.3194.fc7 ro root=LABEL=/ vga=773 acpi=force
initrd /boot/initrd-2.6.21-1.3194.fc7.img
Please notice that you would better use "root=LABEL=/", and avoid to use /dev/sda1 or /dev/sdb1 directly.

If your computer is the same as me, has an internal IDE disk and an external USB drive, Fedora 7 will recognize external USB drive as /dev/sda and internal IDE disk as /dev/sdb during boot up time. This is the opposite to what it does in installation time. So if you use "root=/dev/sdb1", you won't be able to boot Linux successfully from USB drive.

"quiet" means less information displayed during booting.

"vga=773" means use display mode of 1024x768 resolution and 256 colors to display information during booting, so approximately 50 rows of text could be displayed per screen. The resolution and color of X Window after booting will not be influenced.
请注意最好用“root=LABEL=/”,而不要直接用/dev/sda1或/dev/sdb1。

如果你的计算机跟我一样,有一个内置IDE硬盘加一个外置USB硬盘,Fedora 7在从USB外置硬盘启动之后,会把外置硬盘作为/dev/sda,而把内置IDE硬盘作为/dev/sdb,这与安装时是完全相反的。所以假如你设置“root=/dev/sdb1”,那么会启动不成功。

“quiet”表示少显示一些启动时的信息。

“vga=773”表示启动时在1024x768分辨率、256色的模式下显示启动信息,这样可以每屏显示50行左右文字。系统进入X Window之后的分辨率和颜色不受这个参数影响。
4. Setup the computer to boot from external USB drive
4. 设置计算机从USB外置硬盘启动
Now most computers can be configured in BIOS to boot from external USB drive. In order to boot successfully, sometimes you need to set "1.1 legacy device support".
大多数的计算机都可以在BIOS中设置从外置的USB硬盘启动。为了正常启动,有时候还需要设置“1.1 legacy device support”。
Some computers give you a chance to enter boot device selection menu when booting. This makes a lot of convenient, you may press the hot key (F8 or F12 for some computers) during booting, and then choose the device you want to boot from.
有的计算机可以让你在启动时按一个热键进入启动选择菜单,这就很方便了,你可以在开计算机的时候按热键(有的是F8,有的是F12),就会看到一个菜单,让你选择从哪里启动。
5. The end
5. 结束语
Okay, that's it. Very simple, isn't it?
好了,就是这样。很简单,对吧?