FreeNXでつないだ時にフォントが表示されないものがある


* cairo-1.12.xが原因のようです
* https://wiki.archlinux.org/index.php/FreeNX#Broken_resume_with_Cairo_1.12.x にあるように、 /etc/nxserver/node.confの設定を AGENT_EXTRA_OPTIONS_X="-norender"とすればフォントは表示されるようになりますが、描画がよろしくない状態は変わりません。
* http://arm.konnichi.com/search/index.php?a=64&q=%5Ecairo%24&extra=1&community=1&community-testing=1 から cairo-1.10.2-3-x86_64.pkg.tar.xzを取得し、pacman -U ./cairo-1.10.2-3-x86_64.pkg.tar.xzとしてcairoをダウングレードし、様子を見ることにします
* /etc/pacman.confにIgnorePkg = cairoを設定するのを忘れずに。

HP ML110 G7


* 自宅サーバの後継用にHP ML110 G7が安かったので購入した。NTT-X Storeで10,980円
* Xeon E3-1230と8GB*4メモリ(SMD-32G28ECP-13H-Q)を別途購入して装着。なんの問題もなく認識OK
* Arch Linuxを入れたが、起動途中で画面がBlackoutするので、kernelパラメータにnomodesetを渡してやると良い
* iLO3経由で電源のon/offも問題なく可能であった

grub2とUUID


* 標準だとgrub2はファイルシステムのUUIDを元にどのデバイスかを区別しており、このままだと複製したbackup diskから起動しようとした時にそのUUIDのファイルシステムがのったデバイスがないといってrescue modeに落ちてしまいます。
* そこでUUIDで区別しないようにgrub2を設定してみます
====== grub2からuuidを排除 ======
* /etc/default/grubの#GRUB_DISABLE_LINUX_UUID=trueをコメントアウト
* 以下のパッチを当てる
[root@archlinux-proxmox grub]# diff -ur /usr/share/grub/grub-mkconfig_lib /backup/usr/share/grub/grub-mkconfig_lib
--- /usr/share/grub/grub-mkconfig_lib 2012-08-07 22:24:23.649377433 +0900
+++ /backup/usr/share/grub/grub-mkconfig_lib 2012-08-07 22:24:38.432711843 +0900
@@ -146,20 +146,20 @@
done
fi

- # If there's a filesystem UUID that GRUB is capable of identifying, use it;
- # otherwise set root as per value in device.map.
- fs_hint="`"${grub_probe}" --device "${device}" --target=compatibility_hint`"
- if [ "x$fs_hint" != x ]; then
- echo "set root='$fs_hint'"
- fi
- if fs_uuid="`"${grub_probe}" --device "${device}" --target=fs_uuid 2> /dev/null`" ; then
- hints="`"${grub_probe}" --device "${device}" --target=hints_string 2> /dev/null`" || hints=
- echo "if [ x$feature_platform_search_hint = xy ]; then"
- echo " search --no-floppy --fs-uuid --set=root ${hints} ${fs_uuid}"
- echo "else"
- echo " search --no-floppy --fs-uuid --set=root ${fs_uuid}"
- echo "fi"
- fi
+# # If there's a filesystem UUID that GRUB is capable of identifying, use it;
+# # otherwise set root as per value in device.map.
+# fs_hint="`"${grub_probe}" --device "${device}" --target=compatibility_hint`"
+# if [ "x$fs_hint" != x ]; then
+# echo "set root='$fs_hint'"
+# fi
+# if fs_uuid="`"${grub_probe}" --device "${device}" --target=fs_uuid 2> /dev/null`" ; then
+# hints="`"${grub_probe}" --device "${device}" --target=hints_string 2> /dev/null`" || hints=
+# echo "if [ x$feature_platform_search_hint = xy ]; then"
+# echo " search --no-floppy --fs-uuid --set=root ${hints} ${fs_uuid}"
+# echo "else"
+# echo " search --no-floppy --fs-uuid --set=root ${fs_uuid}"
+# echo "fi"
+# fi
}

grub_get_device_id ()

* grub-install /dev/sda

====== backupディスクにgrubを書き込む ======
* 以下のような状況の場合を説明しています
* mount /dev/sdb3 /backup
* mount /dev/sdb1 /backup/boot
* mount -t proc proc /backup/proc
* mount –bind /dev /backup/dev
* chroot /backup
* grub-install /dev/sdb

====== grub rescueモードでの操作 ======
* ls
* ls (hd0,msdos1)/grub
* set prefix=(hd0,msdos1)/grub
* insmod (hd0,msdos1)/grub/i386-pc/normal.mod
* normal

tcによる内向きトラフィックの制御


* outboundなトラフィックの制御は割と簡単に制御できるんだけど、inboundなトラフィックはingressで書いてやってもなかなか思うような制限値になってくれません。
* そこで、ifb(Intermediate Functional Block device)を使うとよいようです
* eth0に入ってくるトラフィックを50Mbpsに制限するスクリプト
#!/bin/sh
### traffic shape for inbound eth0
## Initialize
tc qdisc del dev eth0 ingress handle ffff: > /dev/null 2>&1
tc qdisc del dev ifb0 root handle 1: htb > /dev/null 2>&1

## ifb setup
modprobe ifb
sleep 2
ip link set dev ifb0 up

## mirror eth0 to ifb0
modprobe act_mirred
sleep 2
tc qdisc add dev eth0 ingress handle ffff:
tc filter add dev eth0 parent ffff: protocol ip u32 match u32 0 0 flowid 1:1 action mirred egress redirect dev ifb0

## traffic shape ifb0
tc qdisc add dev ifb0 root handle 1: htb default 10
tc class add dev ifb0 parent 1:1 classid 1:10 htb rate 50mbit

dd中の進行状況を表示


* ddにUSR1シグナルを送ると進行状況を表示してくれるのはmanに書いてあるのでご存知だと思います。
* それをいちいち手でやるのが面倒なので、スクリプトにしてみました
#!/bin/sh
while :
do
ps axuw| fgrep 'dd if=' | grep -v grep | awk '{print $2}' | xargs -i% sh -c 'kill -USR1 %'
sleep 1
done

ext3のディレクトリエントリの削除


* fs/ext3/namei.c
/*
* ext3_delete_entry deletes a directory entry by merging it with the
* previous entry
*/
static int ext3_delete_entry (handle_t *handle,
struct inode * dir,
struct ext3_dir_entry_2 * de_del,
struct buffer_head * bh)
{
struct ext3_dir_entry_2 * de, * pde;
int i;

i = 0;
pde = NULL;
de = (struct ext3_dir_entry_2 *) bh->b_data;
while (i < bh->b_size) {
if (!ext3_check_dir_entry("ext3_delete_entry", dir, de, bh, i))
return -EIO;
if (de == de_del) {
int err;

BUFFER_TRACE(bh, "get_write_access");
err = ext3_journal_get_write_access(handle, bh);
if (err)
goto journal_error;

if (pde)
pde->rec_len = ext3_rec_len_to_disk(
ext3_rec_len_from_disk(pde->rec_len) +
ext3_rec_len_from_disk(de->rec_len));
else
de->inode = 0;
dir->i_version++;
BUFFER_TRACE(bh, "call ext3_journal_dirty_metadata");
err = ext3_journal_dirty_metadata(handle, bh);
if (err) {
journal_error:
ext3_std_error(dir->i_sb, err);
return err;
}
return 0;
}
i += ext3_rec_len_from_disk(de->rec_len);
pde = de;
de = ext3_next_entry(de);
}
return -ENOENT;
}

ext3のディレクトリエントリ


* ext3のディレクトリエントリの構造
* fs/ext3/ext3.h
/*
* Structure of a directory entry
*/
#define EXT3_NAME_LEN 255

struct ext3_dir_entry {
__le32 inode; /* Inode number */
__le16 rec_len; /* Directory entry length */
__le16 name_len; /* Name length */
char name[EXT3_NAME_LEN]; /* File name */
};

/*
* The new version of the directory entry. Since EXT3 structures are
* stored in intel byte order, and the name_len field could never be
* bigger than 255 chars, it's safe to reclaim the extra byte for the
* file_type field.
*/
struct ext3_dir_entry_2 {
__le32 inode; /* Inode number */
__le16 rec_len; /* Directory entry length */
__u8 name_len; /* Name length */
__u8 file_type;
char name[EXT3_NAME_LEN]; /* File name */
};

/*
* Ext3 directory file types. Only the low 3 bits are used. The
* other bits are reserved for now.
*/
#define EXT3_FT_UNKNOWN 0
#define EXT3_FT_REG_FILE 1
#define EXT3_FT_DIR 2
#define EXT3_FT_CHRDEV 3
#define EXT3_FT_BLKDEV 4
#define EXT3_FT_FIFO 5
#define EXT3_FT_SOCK 6
#define EXT3_FT_SYMLINK 7

#define EXT3_FT_MAX 8

シンボリックリンク


* 60バイト以下のシンボリックリンクはinodeのi_blockに格納され、データブロックを消費しない。そのぶんアクセスも速い。
* fs/ext3/namei.c
if (l > EXT3_N_BLOCKS * 4) {
inode->i_op = &ext3_symlink_inode_operations;
ext3_set_aops(inode);
/*
* We cannot call page_symlink() with transaction started
* because it calls into ext3_write_begin() which acquires page
* lock which ranks below transaction start (and it can also
* wait for journal commit if we are running out of space). So
* we have to stop transaction now and restart it when symlink
* contents is written.
*
* To keep fs consistent in case of crash, we have to put inode
* to orphan list in the mean time.
*/
drop_nlink(inode);
err = ext3_orphan_add(handle, inode);
ext3_journal_stop(handle);
if (err)
goto err_drop_inode;
err = __page_symlink(inode, symname, l, 1);
if (err)
goto err_drop_inode;
/*
* Now inode is being linked into dir (EXT3_DATA_TRANS_BLOCKS
* + EXT3_INDEX_EXTRA_TRANS_BLOCKS), inode is also modified
*/
handle = ext3_journal_start(dir,
EXT3_DATA_TRANS_BLOCKS(dir->i_sb) +
EXT3_INDEX_EXTRA_TRANS_BLOCKS + 1);
if (IS_ERR(handle)) {
err = PTR_ERR(handle);
goto err_drop_inode;
}
set_nlink(inode, 1);
err = ext3_orphan_del(handle, inode);
if (err) {
ext3_journal_stop(handle);
drop_nlink(inode);
goto err_drop_inode;
}
} else {
inode->i_op = &ext3_fast_symlink_inode_operations;
memcpy((char*)&EXT3_I(inode)->i_data,symname,l);
inode->i_size = l-1;
}

synergyでmouseの進む、戻るボタンを有効に


* linux側でsynergyサーバを起動してwindowsを操作していて、mouseについている進む、戻るボタンが効かないのが気になっていました。現在は、synergy.confに下記の設定を追記して操作できるようになりました。

section: options
mousebutton(6) = keystroke(WWWBack)
mousebutton(7) = keystroke(WWWForward)
mousebutton(4) = ;
mousebutton(5) = ;
end