如何增加 kernel 最大允许使用的 loop device 个数

整理下笔记。kernel 默认编译是最大允许 8 个 loop 设备,见到 mount: could not find any free loop device 错误时就该处理了,要么释放一些 mount,要么提高这个上限,方法是(以提高上限到 32 为例)

先修改 /etc/modprobe.conf (2.6 内核),增加

options loop max_loop=32

然后 umount 所有的 loop 设备(用 mount 命令查看),再卸载 loop 模块

rmmod loop

如果发现所有 loop 设备都 umount 了 rmmod 还是报 ERROR: Module loop is in use,使用 losetup

losetup -a                      # 查看 loop 设备使用情况
losetup -d /dev/loop1 # detach 设备(example)

再重新加载 loop 模块检查是否生效

modprobe loop
dmesg | grep loop # 应当能见到 loop: loaded (max 32 devices)

最后建立 loop 设备文件

ls -d /dev/loop*
for ((i=8; i<32; i++)); do
mknod -m0660 /dev/loop$i b 7 $i
chown root.disk /dev/loop$i
done

Mar 9, 2010 at 3:27pm | 0 Comments
Tags: and

gnome-screensaver replacement

My favorite screensaver is "nose man" from href="http://www.tux.org/~bagleyd/xlockmore.html">xlockmore, but
gnome screensaver seems no way to use it. I don't want to spend time
to hack gnome-screensaver's configuration, instead, I found this
alternative screen lock program - xautolock. Xautolock can lock the
screen use any lock program, so it's possible to invoke xlockmore's
binary "xlock" with whatever mode you like.

Xautolock also has a cool feature, it can lock the screen when the
mouse is over a screen corner with a customized delay.

To install:

$ sudo apt-get install xlockmore xautolock

Here are the arguments to call xautolock, logged here to prevent read
the long man page again.

# replace gnome-screensaver, lock screen if idle for 5 minutes, or
# mouse over a corner for 3 seconds
#
msg="All money go my home :-)"
/usr/bin/xautolock \
-corners ++++ -cornerdelay 3 -cornerredelay 30 \
-time 5 -locker "/usr/bin/xlock -mode nose -message '$msg'" &

Put this to /etc/rc.local (for ubuntu), it will be
executed by /etc/rc2.d/S99rc.local on boot up.
Since it's an X11 program, it could be started only after a user logged in
to X. To start it automatically for gnome X manager, use session manager
tool to add an entry is a handy way, "System" -> "Preference" ->
"Sessions".

Also, you can create a shortcut point to command xautolock
-locknow
to lock the screen immediately.

Goodbye, gnome-screensaver.

$ killall gnome-screensaver
$ sudo apt-get remove gnome-screensaver

Apr 15, 2008 at 10:23pm | 1 Comment
Tags: , and

wallop, ies4linux

感谢这位叫嘉佑的朋友赠送的 wallop 邀请,新鲜东西我总愿意尝试一下,呵呵。

炫,真是炫,太炫了。炫得 Linux 上不能用,要求 flashplayer8,貌似 For Linux 的还没有这个版本。

除了炫,我觉得它的 UI 设计不是很舒服,上传照片和音乐的对话框太小,还不能改变大小,还有我找了半天才把头像设上,看其他人的也有不少空着头像的,也没找到?但是导入 feed 作为 blog entry 这个功能很好。

Linux 上可以先 wine 一个 IE 用用看,正好招商银行的信用卡网站也是非 IE 不可,装一个也是用得上的。一 google 发现 ies4linux,非常棒,针对 Ubuntu 的步骤更简单,只要这么几步,绝对傻瓜式安装:

sudo apt-get install wine cabextract
wget http://www.tatanka.com.br/ies4linux/downloads/ies4linux-latest.tar.gz
tar zxvf ies4linux-latest.tar.gz
cd ies4linux-*
./ies4linux

安装脚本写得比较牛逼,还带 ANSI 颜色的,IE 5.5、IE 6、flashplayer 9 可以选择。

一开始是拿普通用户装的,不过我习惯软件装到 /usr/local/ 下,所以又手工把文件移过去了,移完只要把那个 ie6 脚本和桌面图标属性稍微改改就能用了。

现在我也有 wallop 邀请了,数量不多,想看看的可以留言。

Oct 14, 2006 at 8:08pm | 2 Comments
Tags: , and

Ubuntu 上自动 mount NIS 用户的主目录

Ubuntu 6.06 LTS,在 NIS 网络中不能自动 mount 主目录实在不方便,今天读了一下 automount(8),/etc/init.d/autofs 和 /etc/auto.net 终于把它弄出来了。关键是用 program 这种形式来运行 automount,对应 的 program 程序要根据输入的 key 输出它的 mount option,mount point 和 mount entry,在 auto home 的情形下 key 当然应该用用户名。

步骤如下:

先建立一个脚本 /etc/auto.home:

#!/bin/bash

[ -z "$1" ] && exit 1

user=$1
options="-fstype=nfs,hard,intr,nodev,nosuid,nonstrict,async"

info=$(ypcat -k auto.home | grep -w ^$user) || exit 1
# username [options] nfsdir
set -- $info

if [ -n "$3" ]; then
options="$options,$2"
nfsdir="$3"
else
nfsdir="$2"
fi

echo $options / $nfsdir

加上执行权限 chmod +x /etc/auto.home,很重要!

/etc/auto.home user123 测试一下,输出应该类似这样才对:
-fstype=nfs,hard,intr,nodev,nosuid,nonstrict,async / home1.prc:/global/export/home1/user123

然后执行 automount --timeout=30 /home program /etc/auto.home
ls /home/user123 试一下,应该能列出目录,表示工作正常。

杀掉刚才这个进程,在 /etc/auto.mater 中加入一行

/home   /etc/auto.home

然后 /etc/init.d/autofs restart 就 OK 了。

Update on Mar 16, 2007:现在知道了有直接支持这个 NIS 映射自动加载的设置,man auto.master 就有了。只需要先执行 ypcat -k auto.master 得到映射表,如 /home 对应 auto.home,再在 /etc/auto.master 里加上一行 /home yp:auto.home 即可实现 /home 目录的自动加载。另外,上面这个脚本也不是没有用,它是通用办法,可以自己控制自动加载的行为。

Sep 15, 2006 at 12:52am | 0 Comments
Tags: , and

深入分析 Linux 内核链表

深入分析 Linux 内核链表

IBM developerworks 上的文章

Nov 23, 2005 at 1:43am | 0 Comments
Tags: and

 1

Tags

Blogroll

Fairy World | STUPiD | 阅微草堂 | ShelleX | 流浪五天