Monday, November 19, 2007

Cygwin 环境下安装 Gtk2

这里的 Gtk2 是指 Perl 的 Gtk2 模块,Cygwin 环境下通过 CPAN 是无法直接安装的,需要修改了 Makefile.PL 之后手动安装。
--- Makefile.PL 2006/11/06 00:35:44 1.1
+++ Makefile.PL 2006/11/06 10:24:38
@@ -331,10 +331,6 @@

# this probably needs to go into ExtUtils::Depends.
sub find_extra_libs {
- # right now we need this terrible hack only for windows.
- # unfortunately, this code doesn't work on cygwin. :-/
- return "" unless $^O eq "MSWin32";
-
# win32 does not allow unresolved symbols in libraries, but
# Gtk2 uses on symbols in the dll created for Glib.
# so, we have to break all this nice abstraction and encapsulation
@@ -346,10 +342,19 @@
my $retstring = "";

use File::Find;
- find (sub {
- $retstring .= " ".$File::Find::name
- if /Glib.lib/i;
- }, @INC);
+
+ if ($^O eq "MSWin32") {
+ find (sub {
+ $retstring .= " ".$File::Find::name
+ if /Glib\.lib/i;
+ }, @INC);
+ } elsif ($^O eq "cygwin") {
+ find (sub {
+ $retstring .= " -L".$File::Find::dir
+ if /libGlib\.dll\.a/i;
+ }, @INC);
+ $retstring .= " -lGlib.dll" if ($retstring ne "");
+ }

return $retstring;
}

这是 Dirk Froemberg 向 Torsten Schoenfeld 提交的 patch,到现在为止还没有被合并进 source。

参考链接:
http://bugzilla.gnome.org

Friday, November 09, 2007

寻找被占用的硬盘空间

收到系统邮件报警,有个分区的空间使用率已经超过90%
[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda7 4.9G 4.3G 267M 94% /
/dev/sda1 99M 17M 77M 18% /boot
/dev/sda2 43G 8.8G 32G 22% /data
none 1.9G 0 1.9G 0% /dev/shm
/dev/sda6 4.9G 43M 4.6G 1% /home
/dev/sda5 4.9G 1.8G 2.8G 39% /usr
/dev/sda3 4.9G 1.5G 3.2G 31% /var

[root@localhost ~]# du -h -x --max-depth=1 /
8.0K /opt
2.0K /boot
5.7M /bin
4.0K /data
0 /proc
144M /lib
8.0K /initrd
11M /etc
8.0K /mnt
0 /sys
8.0K /selinux
2.2M /tmp
42M /root
8.0K /var
8.0K /srv
16K /lost+found
17M /sbin
16K /media
8.0K /usr
0 /dev
8.0K /misc
8.0K /home
4.2G /

[root@localhost ~]# ls -al /
total 174
drwxr-xr-x 24 root root 4096 Aug 16 01:23 .
drwxr-xr-x 24 root root 4096 Aug 16 01:23 ..
-rw-r--r-- 1 root root 0 Aug 16 01:23 .autofsck
drwxr-xr-x 2 root root 4096 Aug 23 04:02 bin
drwxr-xr-x 4 root root 1024 Aug 15 19:12 boot
drwxr-xr-x 5 root root 4096 Sep 20 16:41 data
drwxr-xr-x 9 root root 6540 Aug 16 01:23 dev
drwxr-xr-x 67 root root 4096 Nov 9 14:42 etc
drwxr-xr-x 9 root root 4096 Nov 9 14:42 home
drwxr-xr-x 2 root root 4096 Feb 22 2005 initrd
drwxr-xr-x 12 root root 4096 Oct 26 04:03 lib
drwx------ 2 root root 16384 Aug 16 03:43 lost+found
drwxr-xr-x 4 root root 4096 Aug 16 01:23 media
drwxr-xr-x 2 root root 4096 May 3 2007 misc
drwxr-xr-x 2 root root 4096 Aug 15 18:48 mnt
drwxr-xr-x 2 root root 4096 Sep 20 17:07 opt
dr-xr-xr-x 420 root root 0 Aug 16 10:22 proc
drwxr-x--- 6 root root 4096 Nov 9 14:42 root
drwxr-xr-x 2 root root 12288 Aug 23 04:02 sbin
drwxr-xr-x 2 root root 4096 Aug 15 18:43 selinux
drwxr-xr-x 2 root root 4096 Feb 22 2005 srv
drwxr-xr-x 9 root root 0 Aug 16 10:22 sys
drwxrwxrwt 4 root root 4096 Nov 9 22:36 tmp
drwxr-xr-x 16 root root 4096 Aug 15 18:45 usr
drwxr-xr-x 22 root root 4096 Aug 21 16:32 var

找来找去,找不到吃掉空间的文件,还是经过好友指点,学到了这个命令:
[root@localhost~]# lsof | grep deleted
logswatch 14767 zimbra 1w REG 8,7 1830440 384006 /tmp/logswatch.out (deleted)
logswatch 14767 zimbra 2w REG 8,7 1830440 384006 /tmp/logswatch.out (deleted)
......

意为列出已被删除,但仍被进程占用中的文件。然后就是处理(杀掉?)掉相关进程,释放文件,空间就回来了。