Archive for the '雕虫小技' Category

用 fuse 安装 ssh file system

Monday, August 4th, 2008

fuse 除了对 ntfs 支持以外,还可以设置用于建立远程 ssh 文件系统,这样的话, mysql 文件系统, http 文件系统都可以如法炮制?

# modprobe fuse

# adduser fuse

# chown root:fuse /dev/fuse

# chmod +x /dev/fusermount

# mkdir ~/remoteserv

# sshfs username@ipaddress:/remotepath ~/remoteserv

test:

user@testserver:~/remoteserv$ ls -l
total 16
drwxr-xr-x 1 951247 155725 4096 2006-16-13 13:03 Music
drwxr-sr-x 1 root root 4096 2006-10-11 06:05 logs
drwx—— 1 951247 155725 4096 2006-02-11 16:19 Documents
drwxrwxr-x 1 951247 155725 4096 2006-10-09 02:43 scripts

wsh 和 批处理的比较

Saturday, August 2nd, 2008
看来 Unix Admin 要回头再看当年 DOS 3.0  时代的批处理了。
TABLE 1: WSH Counterparts to Batch File Commands
Logon
Script Task
Batch File Solution WSH Solution
Determining directory and disk space utilization Resource kit utilities diruse.exe and diskuse.exe VBScript’s FileSystemObject
Performing file I/O Command redirection symbols(e.g., >, >>, <, |) and command filters (e.g., find, more, sort) VBScript’s FileSystemObject
Using environment variables Command processor’s Set command and %EnvironmentVariable% construct WSH Shell object’s Environment property
Handling errors ERRORLEVEL environment variable VBScript’s Err object
Accepting user input Command-line arguments the script accesses via %1, %2, %3, etc. Command-line arguments the script accesses via WScript’s Arguments property, or arguments the user enters interactively and the script accesses via VBScript’s InputBox function
Providing script output Command processor’s Echo command WScript’s Echo method, WSH Shell object’s Popup method, or VBScript’s MsgBox function
Establishing network connections NT’s net.exe commands WSH Network object
Performing Registry I/O Resource kit utility reg.exe WSH Shell object’s RegDelete, RegRead, and RegWrite methods
Running external commands Command or utility name WSH Shell object’s Run method
Searching via regular expressions Command redirection symbols (e.g., <, |) and command filters (e.g., find, findstr) Forthcoming VBScript RegExp object
Manipulating groups and users NT’s net.exe commands and a variety of resource kit and third-party utilities ADSI

rtorrent 键盘命令

Saturday, August 2nd, 2008

^q
Initiate shutdown, press again to force the shutdown and skip sending the stop signal to trackers.

up | down | left | right arrow keys, ^P | ^N | ^B | ^F
Select entries or change windows. The right arrow key or ^F is often used for viewing details about the selected entry, while the left arrow key or ^B often returns to the previous screen.

a | s | d
Increase the upload throttle by 1/5/50 KB.

A | S | D
Increase the download throttle by 1/5/50 KB.

z | x | c
Decrease the upload throttle by 1/5/50 KB.

Z | X | C
Decrease the download throttle by 1/5/50 KB.

Main View Keys
->
View download.

1 - 7
Change view.

^S
Start download.

^D
Stop an active download, or remove a stopped download.

^K
Close a torrent and its files.

^R
Initiate hash check of torrent.

^O
Change the destination directory of the download. The torrent must be closed.

^X
Call commands or change settings.

+ | -
Change the priority of the download.

backspace
Add torrent using an URL or file path. Use tab to view directory content and do auto-complete.

l
View log. Exit by pressing the space-bar.

U
Delete the file the torrent is tied to, and clear the association.

I
Toggle whether torrent ignores ratio settings.

Download View Keys

->
View torrent file list. Use the space-bar to change the file priority and * to change the priority of all files. Use / to collapse the directories. OUTDATED

1 | 2
Adjust max uploads.

3 | 4
Adjust min peers.

5 | 6
Adjust max peers.

u
Display transfering blocks.

i
Display chunk rarity.

o
Display the tracker list. Cycle the trackers in a group with the space-bar.

p
View peer and torrent information.

t | T
Initiate tracker request. Use capital T to force the request, ignoring the “min interval” set by the tracker.

k
Disconnect peer.

*
Choke/Snub peer.

最近几天做的几件“无聊”的事情

Monday, July 14th, 2008

我知道在很多人看来这些事情很“无聊”,所以用了这个标题。

  1. 关掉 FireFox 3.0 的所谓 Awesome Bar ,实际上就是地址栏的自动填充功能。 about:config set browser.urlbar.maxRichResults=0
  2. VirtualBox 1.6.0 挂接 USB IDE 接口移动硬盘成功,安装 RHEL5.0,并把挂接的硬盘格式化为 ext3 文件系统
  3. 用 WinHEX 把笔记本的 C: 盘(30GB) Clone 到这个 40GB 的硬盘。重新启动后,系统在“我的电脑”里,和原来的C: 盘一模一样,磁盘大小都一样。但是在 diskmgmt.msc 下,可以看到克隆盘的真实的空间。
  4. FireFox 关掉网页的自动刷新: accessibility.blockautorefresh=true

MSS 盒子两种 reset 的区别

Sunday, July 13th, 2008

一种是初始化 reset ,固件上的所有信息都丢失,插电源线同时按住 reset ,待风扇停止转动后放开 reset。然后按电源开关,几秒后,会自动关闭,再按一次启动盒子。盒子一般将得到 192.168.1.1 的地址。
另外一种是在线初始化, 在盒子运转过程中,直接按 reset ,盒子会 reboot 。这时,盒子不会丢失 IP 地址,但是盒子的一些信息会丢失,例如设置的名字。

nasload mss_v_2_6_2.bin 以后,盒子需要 DHCP 服务器才能得到 IP 地址。 然后进入 Web 可以升级 mss262_openmss1-rc2.bin。

之后,可以 telnet 上去,安装 dropbear 和 busybox 。

把 MSS 上的 Reiserfs 直接连接到 PC

Sunday, July 13th, 2008

这篇文章讲述的步骤比较完整。要点是:

  1. 用 WinHEX 备份硬盘的第一个扇区。
  2. 模板的 512 个字节覆盖第一个扇区。

Offset      0  1  2  3  4  5  6  7   8  9 10 11 12 13 14 15

00000000   33 C0 8E D0 BC 00 7C FB  50 07 50 1F FC BE 1B 7C   3缼屑.|鸓.P..|
00000016   BF 1B 06 50 57 B9 E5 01  F3 A4 CB BD BE 07 B1 04   ?.PW瑰.螭私??
00000032   38 6E 00 7C 09 75 13 83  C5 10 E2 F4 CD 18 8B F5   8n.|.u.兣.怍?嬽
00000048   83 C6 10 49 74 19 38 2C  74 F6 A0 B5 07 B4 07 8B   兤.It.8,t鰻???
00000064   F0 AC 3C 00 74 FC BB 07  00 B4 0E CD 10 EB F2 88   瓞<.t..??腧?
00000080   4E 10 E8 46 00 73 2A FE  46 10 80 7E 04 0B 74 0B   N.鐵.s*﨔.€~..t.
00000096   80 7E 04 0C 74 05 A0 B6  07 75 D2 80 46 02 06 83   €~..t.牰.u襽F..?
00000112   46 08 06 83 56 0A 00 E8  21 00 73 05 A0 B6 07 EB   F..僔..?.s.牰.?
00000128   BC 81 3E FE 7D 55 AA 74  0B 80 7E 10 00 74 C8 A0   紒>U猼.€~..t葼
00000144   B7 07 EB A9 8B FC 1E 57  8B F5 CB BF 05 00 8A 56   ?氅孅.W嬽丝..奦
00000160   00 B4 08 CD 13 72 23 8A  C1 24 3F 98 8A DE 8A FC   .??r#娏$?槉迠?
00000176   43 F7 E3 8B D1 86 D6 B1  06 D2 EE 42 F7 E2 39 56   C縻嬔喼?翌B麾9V
00000192   0A 77 23 72 05 39 46 08  73 1C B8 01 02 BB 00 7C   .w#r.9F.s.?.?|
00000208   8B 4E 02 8B 56 00 CD 13  73 51 4F 74 4E 32 E4 8A   婲.媀.?sQOtN2鋳
00000224   56 00 CD 13 EB E4 8A 56  00 60 BB AA 55 B4 41 CD   V.?脘奦.`华U碅?
00000240   13 72 36 81 FB 55 AA 75  30 F6 C1 01 74 2B 61 60   .r6侞U猽0隽.t+a`
00000256   6A 00 6A 00 FF 76 0A FF  76 08 6A 00 68 00 7C 6A   j.j.v.v.j.h.|j
00000272   01 6A 10 B4 42 8B F4 CD  13 61 61 73 0E 4F 74 0B   .j.碆嬼?aas.Ot.
00000288   32 E4 8A 56 00 CD 13 EB  D6 61 F9 C3 49 6E 76 61   2鋳V.?胫aInva
00000304   6C 69 64 20 70 61 72 74  69 74 69 6F 6E 20 74 61   lid partition ta
00000320   62 6C 65 00 45 72 72 6F  72 20 6C 6F 61 64 69 6E   ble.Error loadin
00000336   67 20 6F 70 65 72 61 74  69 6E 67 20 73 79 73 74   g operating syst
00000352   65 6D 00 4D 69 73 73 69  6E 67 20 6F 70 65 72 61   em.Missing opera
00000368   74 69 6E 67 20 73 79 73  74 65 6D 00 00 00 00 00   ting system…..
00000384   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00   …………….
00000400   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00   …………….
00000416   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00   …………….
00000432   00 00 00 00 00 2C 44 63  01 00 00 00 00 00 80 01   …..,Dc……€.
00000448   01 00 07 FE FF FF 3F 00  00 00 B1 62 A9 03 00 00   …??…眀?..
00000464   C1 FF 07 FE FF FF F0 62  A9 03 51 E9 8E 36 00 00   ?.?餬?Q閹6..
00000480   00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00   …………….
00000496   00 00 00 00 00 00 00 00  00 00 00 00 00 00 55 AA   …………..U

3. 根据硬盘大小修改分区偏移量和大小。

把从 偏移量 0×207 到 0×204 的数据写到 0×1C6 - 0X1C9 , 0X20F-0×20C 写到 0×1CA-0X1CD
0×217 - 0X214 -> 0X1D6 - 0X1D9, 0×21F - 0X21C -> 0X1DA - 0X1DD

0X227 - 0X224 -> 0X1E6 - 0X1E9, 0X22F - 0X22C -> 0X1EA - 0X1ED
4.用 “rfsgui v2.2″ (freeware) 挂接。

我碰到的问题,在第四步不工作,后来用 WinHEX 的磁盘工具的文件恢复功能,恢复文件。但是中文文件名都变得支离破碎。

OpenMSS 文件系统的限制

Wednesday, July 2nd, 2008

关于这个限制,其实在 OpenMSS 官方网站上的 FAQ 里面已经讲得很清楚:

The MSS uses the Reiser filesystem which supports files larger than 4GB. smbfs does NOT support files larger then 2GB (on the 2.6.2 and open 2.6.2 firmware.) The CIFS filesystem DOES support files larger then 2GB. NFS should support files larger than 4GB (someone please confirm this for both MSS and MSS+)

所以 reiserfs 和 NFS 是支持大于 4GB 的。

抵制 NotePad++

Tuesday, July 1st, 2008

第一次看到一个软件公开的和政治挂钩,反对北京奥运。
http://notepad-plus.sourceforge.net/tw/team.php?lang=tw

反正这软件也没有什么很特色的功能。 卸载了吧。可以用 Vim

添加 OpenMss optware 镜像

Monday, June 30th, 2008

optware 原来的地方位于: Oregon - Eugene - Oregon State System Of Higher Education

服务器信息: Apache/2.2.3 (Ubuntu) DAV/2 SVN/1.4.3 mod_python/3.2.10 Python/2.5.1 PHP/5.2.1 mod_ssl/2.2.3 OpenSSL/0.9.8c

国内直接用盒子下载的速度很慢, 在自己的服务器上做了一个镜像。 (定期更新的脚本还没有完成)

# cat /opt/etc/ipkg.conf
src optware http://download.freelamp.com/openmss/optware
src optware http://ipkg.nslu2-linux.org/feeds/optware/oleg/cross/stable
以后安装软件的话,可以直接通过国内的服务器下载了。

建议安装 bash 和 ntp 。ntp 可以保持盒子的时钟和互联网时钟服务器同步。

再次安装 OpenMSS

Saturday, June 28th, 2008

这么便宜的盒子,可以用于家里的电脑备份,共享数据。索性买了两个。老的 40G 硬盘不行了,买一个 500GB 的硬盘塞入。把安装过程总结一下:

(more…)

系统电源,主板烧坏

Saturday, June 28th, 2008

6/12 新系统托管于同普机房,且不料 6/26 下午2-4点左右,系统熄灭。

第二天上午,得知大概是电源有短路,导致电源烧坏,主板也烧坏。幸亏硬盘完好无损。系统正常启动。

(more…)

用 mss 盒子发送邮件

Saturday, June 28th, 2008

最近整了两个 mss 的盒子,用于家里的电脑备份和共享。想检测自己的网站的健康,需要发送警告邮件。
bash-3.2# echo -e “Alert mail body ” |smtpclient -v -s “Alert mail subject?”  -S mail.freelamp.com -f myemailATfreelamp.com tagetemailAT139.com

开始的时候发现能够顺利发送,感觉不对。 因为这样的话, mail.freelamp.com 就是 Open Relay 了。 后来想到自己家里的系统在使用的时候,自己已经接收过电子邮件,实际上服务器端已经对家里的 IP 认证过了,所以发送没有问题。

重启 WAN 口,得到新的 IP 后,再次运行得到:

SMTPclient: unexpected reply: 553 sorry, that domain isn’t allowed to be relayed thru this MTA (#5.7.1)