mount: unknown filesystem type ‘ext2’

今天改了一下 Linux 内核配置,编译好后要 cp 到 /boot 下,因此挂载了 /boot,结果命令提示出错:

# mount /dev/sda1 /boot
mount: unknown filesystem type ‘ext2’


和这位老外朋友遇到的情况一样,直接把文件系统转成 ext3 就可以了:

I usually make my boot partition ext2 because it doesn’t stay mounted and doesn’t get written to unless i’m installing a new kernel or tweaking the options like vga=0×317 or whatever. So having a journal is a waste and it may as well just be ext2. But strangely enough, when I boot, grub sees the boot partition, grub.conf, and the kernel and loads with no problem. But when I try to mount /dev/sda1 from a shell it doesn’t seem to know what i’m talking about! I can mount ext3 and other file systems just fine, but not ext2? I could dig around in the kernel config and figure out what’s missing, but that really didnt matter in this case, so here’s the quick and easy fix with no fishy side effects:

mygentoo ~ # tune2fs -O has_journal /dev/sda1

Now I can mount it from bash just fine… well, that was weird.

— EOF —

xdelta: Windows 下大文件比较(diff/patch)工具

Unix/Linux 系统下的 diff 和 patch 工具真的非常好用!
但是在 Windows 下似乎没有很好的替代工具(装 MinGW 方式除外)。

如果只是比较小文件,其实 Windows 下不缺工具,Beyond Compare、DiffMerge、UltraCompare,Tortoise SVN 也带有一个文件比对工具。
但是如果要对比两个 2G 的文件,90% 的工具都要废了,貌似他们都喜欢把要比对的文件完全加载到内存中,然后做可视化的比对。

最后找到的 xdelta 这个工具可以满足我的要求,项目地址:


E:\soft>xdelta3.0z.x86-32.exe –help
Xdelta version 3.0z, Copyright (C) 2007, 2008, 2009, 2010, Joshua MacDonald
This is free software, and you are welcome to redistribute it
under certain conditions; see “COPYING” for details.
usage: xdelta3 [command/options] [input [output]]
make patch:

xdelta3.exe -e -s old_file new_file delta_file

apply patch:

xdelta3.exe -d -s old_file delta_file decoded_new_file

special command names:
config prints xdelta3 configuration
decode decompress the input
encode compress the input
test run the builtin tests
special commands for VCDIFF inputs:
printdelta print information about the entire delta
printhdr print information about the first window
printhdrs print information about all windows
recode encode with new application/secondary settings
merge merge VCDIFF inputs (see below)
merge patches:

xdelta3 merge -m 1.vcdiff -m 2.vcdiff 3.vcdiff merged.vcdiff

standard options:
-0 .. -9 compression level
-c use stdout
-d decompress
-e compress
-f force (overwrite, ignore trailing garbage)
-h show help
-q be quiet
-v be verbose (max 2)
-V show version
memory options:
-B bytes source window size
-W bytes input window size
-P size compression duplicates window
-I size instruction buffer size (0 = unlimited)
compression options:
-s source source file to copy from (if any)
-S [djw|fgk] enable/disable secondary compression
-N disable small string-matching compression
-D disable external decompression (encode/decode)
-R disable external recompression (decode)
-n disable checksum (encode/decode)
-C soft config (encode, undocumented)
-A [apphead] disable/provide application header (encode)
-J disable output (check/compute only)
-T use alternate code table (test)
-m arguments for “merge”
the XDELTA environment variable may contain extra args:
XDELTA=”-s source-x.y.tar.gz” \
tar –use-compress-program=xdelta3 \
-cf target-x.z.tar.gz.vcdiff target-x.y


— EOF —

Linux 下的多线程下载工具

最先用的是 Axel,功能还可以,不过下载文件最多支持到 2GB,再大的文件就不能下载了,真变态!

接着试用了下 aget,可惜在服务器上不知道什么原因,无法使用!

最后选择用 aria2,很不错,同时支持 HTTP/HTTPS/FTP/BitTorrent。

#aria2c -j10

— EOF —

使用 sendfile() 提升网络文件发送性能

偶见一好文,清楚地阐述了什么是零拷贝(Zero Copy)以及 sendfile 的由来,不复述下实感不快。

read(file, tmp_buf, len);
write(socket, tmp_buf, len);


在用户空间调用 read() 读取文件时发生两次内存拷贝:

  1. DMA引擎将文件读取到内核的文件缓冲区
  2. 调用返回用户空间时将内核的文件缓冲区的数据复制到用户空间的缓冲区

接着调用 write() 把数据写入 socket 时,又发生了两次内存拷贝:

  1. 将用户空间的缓冲区的数据复制到内核的 socket 缓冲区
  2. 将内核 socket 缓冲区的数据复制到网络协议引擎


于是引入了 mmap():
tmp_buf = mmap(file, len);
write(socket, tmp_buf, len);


  1. 调用 mmap() 时会将文件直接读取到内核缓冲区,并把内核缓冲区直接共享到用户空间
  2. 调用 write() 时,直接将内核缓冲区的数据复制到网络协议引擎

这种方式会有个问题,当前进程在调用 write() 时,另一个进程把文件清空了,程序就会报出 SIGBUS 类型错误。

Linux Kernel 2.1 引进了 sendfile(),只需要一个系统调用来实现文件发送。
sendfile(socket, file, len);


  1. 调用 sendfile() 时会直接在内核空间把文件读取到内核的文件缓冲区
  2. 将内核的文件缓冲区的数据复制到内核的 socket 缓冲区中
  3. 将内核的 socket 缓冲区的数据复制到网络协议引擎


Linux Kernel 2.4 改进了 sendfile(),调用接口没有变化:
sendfile(socket, file, len);


  1. 调用 sendfile() 时会直接在内核空间把文件读取到内核的文件缓冲区
  2. 内核的 socket 缓冲区中保存的是当前要发送的数据在内核的文件缓冲区中的位置和偏移量
  3. DMA gather copy 将内核的文件缓冲区的数据复制到网络协议引擎


在许多 http server 中,都引入了 sendfile 的机制,如 nginx、lighttpd 等,它们正是利用 sendfile() 这个特性来实现高性能的文件发送的。

— EOF —

Ubuntu 10.04 LTS 无法添加计算机的问题

今天装了个Ubuntu 10.04 LTS,完全是为了体验传说中的 Ubuntu One……


到第七步时死活找不到 “Add this Computer button” 这个按钮,郁闷了挺久。

还好在他们的 WIKI 中有人提到这个问题:

Monday, May 3, 2010 at 14:32 UTC: Problems adding a computer: Some users have reported problems adding their computers to sync with their Ubuntu One personal cloud. Please review this FAQ item for assistance.

Some users have reported problems with finding the “Add Your Computer” button in this process. We believe this is due to the Ubuntu One Preferences application (step 1) not launching your default web browser (quickly enough… or at all) in order to proceed to step 2. If performing step 1 does not open your web browser (or a new tab if you already have a browser open) within a few seconds, please

  1. close the Ubuntu One Preferences application window (if it’s already open)
  2. open your Terminal (located in Applications >> Accessories)

  3. and type the following:

 u1sdtool -q; killall ubuntuone-login; u1sdtool -c

This should force a web browser to open and put you at step 2 of the process. This is temporary measure so users can get up and running quickly. We will implement a more permanent fix for this problem soon.

明显是这个版本的一个BUG,还好可以用命令行方式补救,期待修复 ……


速度很不理想,继续用我的 dropbox 吧 🙂


Ubuntu One
Ubuntu One

— EOF —