April 2008 Archives

好久没做编码方面的东西了,今天在 火星 上看到一个挑战,一时兴起就做了一下。原题请看 这里

既然是挑战,我目前的算法对于每个数来说都是常数时间,欢迎大家继续拍砖,我的代码2天后公布(我用的是C语言,大家自便)。

不出所料,在 Richard Stallman 在 OpenBSD 邮件列表中对 OpenBSD 进行 毫无根据指责和攻击 之后,OpenBSD 4.3 以地中海风格的 Home to Hypocrisy 还击了。

这次的主题曲仍然是 Jonathan Lewis 作曲并编曲。很有意思的是本次他们所指出的:

In 1998 when a United Airlines plane was waiting in the queue at Chicago Airport for take-off to New Orleans (where a Usenix conference was taking place), one man stood up from his seat, demanded that they stop waiting in the queue and be permitted to deplane. Even after orders from the crew and a pilot from the cockpit he refused to sit down. The plane exited the queue and returned to the airport gangway. Security personnel ran onto the plane and removed this man, Richard Stallman, from the plane. After Richard was removed from the plane, everyone else stayed onboard and continued their journey to New Orleans. A few OpenBSD developers were on that same plane, seated very closeby, so we have an accurate story of the events.

我完全同意这段话:

This is the man who presumes that he should preach to us about morality, freedom, and what is best for us. He believes it is his God-given role to tell us what is best for us, when he has shown that he takes actions which are not best for everyone. He prefers actions which he thinks are best for him -- and him alone -- and then lies to the public. Richard Stallman is no Spock.
We release our software in ways that are maximally free. We remove all restrictions on use and distribution, but leave a requirement to be known as the authors. We follow a pattern of free source code distribution that started in the mid-1980's in Berkeley, from before Richard Stallman had any powerful influence which he could use so falsely.

另外,正告国内某些Stallman的追随者,这个人号召抵制中国商品。看他的主页吧。

2008硬盘磨损年!

我相信很多人都遇到过硬盘卡壳、掉链子的情况。当然,这篇文档的主旨不是告诉你怎么样可以绕过那些老爷子写的课本上说的金科玉律──重要的数据都应该有备份──如果你的数据最终丢失了,那么我的问题是:你的备份呢?

但是,即使你有经常备份的习惯,有些数据还是会难免出现一些没有及时备份而导致丢失的情况。我的观点是,没有备份计划的数据都不是重要数据,不要等到数据丢失了再去后悔,但是我们显然应该采取各种各样的手段来阻止没有及时备份的那一小部分数据的丢失。

硬盘

大家一起默念:它很便宜!它会坏掉!

是的,实战经验会告诉你,它很便宜!它也会坏掉!不管这个硬盘是来自什么厂商,也不管它是SATA、SCSI、SAS或者是传统的ATA接口,它出现故障只是时间早晚的问题。

为了解决这个问题,人们提出了廉价磁盘冗余阵列(RAID)的概念。例如,使用两块相同容量的磁盘组成 RAID-1 (MIRROR) 阵列,可以在其中任意一块出现问题时,从另一块中取出数据。而如果有至少3块硬盘,便可以组成 RAID-5 (注:还有其他RAID级别可以用3块硬盘组成冗余结构),只损失 1/n 的容量(n为硬盘数量)来得到带冗余的存储,使得存储可靠性得以提高。

除了改善可靠性之外,RAID还可以用来改善读写性能。例如用多块硬盘组成 RAID-0 阵列,可以将读写性能提高 n 倍,等等。我们并不讨论这些RAID级别。

不幸会发生

和很多人已经想到的一样──不要高兴的太早......

带数据冗余的 RAID 的一个基本假设是,磁盘是不骗人的,它有两种状态:好、坏,并且,主机(或RAID控制器)能够可靠地识别这种状态。

很不幸,这句话只对了一半。一块磁盘要么是好的、要么是坏的(这里,"坏的"的定义是读写时会发生任何错误),但是主机未必能够识别这种状态。

更为严重的是,有些时候主机甚至连读出来的数据是否是正确的这件事都不知道!当你发现自己的程序在其它机器上都很正常,但是在某台机器上总是神秘的崩溃的时候,你就要看看是不是那台机器的内存或者其他存储器出现问题了。

祈祷(歌词)

| 1 Comment | No TrackBacks

某竞选广告里面用到的一首老歌。
==========
让我们敲希望的钟啊
多少祈祷在心中
让大家看不到失败
叫成功永远在
让地球忘记了转动啊
四季少了夏秋冬
让宇宙关不了天窗
叫太阳不西沉

让欢喜代替了哀愁啊
微笑不会再害羞
让时光懂得去倒流
叫青春不开溜
让贫穷开始去逃亡啊
快乐健康留四方
让世界找不到黑暗
幸福像花开放

2008硬盘磨损年,你需要这个工具,是的,即使你有备份,只要那备份不是实时的,你还是会需要这个工具。

recoverdisk(1)是FreeBSD 7.0新引入基本系统(/sbin!)的磁盘复制工具,这个工具对于修复硬盘、光盘、存在坏盘上的文件等各种情形都能非常有效地进行迅速修复:它首先尝试以1MB的块尺寸读取和写入数据,随后是64K和512字节(1扇区),遇到错误时会自动跳过,从而最大限度地从损坏的磁盘上恢复数据(如果是用 dd(1) 来恢复数据,通常在遇到坏区时会丢掉整个block,而recoverdisk则是先跳过,然后回过头来用较小的块尺寸重新读取直到失败,而此时主要的数据都已经恢复了)。

Lenovo laptops has bad quality.

这台Thinkpad T61是我这么多年以来用过的唯一一台:
This Thinkpad T61 is the only laptop that I have encountered in my many year usage of laptop computers:

硬盘在机器购买半年之内坏掉两块;
It has hard drive with bad sectors with only half year after purchase;

第一次联系客服,拖了一周寄来一块台式机硬盘;
The first time I have contacted their service representative, they mailed me a hard drive that is used for desktop computers (you know, they ask your computer type number which clearly indicates that it is a laptop), and the drive mailed in after 1 week.

最后一次联系客服,寄来一块硬盘仍然有问题(所以,总计我收到至少3块坏硬盘)
The last time I have contacted their service representative, they have mailed me a hard drive that has read/write issues.

的机器。

离谱也要有点限度吧?
It is ridiculous, yup, it IS ridiculous.

半年前的邮件油价是这样的:

今天,公司门口的 Chevron 的价格牌上终于历史性地出现了 $4.02。

Monthly Archives

Pages

OpenID accepted here Learn more about OpenID
Powered by Movable Type 5.2.3