Wednesday, May 14, 2008

Slackware RAID HOWTO 指南 (Chinese Translaction)

Slackware RAID HOWTO
Slackware RAID 指南

Version 1.00
2008/04/29

by Amritpal Bath



Contents
目录
===============================================================================

- Introduction
- Warnings
- Planning
- Setup
- Using the generic kernel
- Troubleshooting
- Appendices
- Acknowledgements/References




Introduction
简介
===============================================================================

This document explains how to install Slackware 12.1 (and beyond) on a
software RAID root filesystem. It is meant to cover only software raid.
If you are using a RAID expansion card, or the RAID functionality that came
with your motherboard, this document will not be useful for you.
本文解释了如何在一个基于软件RAID(廉价磁盘冗余阵列)的根文件系统上安装Slackware 12.1。本文只涵盖软件RAID。如果你使用RAID扩展卡,或者你的主板带有RAID功能,本文将不会对你有帮助。

In order to follow this document, your computer must have two or more empty
hard drives. While it is possible to be creative and create RAID arrays on
drives that already contain data, it can be error prone, so it is not
covered in this document.
你的电脑必须有两个以上的空硬盘你才可以跟着本文做。虽然你可以发挥创意,在已经有数据的硬盘上建立RAID阵列,但是这样做容易导致问题,所以本文不包括这方面的内容。


Warnings
警告
===============================================================================

If you perform the following instructions on hard drives with data on them,
YOU WILL LOSE ALL OF YOUR DATA.
如果你在有数据的硬盘上执行以下指令,上边的所有数据将会丢失。

If you wish to perform these operations on hard drives that hold data of
any importance, you MUST BACKUP YOUR DATA. The procedure below will
destroy all of the data on your hard drives, so any important data will
need to be restored from your backups.
如果你要在有重要数据的硬盘上执行以下指令,请先做好备份。下面的步骤会消除硬盘上的所有数据,所以你将需要从你的备份里恢复它们。


One more time: *BACKUP YOUR DATA, OR YOU WILL LOSE IT!*
再一次:备份你的数据,否则你将失去它们。

If you don't backup your data and end up losing it, it will be your fault.
There is nothing I can do to help you in that case.
如果你因为没有备份数据而导致数据丢失,那时你自己的错。我帮不了你。

Now, on with the show... :)
好了,我们开始吧... :)



Planning
计划
===============================================================================

The first step is to determine which RAID level you want to use.
第一步是决定你要哪个RAID级。

It is recommended that you familiarize yourself with basic RAID concepts,
such as the various RAID levels that are available to you. You can read
about these in various places - consult your favorite search engine about
"raid levels", or see the References section.
建议你先搞清楚RAID的基本概念,比如你可以使用的各个RAID级。你可以在很多地方找到这方面的信息 - 用你喜爱的搜索引擎查一查"raid levels"。或者看本文的“参考书目”一节。

Here's a quick summary of the more common RAID levels:
下面是对常见的RAID级的一个简单的总结:

- RAID 0: Requires 2 drives, can use more. Offers no redundancy, but
improves performance by "striping", or interleaving, data between all
drives. This RAID level does not help protect your data at all.
If you lose one drive, all of your data will be lost.

- RAID 0: 需要两个或者更多的设备。不支持冗余,但“striping",或者说interleaving(数据交替储存?),可以提高读写的性能。这个级别不能够保护你的数据。如果一个设备坏了,你所有的(在这个RAID设备上的)数据都会丢失。

- RAID 1: Requires 2 drives, can use more. Offers data redundancy by
mirroring data across all drives. This RAID level is the simplest way
to protect your data, but is not the most space-efficient method. For
example, if you use 3 drives in a RAID 1 array, you gain redundancy, but
you still have only 1 disk's worth of space available for use.
- RAID 1: 需要两个或者更多的设备。使用数据在各个设备上的镜像来提供冗余。这个级别是最简单的一种保护你的数据的方法。

- RAID 5: Requires 3 drives, can use more. Offers data redundancy by
storing parity data on each drive. Exactly one disk's worth of space
will be used to hold parity data, so while this RAID level is heaviest
on the CPU, it is also the most space efficient way of protecting your
data. For example, if you use 5 drives to create a RAID 5 array, you
will only lose 1 disk's worth of space (unlike RAID 1), so you will
end up with 4 disk's worth of space available for use. While simple to
setup, this level is not quite as straightforward as setting up RAID 1.
- RAID 5: 需要三个或者更多的设备。通过在每个设备上储存的奇偶数据来提供冗余。正好整一个设备大小的空间会用来储存奇偶数据,虽然这个RAID级用最多的CPU,但是他也是最有效率利用存储空间的保护数据的方法。比方说,如果你用5个设备来建立一个RAID 5阵列,你只失去了一个设备大小的空间(不像RAID 1),所以你可以有4个设备大小的空间用来存放数据。虽然设置起来简单,但是这个级别不象设置RAID 1那么容易。



Setup
设置
===============================================================================

=== Partition hard drives ===
硬盘分区

Once you have booted the Slackware installer CD, the first step is to
partition the hard drives that will be used in the RAID array(s).
你用Slackware安装光盘引导进系统之后,第一步就是给要在RAID阵列中使用的硬盘分区。

I will assume that your first RAID hard drive is /dev/sda. If it is
/dev/hda or something similar, adjust the following commands appropriately.
我假设你的第一个RAID硬盘是/dev/sda。如果它是/dev/hda或者其他类似的设备,你要对下面的命令作适当的调整。

You can see your drives by running: cat /proc/partitions
你可以运行这个来看你的硬盘:cat /proc/partitions

- /boot: RAID 0 and RAID 5 users will require a separate boot partition, as
the computer's BIOS will not understand striped devices. For
simplicity's sake, we will make /boot a small RAID 1 (mirror) array.
This means that in the case of RAID 0, it will not matter which drive
your BIOS attempts to boot, and in the case of RAID 5, losing one drive
will not result in losing your /boot partition.

- /boot: RAID 0 和 RAID 5 的使用者需要一个独立的引导分区,这是因为电脑的BIOS不能识别数据交替储存的设备。为简单起见,我们把/boot做成一个小的RAID 1阵列。这就是说,在RAID 0下面,你的BIOS可以用(这个RAID 1阵列里的)任何一个设备来引导。在RAID 5 下面,失去一个设备不会导致你失去/boot分区。

I recommend at least 30MB for this partition, to give yourself room to
play with multiple kernels in the future, should the need arise. I tend
to use 100MB, so I can put all sorts of bootable images on the partition,
such as MemTest86, for example.
我建议给这个分区至少30MB,以便让你将来有需要的话可以使用多个内核。我一般会给100MB,这样我可以把各种可引导的(内核)文件如MemTest86放在上面。

Go ahead and create a small boot partition now on /dev/sda, via cfdisk
(or fdisk, if you prefer).
现在在/dev/sda上用cfdisk或者fdisk建一个小的引导分区。

Ensure that the partition type is Linux RAID Autodetect (type FD).
确保分区类型是Linux RAID Autodetect (type FD)。


- /: Every setup will require a root partition. :) You will likely want to
create a partition takes up most of the rest of the drive. Unless you
are using LVM (not covered in this document), remember to save some space
after this partition for your swap partition! (see below)
- /:每个配置多需要一个根分区。:) 你很可能想要然这个分区占掉硬盘上的大部分空间。除非你用LVM(不在本文范围内),否则记得留些空间给交换分区(见下)!

If you are not creating a swap partition, I recommend leaving 100MB of
unused space at the end of the drive. (see "safety" for explanation)
- 如果你不打算建交换分区,我建议在硬盘的末端留100MB空间。(解释见“安全性”一节)。

Go ahead and create your main partition now on /dev/sda, via cfdisk
(or fdisk, if you prefer).
现在在/dev/sda上用cfdisk或者fdisk建你的主分区。

Ensure that the partition type is Linux RAID Autodetect (type FD).
确保分区类型是Linux RAID Autodetect (type FD)。

- swap: Swap space is where Linux stores data when you're running low on
available RAM. For fairly obvious reasons, building this on RAID 0 could
be painful (if that array develops a bad sector, for example), so I tend
to build swap on RAID 1 as well. If you understand the danger and still
want to build swap on RAID 0 to eke out as much performance as possible,
go for it.
- swap: 交换空间是Linux在内存不够的时候存放数据的地方。显而易见的,把它建在RAID 0上可能会很糟糕(比如说,那个阵列出了一个坏扇区),所以我一般也把它建在RAID 1上。如果你明白其中的危险性,但是还是想把它建在RAID 0上以尽可能多的提升性能,也是可以。

For RAID 1 swap, create a partition that is the exact size that you want
your swap space to be (for example, 2GB, if you can't decide).
对于RAID 1 交换分区,你想要多大,就建一个多大的分区。(如果你不能决定,就放2GB)

For RAID 0 swap (not recommended), create a partition that is equivalent
to the swap size you want, divided by the number of drives that will be
in the array.
对于RAID 1 交换分区,建一个大小为你想要的大小除以设备的数目的分区。

For example, 2GB / 3 drives = 683MB swap partition on /dev/sda.
比如说,2GB / 3个硬盘 = 683MB 交换分区 在/dev/sda上。

Ensure that the partition type is Linux RAID Autodetect (type FD).
确保分区类型是Linux RAID Autodetect (type FD)。

I recommend leaving 100MB of unused space at the end of the drive.
(see "safety" for explanation)
我建议在硬盘的末端留100MB空间。(解释见“安全性”一节)。

See also: Appendix A - Striping swap space without RAID 0.
又见:附录A - 不用RAID 0来交替储存交换空间。


- safety! I highly recommend leaving 100MB of unpartitioned space at the
end of each drive that will be used in the RAID array(s).
- 安全性!我极力推荐在每个RAID阵列设备的末端留100MB为分区的空间。

In the event that you need to replace one of the drives in the array,
there is no guarantee that the new drive will be exactly the same size as
the drive that you are replacing. For example, even if both drives are
750GB, they may be different revisions or manufacturers, and thus have a
size difference of some small number of megabytes.
如果你需要更换阵列中的一个设备的话,新的硬盘不一定和原来的正好完全一样大小。比方说,就算两个硬盘都是750GB,它们可能属于不同的版本或者制造商,因此可能会有几兆的差异。

This is, however, enough to throw a wrench in your drive-replacement
plans - you cannot replace a failed RAID drive with one of a smaller size,
for obvious reasons. Having that small 100MB buffer just may save your
bacon.
然而,这足以扰乱你的硬盘更换计划。很显然,你不能用一个小一点的硬盘来换掉坏掉的硬盘。留100MB的缓冲空间可以预防这个问题。



=== Copy and review partitions ===
复制与检查分区

Now that /dev/sda is partitioned as appropriate, copy the partitions to all
the other drives to be used in your RAID arrays.
/dev/sda分好区之后,把它的分区拷贝到RAID阵列里的所有其他硬盘。

An easy way to do this is:
一个简单的方法是:
sfdisk -d /dev/sda | sfdisk /dev/sdb

This will destroy all partitions on /dev/sdb, and replicate /dev/sda's
partition setup onto it.
这会毁掉/dev/sdb里的所有分区,并把/dev/sda的分区复制到/dev/sdb。

After this, your partitions should look something like the following:
这之后,你的分区会大概是下面这个情况:

- RAID 0:
/dev/sda1 30MB /dev/sdb1 30MB
/dev/sda2 100GB /dev/sdb2 100GB
/dev/sda3 2GB /dev/sdb3 2GB

- RAID 1:
/dev/sda1 100GB /dev/sdb1 100GB
/dev/sda2 2GB /dev/sdb2 2GB

- RAID 5:
/dev/sda1 30MB /dev/sdb1 30MB /dev/sdc1 30MB
/dev/sda2 100GB /dev/sdb2 100GB /dev/sdc2 100GB
/dev/sda3 2GB /dev/sdb3 2GB /dev/sdc3 2GB

All partition types should be Linux RAID Autodetect (type fd).
所有分区类型都应该是Linux RAID Autodetect (type FD)。


=== Create RAID arrays ===
建立RAID阵列

Now it's time to create the actual RAID arrays based on the partitions that
were created.
现在是时候在你的分区上建立RAID阵列了。

The parameters for each of these RAID commands specifies, in order:
每个RAID命令的参数依次是:
- the RAID device node to create (--create /dev/mdX)
- 要建立的RAID设备节点 (--create /dev/mdX)
- the RAID level to use for this array (--level X)
- 要使用的RAID级 (--level X)
- how many devices (partitions) to use in the array (--raid-devices X)
- 在这个阵列里有多少个设备(分区)(--raid-devices X)
- the actual list of devices (/dev/sdaX /dev/sdbX /dev/sdcX)
- 实际设备列单 (/dev/sdaX /dev/sdbX /dev/sdcX)

Start by creating the RAID array for your root filesystem.
首先建立根文件系统的RAID阵列。

- RAID 0:
mdadm --create /dev/md0 --level 0 --raid-devices 2 \
/dev/sda2 /dev/sdb2

- RAID 1:
mdadm --create /dev/md0 --level 1 --raid-devices 2 \
/dev/sda1 /dev/sdb1

- RAID 5:
mdadm --create /dev/md0 --level 5 --raid-devices 3 \
/dev/sda2 /dev/sdb2 /dev/sdc2


Next, let's create the array for the swap partition. This will be RAID 1
regardless of which RAID level your root filesystem uses, but given our
partition layouts, each command will still be slightly different.
其次,建立交换分区阵列。不论你的根文件系统用哪个RAID级,这个都是RAID 1。但是因为我们不同的分区分布,每个命令还是会有一点不同。

- RAID 0:
mdadm --create /dev/md1 --level 1 --raid-devices 2 \
/dev/sda3 /dev/sdb3

- RAID 1:
mdadm --create /dev/md1 --level 1 --raid-devices 2 \
/dev/sda2 /dev/sdb2

- RAID 5:
mdadm --create /dev/md1 --level 1 --raid-devices 3 \
/dev/sda3 /dev/sdb3 /dev/sdc3


Finally, RAID 0 and RAID 5 users will need to create their /boot array.
RAID 1 users do not need to do this.
最后,RAID 0 和 RAID 5 用户需要建立/boot 阵列。RAID 1用户不需要。

- RAID 0:
mdadm --create /dev/md2 --level 1 --raid-devices 2 \
/dev/sda1 /dev/sdb1

- RAID 5:
mdadm --create /dev/md2 --level 1 --raid-devices 3 \
/dev/sda1 /dev/sdb1 /dev/sdc1


We're all done creating our arrays! Yay!
所有的阵列都建好了!Yay!


=== Run Slackware setup ===
运行Slackware安装

First, let's format our swap array, so the installer recognizes it:
首先,格式化交换阵列,让安装程序可以识别它。
mkswap /dev/md1

Now run 'setup' as normal.
接下去如常运行'setup'。

When you choose to setup your swap partitions, /dev/md1 will show up.
Continue with this selected.
当你选择设置你的交换分区时,/dev/md1会出现在选项里。选它然后继续。

When asked for the target partition, choose the root array (/dev/md0).
当让你选择目标分区时,选根阵列(/dev/md0)。

You may choose the format method and filesystem of your choice.
你可以选择你要的文件系统和格式化方法。

RAID 0 and RAID 5 users must also setup /boot. When asked about setting up
extra partitions, choose /dev/md2. When asked where to mount this device,
enter "/boot".
RAID 0 和 RAID 5 用户必须设置/boot。当然你设置额外的分区时,选/dev/md2。当问你挂载到哪里时,输入/boot。

After this, continue installation as normal.
之后,照常继续安装。

For LILO configuration:
- When asked about LILO, choose the "simple" setup.
- When asked about additional "append=" parameters, RAID 0 and
RAID 5 users should type in "root=/dev/md0", to ensure that the proper
array is mounted on / at bootup.
- When asked about where to install LILO, choose MBR.
LILO设置:
- 当问你LILO设置时,选“simple”设置。
- 当问你附加的"append="参数时,RAID 0 和 RAID 5 用户要输入"root=/dev/md0" 以确保引导时正确的阵列会被挂载到/上。
- 当问你把LILO安装到哪里时,选MBR。

You may see some warnings scroll by. This is OK.
你可能会看到一些警告信息,那些不碍事。


=== Finishing touches ===
完成安装

After exiting the installer, we have just a few settings to tweak.
推出安装程序后,还有几个设置要“搞”一下。

Start by switching into your actual installation directory:
首先切换进你的系统所安装到的目录。
- chroot /mnt


Let's make sure LILO boots from the RAID arrays properly. Using your
favorite editor (vim/nano/pico), edit /etc/lilo.conf:
确保LILO是从正确的RAID阵列引导的。用你喜欢的编辑器(vim/nano/pico)编辑/etc/lilo.conf:
- add a new line (add it anywhere, but don't indent it):
- 加入一行(随便哪里,但是不要缩进):
raid-extra-boot = mbr-only
- You will need to change the following line:
- 修改这一行:
boot =
RAID 0 and RAID 5 users, change it to:
RAID 0 和 RAID 5 用户改成:
boot = /dev/md2
RAID 1 users, change it to:
RAID 1 用户改成:
boot = /dev/md0

- Save the file and exit your editor.
- 保存文件,推出编辑器。
- run "lilo".
- 运行“lilo”。


When that's done, let's exit the installation and reboot:
完成后,退出安装,重启:
- exit
- reboot

Voila!
完成!



Using the generic kernel
使用generic内核
===============================================================================

The official Slackware recommendation is to switch to the "generic"
Slackware kernel after installation has been completed. If you wish to use
the generic kernel, you must create an initrd. This section gives a quick
example of booting a RAID system in this fashion.
Slackware官方推荐完成安装后换去使用generic内核。如果你想用generic内核的话,就要建立一个initrd。这一节简单讲述如何用这个方法启动一个RAID系统。

If you require more information on initrds, please read /boot/README.initrd.
如果你需要更多关于initrd的信息,请读/boot/README.initrd。

Typically, a user switches to a generic kernel by booting the system, and
afterwards running the following:
一般来说,用户要启动系统并做以下步骤来切换到generic内核:
- cd /boot
- rm vmlinuz System.map config
- ln -s vmlinuz-generic-smp-* vmlinuz
- ln -s System.map-generic-smp-* System.map
- ln -s config-generic-smp-* config

Don't run lilo yet, we'll do that soon.
先不要巡行lilo。我们马上就会做到那一步。

Next, edit (create, if necessary) /etc/mkinitrd.conf and add:
其次,编辑(如有必要,创建)/etc/mkinitrd.conf 并加入:
MODULE_LIST="ext3"
RAID="1"

Obviously, this assumes that you are using the EXT3 filesystem. If you are
using another filesystem, adjust the module appropriately (reiserfs or xfs,
for example). If you wish to read more about the MODULE_LIST variable,
consult "man mkinitrd.conf".
显然,这里假设你用EXT3文件系统。如果你用其他的文件系统,适当修改模块行(比如reiserfs,xfs)。如果你要了解更多关于MODULE_LIST变量,参考"man mkinitrd.conf"。

Note: If the module for your hard drive controller is not compiled into the
generic kernel, you will want to add that module to the MODULE_LIST variable
in mkinitrd.conf. For example, my controller requires the mptspi module, so
my /etc/mkinitrd.conf looks like:
注意:如果你的硬盘控制器的模块没有被编译到generic内核的话,你需要把他加到mkinitrd.conf的MODULE_LIST变量里。比如,我的控制器需要mptspi模块,所以我的/etc/mkinitrd.conf是这样的:
MODULE_LIST="ext3:mptspi"
RAID="1"

We're almost done.
差不多了。

Edit /etc/lilo.conf, and find the line at the very end that says:
编辑/etc/lilo.conf,找到这一行:
image = /boot/vmlinuz

Add a new line after it that says:
在它之后加入这行:
initrd = /boot/initrd.gz

In this case, be sure to indent the line you've added!
这个时候,确保加入的这行有缩进。

Next, create the initrd based on the config file created earlier.
接下去,根据之前建立的配置文件创建initrd。
mkinitrd -F


Finally, run "lilo" to make the new settings take effect, give yourself a
pat on the back, and reboot your finished system. :)
最后,运行“lilo”让新的设置生效。拍拍你自己的背,然后启动完成的系统。



Troubleshooting
故障检查
===============================================================================

Any number of typos can result in a system that does not boot on its own,
but all is not lost. Put the rubber chicken and the lemon away...
无论多少的打字错误都可能导致你的系统不能启动。不过这并不意味着全完了。(下一句不会 :P)

Booting your Slackware media (DVD, for example) can make it very easy to
switch into your installed system and make repairs:
用你的Slackware介质(比如DVD)启动系统。这可以让你非常容易的切换到你安装好的系统来进行修理。

- Boot Slackware CD/DVD.
- 启动Slackware CD/DVD。
- Login to installer as normal.
- 如常登录进安装程序。
- Scan for, and then assemble the RAID arrays:
- 扫描并组装RAID阵列:
mdadm -Es > /etc/mdadm.conf
mdadm -As
- Mount root partition:
- 挂载根分区:
mount /dev/md0 /mnt
- Switch to installed OS:
- 切换到安装好的系统:
chroot /mnt
- Mount remaining filesystems:
- 挂载其他的文件系统:
mount /boot (RAID 0 and RAID 5 users only)
mount /proc
mount sys /sys -t sysfs

At this point, you can bring up your favorite editor, tweak config files,
re-run mkinitrd/lilo/etc as you wish, or anything else you need to do to
make your system bootable again.
到这里,你可以打开你喜欢的编辑器,修改配置文件,重新运行mkinitrd/lilo/等等,或者任何其他让你的系统可以正常引导要做的事情。
When you're finished making your changes, rebooting is simple:
当你做完了改动后,重新启动很简单:
- cd /
- umount boot proc sys
- exit
- reboot

If you are having issues that you're unable to resolve, shoot me an email.
Perhaps the answer will make it into this section. :)
如果你又不能解决的问题,给我发个电邮。也许答案会被加到这一节里。



Appendices
附录
===============================================================================

=== Appendix A: Striping swap space without RAID 0 ===
附录A:不用RAID 0来交替储存交换空间

For completeness' sake, I should mention that swap space can be striped to
improve performance without creating a RAID 0 array.
为了完整性,我应该阐明不需要RAID 0阵列也可以做到交替储存交换空间。

To accomplish this, start by forgetting about any instructions having to do
with /dev/md1, which would be our swap array - create the swap partitions on
the hard drives, but do not create this particular array.
为了做到这点,先不要管关于/dev/md1(我们的交换阵列)的指令 - 在硬盘上建立交换分区,但是不要建立这个阵列。

When creating the swap partitions, ensure that the partition type is set to
Linux Swap (type 82).
当建立交换分区时,确保分区类型是Linux Swap (type 82)。

During setup, the installer will recognize the swap partitions. Ensure that
all of them are selected, and continue as normal.
在安装过程中,安装程序会识别交换分区。确保所有的分区都被选上。如常继续。

After installation is complete, go ahead and boot your system - we can
finish this once the system is booted, in the interest of simplicity.
安装完成后,重启系统 - 重启后我们就可以完成安装了。

When the system boots, edit /etc/fstab with your favorite editor. Find the
lines that describe your swap partitions - they say "swap" in the second
column.
系统启动后,编辑/etc/fstab。找到描述你的交换分区的那些行 - 第二列是"swap"的哪些。

Each of these lines says "default" in the fourth column. Simply change that
to "default,pri=0" for each line.
每一行的第四列都是“default”。把它们都改成“default,pri=0”。

After saving the file, either reboot, or simply run:
保存文件后,要么重启,要么只要运行:
swapoff -a
swapon -a

To confirm that the setting has taken effect, you can run:
可以运行一下来确认设置生效了:
swapon -s

Verify that the Priority column reads 0 for each partition, and we're done!
检查每个分区的Priority列都是0,就完成了!



Acknowledgements/References
感谢/参考书目
===============================================================================

- In depth explanation of RAID levels:
"LasCon Storage - Different types of RAID"
http://www.lascon.co.uk/d008005.htm

- Thanks to John Jenkins (mrgoblin) for some tips in:
"Installing with Raid on Slackware 12.0+"
http://www.userlocal.com/articles/raid1-slackware-12.php

- Thanks to Karl Magnus Kolst?(karlmag) for his original writeup on
Slackware and RAID, ages ago!
"INSTALLING SLACKWARE LINUX version 8.1 WITH ROOT PARTITION ON A SOFTWARE
RAID level 0 DEVICE"
http://www.userlocal.com/articles/raid0-slackware-linux.php

- Of course, thanks to Patrick "The Man" Volkerding for creating Slackware!
http://slackware.com/

- Also thanks to the rest of the guys that proofread, tested, and suggested!
Eric Hameleers (alienBOB), Robby Workman, Alan Hicks,
Piter Punk, Erik Jan Tromp (alphageek)...

- My contact info:
作者联系方法:
Primary email: amrit@slackware.com
Secondary email: amrit@transamrit.net
On certain IRC networks: "amrit" (or some variation :) )

- This latest version of this document can be found at:
最新版本位于:
http://slackware.com/~amrit/
http://transamrit.net/docs/slackware/

Sunday, May 11, 2008

家庭经典语录

今天买了一个机箱风扇,挺酷的,风扇中间还有个防伪三维彩印。一动风扇彩印就会变化。拿风扇去给老婆看,老婆看到就说,好厉害,还会转!我差点晕倒。她赶快澄清她说的是那个彩印。

Friday, May 9, 2008

Slackware 12.0 to 12.1 Upgrade HOWTO Chinese Translation

Slackware 12.0 to 12.1 Upgrade HOWTO
Slackware 12.0 到 12.1 升级指南

This document explains how to upgrade from Slackware 12.0 to Slackware 12.1.
这篇文章是Slackware 12.0 到 12.1的升级说明。
----------------------------------------------------------------------------

For details of important changes from Slackware 12.0 to 12.1, see the file
'CHANGES_AND_HINTS.TXT'. Thanks to Robby Workman for help with this.
关于从Slackware 12.0 到 12.1的重大变化,请参考CHANGES_AND_HINTS.TXT。感谢Robby Workman在这上的帮助。

Before you begin, I would strongly recommend making a backup of your
system, or, if not the entire system, at least the /etc directory. You
might find that you need to refer to a few things after the upgrade
process is complete. Back it up, or take your chances.
开始之前,我强烈建议你备份你的系统。就算不备份整个系统,至少要备份/etc目录。因为升级完成后你可能需要查(目录)里的一些东西。要么备份要么博一下。

OK, now that everything is safely backed up, let's proceed. :-)
好了,如果都备份好了,就开始吧。

To do this, you'll need the Slackware 12.1 packages. If these are on a CD,
create a new directory to mount the CD on so that it doesn't get in the way
during the upgrade:
升级需要Slackware 12.1 的软件包。如果它们在CD上,建一个新目录来挂载CD,以免它们在升级过程中碍事。

mkdir /packages
mount /dev/cdrom /packages

The packages don't have to be on a CD-ROM, as an alternative you could
copy the slackware directory (the one with the various package
subdirectories in it, basically the "slackware" directory from the install
CD) to someplace like /root/slackware/. The important thing is that you
know where the slackware packages directory is. We'll use /root/slackware
in the following examples.
软件包不一定要在CD-ROM上。另一个方法是把slackware目录拷贝到某个地方,比如/root/slackware/。你需要知道软件包的目录在哪里。在以下的例子中我们假设是/root/slackware。

0. Put your machine in single-user mode:
0. 让你的机器进单用户模式:
telinit 1


1. Upgrade your glibc shared libraries. This is important, or things
might go haywire during the first part of the upgrade:
1. 升级glibc共享库。这很重要。不然的话第一部分的升级会搞糟:
upgradepkg /root/slackware/a/glibc-solibs-*.tgz


2. Upgrade your package utilities:
2. 升级软件包管理工具:
upgradepkg /root/slackware/a/pkgtools-*.tgz


3. Upgrade everything else (and install new packages):
3. 升级其他所有的软件包 (包括安装新的软件包):
upgradepkg --install-new /root/slackware/*/*.tgz

If you wish to upgrade everything except for the KDEI language
packs for KDE (these take a lot of space and can be dealt with
after the main upgrade more quickly and easily), running this
script in the "slackware" directory will do the trick:
如果你想要升级除了KDEI语言包(这些会用掉很多空间,而且系统升级完成后升级它们很容易)之外的所有软件包的话,在slackware目录下运行这个脚本:

#!/bin/sh
for dir in a ap d e f k kde l n t tcl x xap y ; do
( cd $dir ; upgradepkg --install-new *.tgz )
done


4. Make sure your system will boot. First, be sure your initrd is up
to date (if you use one). If you use LILO, make sure the paths in
/etc/lilo.conf point to a valid kernel and then type 'lilo' to
reinstall LILO. If you use a USB memory stick to boot, be sure to
copy the new kernel to it in place of the old one.
4. 确保你的系统可以引导进slackware。首先,确定你的initrd是最新的。如果你用LILO, 确保/etc/lilo.conf里的路径都指向有效的内核,然后打'lilo'重新安装LILO到引导区。如果你用USB闪存来引导,一定要把新内核拷贝过去覆盖旧的。

5. Remove obsolete packages. The CHANGES_AND_HINTS.TXT file should have a
list of these. You may also wish to go into /var/log/packages and take
a look at the package list:
5. 卸载已废弃的软件包。CHANGES_AND_HINTS.TXT里有一个列单。你也可以到/var/log/packages看一看:
ls -lt | less

You may spot some old, obsolete, or discontinued packages. If so,
you can remove these using 'removepkg'.
你可能会发现一些旧的,已废弃的,或者已停止支持的软件包。可以用'removepkg'卸载它们。

6. Fix your config files. Some of the config files in /etc are going to
need your attention. You'll find the new incoming config files on
your system with the ".new" extension. You may need to fill these in
with information from your old config files and then move them over.
6. 修正你的配置文件。需要注意/etc目录下的一些配置文件。新安装的配置文件以".new"为扩展名。你需要把旧的配置文件里的东西移到新的里面。

Feel brave? You can use this little script to install all of the
.new config files in /etc. If you've made any local changes you'll
need to add them to the newly installed files. Your old config files
will be copied to *.bak. Anyway, it might be an easier starting
point. Here it is:
如果你勇敢的话,可以用下面这个小脚本安装所有的.new配置文件。如果你以前改过某些配置文件的话,你要在新的配置文件里再做一遍你的改动。旧的配置文件会被备份成.bak扩展名。无论如何,可能这样做来开始比较容易。脚本如下:

#!/bin/sh
cd /etc
find . -name "*.new" | while read configfile ; do
if [ ! "$configfile" = "./rc.d/rc.inet1.conf.new" \
-a ! "$configfile" = "./group.new" \
-a ! "$configfile" = "./passwd.new" \
-a ! "$configfile" = "./shadow.new" ]; then
cp -a $(echo $configfile | rev | cut -f 2- -d . | rev) \
$(echo $configfile | rev | cut -f 2- -d . | rev).bak 2> /dev/null
mv $configfile $(echo $configfile | rev | cut -f 2- -d . | rev)
fi
done


7. If you use a non-en_US language pack for KDE and you already have it
installed, then you may upgrade it by moving into the slackware/kdei
directory and using this command:
7. 如果你已经安装使用了非美国英语的KDE语言包的话,可以进入slackware/kdei目录用下面这个命令升级它:
upgradepkg --install-new k**tgz

To have upgradepkg cycle through all of the available packages, and
see which ones need to be upgraded, use this in slakckare/kdei:
在slackware/kdei里用如下命令来升级所有需要升级的语言包:
upgradepkg *tgz

If your language has been added to KDE since Slackware 12.0, you'll
need to install it using installpkg, or upgradepkg --install-new.
如果你的语言是Slackware 12.0后才加入的。你要用installpkg,或者upgradepkg --install-new来安装它。
Typically you'll need to make sure that you have installed the
slackware/kdei packages for kde, koffice, and k3b (if you use those).
通常你要保证安装了kde, koffice, 和k3b的语言包(如果你有用它们的话)。

8. Return to multi-user mode:
8. 回到多用户模式:
telinit 3


At this point you should be running Slackware 12.1. :-)
到这里有已经在运行Slackware 12.1了 :-)
I wish everyone good luck with this!
我祝愿每个人升级时好运!

---
Patrick Volkerding
volkerdi@slackware.com

Sunday, May 4, 2008

Making initrd for Slackware 12.1 generic-smp kernel

Kernel: 2.6.24.5-smp
Root Device: /dev/md0 (RAID-1)
Root FS: ext3

mkinitrd -c -k 2.6.24.5-smp -m ext3 -f ext3 -R
add "-L" if LVM support is required.

Saturday, May 3, 2008

Extenting a Logical Volume (non-RAID)

Create a new partition. e.g. /dev/sda9. Set the partition type to 8E (Linux LVM)
May need to reboot.
pvcreate /dev/sda9
vgextend datastore_vg0 /dev/sda9
lvextend -L80G /dev/datastore_vg0/download #80G is the target total size, not incremental size
resize_reiserfs -f /dev/datastore_vg0/download

Thursday, May 1, 2008

Buring Files bigger than 4GB to DVD

Update2 (5 May 2009) - The issue below is fixed in k3b 1.63 (r948463) in slackware current and cdrtools-2.01.01a57.

Update - Issue: The DVDs burnt using K3B (and cdrtools) cannot be mounted with appropriate permissions using type udf. The permission is "d---------" when mounted. Mounting as iso9660 gives right permission.

After some trying, I finally managed to burn files bigger than 4GB to DVDs.

Required software:
cdrtools-2.01.01a38-i486-1 or later
k3b-1.0.4-i486-3 or later

From www.k3b.org k3b 1.0.4 Annoucement:
K3b now silently allows the burning of files bigger than 4 GB if an appropriate version of genisoimage or mkisofs is installed ("silently" means that I did not introduce any new messages)

Before start burning DVD, change the Filesystem Settings as follows: (see screenshot below)

- Check "Generate UDF structures"
- Select "Level 3" under "ISO Level"














Note if the settings are not appropriate, k3b will still go ahead to burn the DVD, but happily leave out the file that is more than 4GB and close the DVD, effectively wasting the DVD.