安装linux(7)

--- (文/曾瑞源)

LILO

Welcome to the Slackware Linux 2.0.2 Bootkernel disk!

If you have any extra parameters to pass to the kernel, enter them at the
prompt below. For instance, you might need something like this to detect the
hard drive on PS/1 and ValuePoint models from IBM:

ramdisk hd=cyl,hds,secs (Where "cyl", "hds", and "secs" are the number of
cylinders, sectors, and heads on the drive. Most
machine won't need this.)

Also, in a pinch, you can boot your system with a command like:
mount root=/dev/hda1

On machines with low memory, you can mount root=/dev/fd1 or
mount root=/dev/fd0 to install without a ramdisk. See LOWMEM.TXT for details.

If you wold rather load the root/install disk from your second floppy drive:
drive2 (or even this: ramdisk root=/dev/hd1)

DON'T SWITCH ANY DISKS YET! This prompt is just for entering extra paramters.
If you don't need to enter any paramters, hit ENTER to conitnue.

boot: mount root=/dev/hda1

把上面 /dev/hda1 换成您实际的情况就可以。

Slackware Linux bootdisk/rootdisk 组合也可以作为系统急救
磁片, 比方说您不小心修改 /etc/fstab 档案, 但却由於有错误造成
无法开机, 类似这种例子, 您就可以用 bootdisk 磁片开机, 之後换
插入 rootdisk磁片, 继续执行开机作业, 我们前面提很多次, 这样子
执行的就是一套阳春的 Linux作业系统, 但虽然阳春, 基本的系统工
具程式都有, 比方说 vi 文字编辑器。

由这软碟系统来修复硬碟内的 Linux档案系统的作法, 是先把硬
碟内的 Linux / (root) 档案系统挂上来, 之後用 vi 修改造成错误
的设定档案, 或者用 e2fsck 或 fsck 来修复硬碟内的档案系统结构
(就类似 DOS的 CHKDSK指令)。

$ mount -t ext2 /dev/hda2 /mnt

笔者发现 Slackware Linux 2.02 以後的 rootdisk 磁片里面已
经没有 vi 及 e2fsck 等工具, 假如您想使用 vi 的话, 可以试看看
/mnt/usr/bin/vi。


□ 如何自制 bootdisk

有些朋友会碰到 bootdisk 磁片开机後, 无法认为电脑硬体设备,
举个例子来说, 比方您电脑配备有一个非常特别品牌的硬碟控制卡,
而所以现有 Slackware Linux 的众多 bootdisk 都没有 driver, 而
您又确定知道新版的 Linux Kernel source 里面有 driver。 您有
这情况时, 可以请别人帮忙, 在别一部 Linux 机器上编译该份 Kernel
核心程式码, 之後根据该份核心码制作一张您自己的 bootdisk。 细
节如下:

1A. cd /usr/src/linux 编译系统核心
(请参考拙著『轻轻松松管理 Linux/Unix』
1B. 插入一张格式化过的磁片
2. mount /dev/fd0 /mnt
3. cat zImage > /mnt/vmlinuz
4 rdev -R /mnt/vmlinuz 0
5. rdev /mnt/vmlinuz /dev/fd0H1440
6 rdev -r /mnt/vmlinuz 1440
7. lilo -r /mnt
8. umount /mnt
9. 完成, 取出您的磁片

□ pkgtool 软体维护

有时候, 您因为任何原因, 需要增减系统内的应用软体, 有这情
况时您就必须借助 pkgtool 的帮忙。 比方说, 您想把某一个不常使
用的软体拿掉, 因为它占用非常大的硬碟空间, 或者比方说, 一开始
时, 您只安装了最基本的A 与 AP系列软体, 您後来想要加装剩下一系
列的软体, 这时您就可以使用 pkgtool 程式来达成。

pkgtool 的使用场合主要是在安装完成後的系统之下, 而不是
bootdisk/rootdisk 所执行的安装过程中。

pkgtool 的使用法非常简单, 这部份笔者在这『轻轻松松管理
Linux/Unix』 这本书也有提到。 大体而言, 您只需要下 pkgtool
这指令, 就可以直接在萤幕画面上得知操作的细节, 应该非常容易。


□ 手工建置档案系统

在第四章中, 我们提到, 执行作业系统的安装过程中, 必然要经
过一道「建置档案系统」的程序 (DOS用 FORMAT, Linux用 mke2fs),
这道程序是用来把已经完成规划的分割区, 进一步赋予其档案系统属
性。

可惜前面的介绍中, 由於 setup 自动的进行这道步骤, 所以我们
没有认识到如何收工来做这样工作, 这一节就要补充这个不足。

作法上, 通常我们必须先规划出一个新个分割区 (或者说已经规
划好了), 我们接著要想办法知道要所执行档案系统建置的分割区其实
际的大小 (Bloack数目), 以下例子是用 fdisk 来取得数据。


# fdisk /dev/hdb

Command (m for help): p

Disk /dev/hdb: 16 heads, 63 sectors, 826 cylinders
Units = cylinders of 1008 * 512 bytes

Device Boot Begin Start End Blocks Id System
/dev/hdb1 1 1 100 50368+ 83 Linux native
/dev/hdb2 101 101 405 153720 7 OS/2 HPFS
/dev/hdb3 536 536 736 101304 83 Linux native
/dev/hdb4 * 406 406 535 65520 a5 BSD/386

Command (m for help): q


假如我们的目的分割区为 /dev/hdb3, 这时我们看其对应那一行,
得到一个数据 101304 Bloacks, 根据这数据, 我们执行以下指令:

$ mke2fs -c /dev/hdb3 101304

我们就简单介绍如此, 想深入认识的朋友, 可以用 man mke2fs
指令来查询线上使用手册。



□ 您需要虚拟记忆体吗?

在前面第四章中, 我们介绍到很多地方提起「虚拟记忆体」, 您
心理会不会问说, 「我真的需要设计虚拟记忆体吗」?

这问题牵涉到一个实际的问题, 就是您现有的记忆体够大吗? 大
凡实际的记忆体不够时, Linux 便有可能开始用到虚拟记忆体, 假如
这时候连虚拟记忆体也用光了, 系统便会有类似当机的反应 (多半不
会真正当机), 至少正执行中的应用软体因此原因当掉的可能非常大。

照笔者经验, 我通常会规划一个 Swap Partition 的虚拟记忆体,
而其大小不小於实际虚拟记忆体之大小, 以这样的情况观察系统的运
转, 尤其是记忆体消耗的情况, 若发觉有需要, 可以再设立第二个
Swap Partition, 若没有办法增加 Swap Partition, 可以用 Swap
File, 不过 Swap File 效率上比 Swap Partition 低。

最後提醒读者一个观念, 假如系统经常性的使用掉大量的虚拟记
忆体, 这时您或许就该考虑扩充实际的记忆体了, 假如您希望系统运
转的效率处在最佳状态的话。 对於把 Linux使用在有严肃生产力场合
的读者朋友来说, 尤其要注意这一点。


□ 手工建造 Swap Partition

手工建造一个 Swap Partition 作为虚拟记忆体, 操作上非常简
单, 我们同样是用 fdisk 规划出一个新的分割区 (假设硬碟内仍未
满), 同时把该分割区的型别改别 Swap Partition, 之後我们用 mkswap
指令赋予其档案系统属性, 最後, 用 swapon 指令启动使用就可以。
一共三道步骤。

以下我们就来看一下实际操作系□例。

步骤一.

/# fdisk /dev/hda ← 在Shell提示符号後键入fdisk指令

Command (m for help): p ← 我先来看看目前的设定情况

Disk /dev/hda: 15 heads, 17 sectors, 1001 cylinders
Units = cylinders of 255 * 512 bytes

Device Boot Begin Start End Blocks Id System
/dev/hda1 * 1 1 161 20519 4 DOS 16-bit <32M
/dev/hda2 302 302 1001 89250 81 Linux/MINIX
/dev/hda3 260 260 301 5355 81 Linux/MINIX

Command (m for help): n ← 增加一个Partition
Command action
e extended
p primary partition (1-4)
p ← 指定Primary
Partition number (1-4): 4 ← 指定第四个分割区 (前三个已经满了)
First cylinder (162-1001): 162 ← 回答162 (162为系统自动侦测得知)

Last cylinder or +size or +sizeM or +sizeK (162-259): 259 ←
259也是系统自动侦测, 这两个数据, 您依照自己情况调整
Command (m for help): t ← t 变更分割区的 ID

Partition number (1-4): 4 ← 第4个分割区 (您依照情况调整)

Hex code (type L to list codes): 82 ← 82代表Swap Partition
Changed system type of partition 4 to 82 (Linux swap)

Command (m for help): p ← 设定完毕, 我们先瞧一瞧

Disk /dev/hda: 15 heads, 17 sectors, 1001 cylinders
Units = cylinders of 255 * 512 bytes

Device Boot Begin Start End Blocks Id System
/dev/hda1 * 1 1 161 20519 4 DOS 16-bit <32M
/dev/hda2 302 302 1001 89250 81 Linux/MINIX
/dev/hda3 260 260 301 5355 81 Linux/MINIX
/dev/hda4 162 162 259 12495 82 Linux swap

果然新造一个/dev/hda4 partition, 且指定为Linux Swap

Command (m for help): w ← 无误後, 将以上设定存起来
The partition table has been altered.
Please reboot before doing anything else.

步骤二.
执行步骤一後, 重新开机, 接著执行步骤二及步骤三。


$ mkswap -c /dev/hda4 12495 ← 这里 /dev/hda4为刚设定的Swap
Partition, 12495为该分割区的大小
Setting up swapspace, size = 12787712 bytes

步骤三.

$ /sbin/swapon /dev/hda4


假如您是临时需要扩充虚拟记忆体, 上面这三道步骤已经足够了
。但假如您想让系统在每次开机後都自动取用这些虚拟记忆体, 这时
您就要有额外的设定, 否则每次您都要重复执行步骤三, 系统才知道
如何取用该分割区。

要设定这分割区为固定系统的虚拟记忆体很简单, 方发之一, 就
是把 /sbin/swapon /dev/hda4 指令加入 /etc/rc.d/rc.local 档案
内, 或者另外的方法, 在 /etc/fstab档案内加入

/dev/hda4 none swap

一行就可以。 同样的, 假如您的分割区不是/dev/hda4的话, 请更改
这数据以符合您的情况。

您可以用vi 来编辑/dev/fstab档案以便加入这一行, 下图就是笔者
/dev/fstab档案的内容。


/dev/hda2 / ext2 defaults
/dev/hda4 swap swap defaults ← 加入这一行
none /proc proc defaults


或者您可以使用下列指令(这适合不懂vi的读者们)。

$ cd /etc
$ cp fstab fstab.backup ← 先备份, 以免万一失手
$ echo "/dev/hda4 swap swap defaults" >> fstab

$ /sbin/swapon -a ← 使生效, 而无须重新开机

经过这一额外的动作後, 我以後每次的开机, 系统都会自动把这一
个12MB大的Swap Partition 扩充加入原来的记忆体。为确定这设定是
否生效, 您重新开机, 并观察在开机的时候, 是否有下面这一段讯息,

adding Swap: 12488k swap-space

有的话, 事情就妥当了。



□ 手工建造 Swap File


至於设置Swap File与设置Swap Partition道理也很类似, 我们来看
下面步骤。

1. 执行dd 以建置一个Swap File (此例为/SWAPFILE, 名字可以自取)
2. 执行″mkswap swap-file block-size″
3. 执行″swapon swap-file″

在步骤一, 我设定8 MB(8196) 的Swap File, 该Swap File取名为
SWAPFILE, 该档案位於第二个Partition (/dev/hda2)的″/″目录下。
这档名您可自取, 所在位置也随您喜好。

步骤一
$ dd if=/dev/hda2 of=/SWAPFILE bs=1024 count=8192
8192+0 records in
8192+0 records out


步骤二
$ mkswap /SWAPFILE 8192
Setting up swapspace, size = 8384512 bytes



步骤三
$ /sbin/swapon /SWAPFILE
Adding Swap: 8188k swap-space

经过这三道步骤後, 这一个Swap File已经暂时成为您系统记忆体
的一部份了, 不过一旦您关机, 这一个Swap File就又失效了。於是我
们便又想到, 如何永久取用该Swap File?

很简单, 您可以用″vi″编辑/etc/rc档案, 加入″/sbin/swapon
/SWAPFILE″一行。或者, 底下用更简单的示□, 让不懂vi的朋友参考
。下面指令中, /SWAPFILE是您之前取的档名, /sbin/swapon是启动指
令。


$ cp /etc/rc.d/rc.local /etc/rc.d/rc.local.old ← 备份, 以免万一失手
$ echo "/sbin/swapon /SWAPFILE" >> /etc/rc.d/rc.local

或者假如您不喜欢上面步骤三的方法, 也可以这样做:


$ cd /etc
$ cp fstab fstab.backup ← 先备份, 以免万一失手
$ echo "/SWAPFILE swap swap defaults" >> fstab

$ /sbin/swapon -a ← 使生效, 而无须重新开机


□ 手工设定 LILO

LILO 是 Slackware Linux 内建开机选择程式, 它可以用来启动
Linux, 也可以用来启动硬碟内的任何一个作业系统。 在笔者看来,
LILO 拥有是简单好用、强悍、且安全的特色, 非常值得推荐, 最重
要的, 您安装好 Slackware Linux後, 它就在那里。

比较详细的 LILO 介绍, 请参考『轻轻松松管理 Linux/Unix』,
这里, 笔者只稍微介绍而已, 补充一一些 setup 自动安装程式所没
有介绍的。

boot = /dev/fd0 # 这行用在软碟开机 启动场合
# boot = /dev/hda # 这行用在硬碟 MBR 启动 启动场合
# boot = /dev/hda2 # 这行用在硬碟 superblock 启动场合
install = /boot/boot.b
delay = 50
#
image = /vmlinuz # 启动 Linux
label = linux
root = /dev/hda1
vga=normal
other = /dev/hda3 # 启动 DOS
label = dos
table = /dev/hda

当 /etc/lilo.conf 如上示□设定完成後, 摆一张格式话过的磁
片在第一个软碟机内, 执行 lilo 指令即可。 这张词篇就可以用来
开机。



□ 如何解除LILO自动开机程序
本书作者其实最推荐把 LILO 安装在软碟上面, 也就是说尽量由
软碟开机, 而不去动到硬碟的 MBR, 这样子, 假若以後不跑 Linux了,
MBR 里面也不会残留著 LILO, 您也就不需要阅读本节的介绍。

假如您已经把 LILO 安装在硬碟 MBR, 因为任何理由您想把 MBR
清理乾净, 在以後用硬碟开机时不想再看到 LILO 字眼, 一般的作法
很简单, 拿一片 DOS 开机片, 先确定该磁片内附有 FDISK.EXE 工具
程式。 用该 DOS 磁片启动电脑, 之後执行 A:/> FDISK /mbr 指令
即可。


Slackware FAQ, last revised: 5 November 1994

These are questions people ask me quite often. Hopefully now that they're
answered here that won't be the case. :^)

-----

Q: When I installed Slackware, the system could see my CD-ROM just fine. But,
when I try to boot using LILO or the bootdisk the system doesn't find the
CD-ROM drive anymore! How can I fix this?

A: The problem is probably that you used a bootkernel disk with support for your
CD-ROM drive, but didn't install a kernel with support. If you have a
non-SCSI CD-ROM drive, or a SCSI CD-ROM drive on a controller with alpha
(experimental) support, then you may need to use a kernel from the Q disk
series that contains the proper support.

You can use the same bootkernel disk you installed the system with to get
into your machine. Use a command like this on the LILO prompt, but replace
the root device name with the one you used on your machine:

mount root=/dev/hda

Once you're logged in, you need to install a new kernel. Use pkgtool or
installpkg to install it:

cd /cdrom/slakware/q4 (or possibly another directory with kernel packages)
installpkg mitsumi.tgz (this one has Mitsumi CD support)

You'll need to install LILO, build a bootdisk, or have Loadlin boot the new
kernel before it will work. See the question below about "I just built a
new kernel..." (The kernel packages install the kernel as /vmlinuz, not
zImage, so use /vmlinuz wherever the answer mentions zImage.)

NOTE: for the best possible results, you need to compile a kernel that only
contains drivers for the hardware you have. If you're ready to tackle that
task, zless /usr/doc/faq/howto/Kernel-HOWTO.gz on your installed system.

-----

Q: I got a PROBLEM_WITH_INEWS_DOMAIN_FILE!

A: Then set your hostname in /etc/NNTP_INEWS_DOMAIN.

-----

Q: Why do I get "network unreachable" under Slackware?

A: There are a couple of possibilities. For most users, things work right out
of the box. However, if you're running into this problem here are two
workarounds you can try:

1. Reverse the broadcast and netmask arguments (and their variables)
in the call to ifconfig in /etc/rc.d/rc.inet1. Make sure you are
not trying to route your own IP address - you shouldn't have to.

2. Make sure /etc/networks is properly configured.

3. You may want to try the 'netconfig' script (in the package netcfg.tgz).
It's not perfect, but does a pretty good job.

4. Make sure the kernel you're using supports your hardware. Most of the
kernels provided with Slackware include a /boot/config.in file where you
can look up the compilation options.

-----

Q: Why the $%#@! isn't my UltraStor SCSI detected? It works under DOS!

A: Set the I/O address to 0x340 instead to 0x330.

For any hardware that doesn't work, a good rule is to try playing around
with the IRQ and I/O settings on it to see what happens. If your system
is up and running and you're having problems with a CD-ROM or tape or
something like this, you can always look around for the driver source in
/usr/src/linux/drivers... really, it won't bite! Often, the source
contains important documentation, such as the default IRQ settings for
that type of device, and the major number for the entry in /dev. Also,
try other bootkernels and see if that helps.

-----

Q: My large (> 1/2 gig) IDE drive reports more than 16 heads, and as a
result Linux won't install on it. What can I do?

A: See the file EIDE.TXT for instructions on how to make it work. (Thanks to
Bob DiMarco for forwarding this to me, and Patrick LoPresti for compiling
the information in the first place)

Note that newer kernels (> 1.1.40) will do this translation for you
automatically, and thus make the workaround unnecessary. Once these new
kernels make it into the Q series, you should probably use one of them if
you have an EIDE drive and want to avoid the whole problem.

-----

Q: How do I make a Slackware bootkernel disk with this new kernel I made?

A: OK, well you grab an existing one like the "bare.gz", put it on a floppy,
and do this:

mount /dev/fd0 /mnt (this mounts it)
cat zImage > /mnt/vmlinuz (put the new kernel in place)
rdev -R /mnt/vmlinuz 0 (mount read-write)
rdev /mnt/vmlinuz /dev/fd0H1440 (use that drive, or /dev/fd0h1200)
rdev -r /mnt/vmlinuz 1440 (set the ramdisk size, or use 1200 with 1.2 meg)
lilo -r /mnt (reinstall lilo)
umount /mnt (that's it! you're done! :^)

If you want it to stop and give the message to switch disks, you'll need the
ramdisk.c patch in /pub/linux/slackware/kernels on ftp.cdrom.com. I have no
idea if this will still patch into the newest kernels. Otherwise, you don't
really need it if you're brave enough to just switch the new disk in as soon
as you see the "Uncompressing Linux..." message. It's always worked for me.

-----

Q: I just built a new kernel. Now how to I go about replacing my existing
kernel with this new zImage file?

A: First, you must prepare the new kernel. If you're using UMSDOS, you'll want
your system to boot read-write. Otherwise, you'll want it to boot read-only
so your filesystems can be safely checked. So, do this:

For UMSDOS:
rdev -R zImage 0
For any other filesystem type:
rdev -R zImage 1

Then, you'll need to set the root partition. For example, if your root
Linux partition is /dev/hda2, you'd do this:

rdev zImage /dev/hda2

Then, you can set a video mode if you like. As an example, this sets normal
80x25 console mode:

rdev -v zImage -1

Other modes include: -3 = Prompt, -2 = Extended VGA. You might need to
remove a line in your /etc/lilo.conf that forces normal video if you use
LILO and wish to try an extended video mode.

Next, you need to install the kernel. If you boot from a floppy disk, you
can simply stick a formatted floppy into your drive and write the zImage
to it like this:

cat zImage > /dev/fd0

If you use lilo, you should copy the zImage to where your lilo.conf expects
it to be and then reinstall lilo. This should work if you used Slackware's
liloconfig script to set up LILO. (this is the script setup uses)

cp zImage /vmlinuz ; lilo

You may wish to back up your existing /vmlinuz first.

If you use Loadlin, copy the kernel to your DOS partition where Loadlin can
see it (if you use UMSDOS, you won't need to do this). Then, start Linux
from DOS like this:

c:\loadlin\loadlin.exe c:\linux\vmlinuz root=/dev/hda2

That should do it.

-----

Q: Why can't I cut and paste from elvis (vi) in an xterm?

A: Later versions of elvis use the mouse for cursor positioning instead. If
you want to cut and paste, hold the left shift key down while you use the
mouse.

-----

Q: Why doesn't my bus mouse work? The kernel, selection, the
X server and test-mouse all say "no such device."

A: The kernels distributed with Slackware don't have the drivers for
busmice compiled in. Last time I tried to include all of them there
were horrible driver conflicts -- better to leave them out if they
can't coexist. Obviously, it's not feasible for me to provide
versions of every precompiled kernel for each type of busmouse. I
only have a 386. ;^)

The solution is to get the kernel sources, configure the kernel to
support the your type of mouse and no other mouse devices, and rebuild
it. Documentation on how to do this is included in the kernel
source, i.e. the kernel.tgz package found in the D series. You will
also need at least the gcc.tgz, include.tgz, libc.tgz, and binutils.tgz
packages from the D series to rebuild the kernel.

-----

Q: I see my SoundBlaster/Panasonic CD-ROM detected at boot, but I can't
install from it or mount it. What's going on?

A. Try setting to drive's ID to 0. This is expected by the install disks.
There should be a jumper on the back of the drive that selects this --
just move it to the leftmost position.

-----

Q: I'm using UMSDOS and would like to use the same swapspace under Windows
and Linux. Can this be done?

A: If you want to share a Linux-UMSDOS swapfile with MS-Windows, you can
do the following:

1. Create PERMANENT(!) swap file in MS-Windows with size NNNN kbytes.
2. In /etc/rc.d/rc.local add the following lines:

rm -f /DOS/windows/spart.par <--- Needed in order to suppress
Windows complain on next start!
mkswap /DOS/386spart.par NNNN
sync
swapon /DOS/386spart.par

3.In /etc/rc.d/rc.0 add "swapoff" for this file.

-----

Q: What's the password for root on the install disk?

A: There isn't one. If you're asked for one, it usually means that you
don't have enough memory to install.

To help work around this, look in your CMOS settings and make sure you don't
have any ROM shadowing enabled. ROM shadowing wastes memory and won't
improve the performance of Linux. Also, make sure you're using the smallest
bootkernel disk you can. For example, you don't need to use "scsinet" if
you're not installing to a SCSI drive via NFS. Use something small -- the
"bare" disk if you can get away with it. Some people mistakenly think they
need to use a bootkernel disk with network drivers if they plan to use
networking after installation. Not so! The drivers on the bootkernel disk
have no impact on what you can use *after* installation -- in almost all
cases you won't be running the same kernel on your installed system as
you used to install it.

-----

Q: How can I install and remove software now that the Slackware Linux
distribution is installed on my machine?

A: To remove packages, type "pkgtool" and follow the prompts. Pkgtool will
also allow you to add packages that are in the current directory.

The preferred way to install software is with the "setup" script.
When you do your initial installation, setup puts a copy of itself in your
/sbin for future use. You can also add software to your machine using the
boot/install disk, if you really want to.

When adding software to a running system via NFS, it is preferable to
mount the partition yourself and then use the 'install from a mounted
directory' feature of setup.

There are also command line utilities that allow you to create, install,
and remove packages. For these, you should refer to the manpages:
installpkg(8), removepkg(8), makepkg(8), explodepkg(8). A simple example
of how you would install a package with installpkg:

installpkg package.tgz