2009年12月28日月曜日

Firefoxのキャッシュをtmpfsへ

How to: Reduce Disk Writes to Prolong the Life of your Flash Drive
にならい、firefoxのキャッシュを/tmpに移動する。

/etc/fstabを修正して、既に/tmpをtmpfsで作ってあるので、
firefoxの設定でキャッシュの位置を/tmpに指定するのみ。
上記リンクから引用
Launch Firefox and enter about:config into the URL bar and press enter.
Right click and select New > String;
enter browser.cache.disk.parent_directory as the name
and /tmp as the string value.
This will instead store the cache in RAM (if you followed the first operation in this article.)

firefoxを再起動したら、ちゃんと/tmpにキャッシュができてました。

2009年12月27日日曜日

tmpfsを使う

Linuxでは、tmpfsというファイルシステムが用意されている。
/dev/sda1と同様に使えば、必要に応じメインメモリの一部を使ってファイルシステムを利用できる。
どんな風に動くのかは、下記を参照
naoyaのはてなダイアリー:tmpfs は本当に容量が動的なのか

tmpfsは実は、ubuntu9.10ではデフォルトで使われていて、df -h するとこんな感じ。
現行マシンの例
ファイルシステム            サイズ  使用  残り 使用% マウント位置
/dev/md4             21G   4.8G   15G  25% /
udev                  249M   308K  249M   1% /dev
none                  249M   1.1M  248M   1% /dev/shm
none                  249M   292K  249M   1% /var/run
none                  249M       0  249M   0% /var/lock
none                  249M       0  249M   0% /lib/init/rw
/dev/md2           190M   111M   70M  62% /boot
/dev/md5           125G    16G  103G  14% /home

~$ cat /etc/mtab
/dev/md4 / ext3 rw,relatime,errors=remount-ro 0 0
proc /proc proc rw 0 0
none /sys sysfs rw,noexec,nosuid,nodev 0 0
none /sys/fs/fuse/connections fusectl rw 0 0
none /sys/kernel/debug debugfs rw 0 0
none /sys/kernel/security securityfs rw 0 0
udev /dev tmpfs rw,mode=0755 0 0
none /dev/pts devpts rw,noexec,nosuid,gid=5,mode=0620 0 0
none /dev/shm tmpfs rw,nosuid,nodev 0 0
none /var/run tmpfs rw,nosuid,mode=0755 0 0
none /var/lock tmpfs rw,noexec,nosuid,nodev 0 0
none /lib/init/rw tmpfs rw,nosuid,mode=0755 0 0
/dev/md2 /boot ext3 rw,relatime 0 0
/dev/md5 /home ext3 rw,relatime 0 0
binfmt_misc /proc/sys/fs/binfmt_misc binfmt_misc rw,noexec,nosuid,nodev 0 0
gvfs-fuse-daemon /home/koichi/.gvfs fuse.gvfs-fuse-daemon rw,nosuid,nodev,user=xxxx 0 0

/etc/fstab には記載がないが、起動時のスクリプトでマウントされているらしい(下記参照)
/lib/init/rw と /dev/shm の tmpfs のサイズを変える Linux

/dev/shmを/temにマウントすればよいのかもしれないが、
/dev/shmがどの時点で使えるのか分からないので、
下記の参考のとおり、/etc/fstabで記述する。
How to: Reduce Disk Writes to Prolong the Life of your Flash Drive

いろいろ試してみて、notime,modeのオプションはつけなくてもOKらしい
logは残しておいた方がよいかな
tmpfs /tmp       tmpfs defaults 0 0
tmpfs /var/tmp       tmpfs defaults 0 0

/etc/fstabの最後に追加した

ところで、mode=はルートのパーミッションの指定だけど、4桁なのはなぜ?
パーミッション設定の極意! に説明がありました。転載させていただきます。

■ スティッキービット
drwxrwxrwxt のように”t”ビットがついた場合を意味する。
これをつける事によって、書き込み、読み出し、実行は出来るけど名前の変更、削除が出来なくなる。
特に、/tmpとかメールサーバのmailディレクトリの属性に良く使う。

スティッキービットを付加したい場合は、
# chmod +t <ディレクトリ名もしくはファイル名>
または、
# chmod 1777 <ディレクトリ名もしくはファイル名>
のように、数字の先頭に1を付加する。

2009年12月22日火曜日

New PC

何年かぶりに新PCを組む
Ubuntu 9.10 で SSD RAID 0 を試す

構成
CPU       Core i7 860 BOX
マザーボード  GA-P55M-UD4 Rev.1.0
メモリー       CMD4GX3M2A1600C8 (DDR3 PC3-12800 2GB 2枚組)
ビデオカード  GF-GT240-E512HD/D5/AC (PCIExp 512MB)
電源ユニット MODU82+ EMD525AWT
ケース     ACRYLIC COWBOY DC-ACPCD/R

とりあえず、古いIDEのディスク2台でRAIDインストールのテスト
CD-ROMは買ってないので、USBメモリからのインストール

Ubuntu Desktop 日本語 Remix CD はソフトウェアRAIDにインストールできないので、
Low-Power Intel Architecture alternate install CD を利用
下記のリンクからTorrentを使ってisoイメージをdownload
 Bit Torrent »

downloadできたらメニューのシステム、システム管理 から USBスタートアップ・ディスクの作成
downloadした元になるisoイメージとUSBメモリを指定して、作成

まずは、古いハードディスク二台でインストールの練習

組み上げたPCにUSBメモリーを差して起動
もちろん、BIOSで起動ドライブ等の設定はしてから。

途中でストップ、/bootをRAID0のドライブに作るとそのドライブのMBRにgrubがインストールできない。
/bootを別パーティションにして、再度インストール。うまくいきました。
本番では/bootをRAID1にしようかな。





 

2009年10月3日土曜日

VNC

VNCを使って、UbuntuからWindowsを使う

WindowsのVNCサーバーには、UltralVNCを使う。
窓の杜からダウンロードしてインストール
窓の杜 - UltraVNC
設定の参考
Windows上にVNCサーバー導入(UltraVNC)

Ubuntuには、デフォルトでリモートデスクトップビュワー(Vinagre)がインストールされている。

Windowsには固定IP割り振ってないけど、現在アサインされているアドレスを指定して、接続。
少し遅いけど充分です。

2009年9月26日土曜日

samba

Synapticでsambaをインストール
libpam-smbpassもインストール
pluggable authentication module for Samba
This is a module for PAM that enables a system administrator to migrate
user passwords from the Unix password database to the SMB password
database as used by Samba, and to subsequently keep the two databases in
sync. Unlike other solutions, it does this without needing users to log
in to Samba using cleartext passwords, or requiring them to change their
existing passwords.

sudo chown nobody:nogroup /home/pub
sudo chmod 777 /home/pub


/etc/samba/smb.conf を編集

workgroup = HOME
dos charset = CP932
unix charset = UTF-8
display charset = UTF-8
map to guest = Bad User

server string = %h (Samba, Ubuntu)

security = user

# CUPS printing. See also the cupsaddsmb(8) manpage in the
# cupsys-client package.
printing = cups
printcap name = cups

[homes]
comment = Home Directories
browseable = no
read only = no

[pub]
comment = Share Directories
path = /home/pub
hosts allow = 192.168.0. 127.
quest ok = no
writable = yes


sudo /etc/init.d/samba restart

CUPSの設定
メニューから システム管理>印刷
プリンタ設定のメニューから サーバ>設定
共有プリンタの公開にチェック
インターネットからの印刷は許可しない

/etc/cups/mime.convs を local.convs として保存し(Originalを残して)
以下の行のコメントアウトをはずす。
#application/octet-stream application/vnd.cups-raw 0

これで無事にWindowsから印刷できました。
簡単です。

Convmv

Vineの文字コードはEUCでUbuntuはUTF-8。文字コードが異なるため、Ubuntuに用意されているconvmv コマンドで、ファイル名をEUCからUTF-8に変更する。このコマンドはファイルの中味のコードは変えない。

まず、convmvをsynapticdでインストール

VineのHomeDirectoryをマウントして、テストしたのち、
sudo convmv -r -f euc-jp -t utf8 /mnt/new/koichi_backup/* --notest
無事に変換されました。必要なファイルを新しいHomeにCopy!

2009年6月7日日曜日

EPSON PM-A900

Avasys 
からcups用RPMのドライバーをダウンロード
pipsa900-cups-2.6.2-1.i386.rpm

Ubuntu 8.04/8.10 への
Photo Image Print System for Linux v2.6 CUPS版のインストール方法

から要約して転載

Synapticでalienとlibgtk1.2をインストール

alienツールを利用し、ダウンロードしたrpmパッケージをdebパッケージに変換します。
sudo alien --keep-version pipsa900-cups-2.6.2-1.i386.rpm

alienツールにより変換されたdebパッケージをインストールします。
sudo dpkg -i pipsa900-cups_2.6.2-1_i386.deb

テキストエディターを使用して、"/etc/init.d/ekpd"スクリプトファイルを作成します。
sudo gedit /etc/init.d/ekpd

#! /bin/sh
#
# Photo Image Print System

PATH=/bin:/usr/bin:/sbin:/usr/sbin
DAEMON=/usr/local/EPKowa/printer/ekpd
NAME=ekpd

[ -f $DAEMON ] || exit 0

OLDMASK=`umask`
umask 000

case "$1" in

start)
pidlist=`pidof $NAME`
if [ "x" = "x$pidlist" ]; then
echo -n "Starting $NAME: "
$DAEMON 2>/dev/null
echo "$NAME."
fi
;;

stop)
echo -n "Stopping $NAME: "
pidlist=`pidof $NAME`

for apid in $pidlist; do
kill -s 9 $apid 2>/dev/null
done
echo "$NAME."
;;

restart)
$0 stop
sleep 2
$0 start
;;

*)
echo "Usage: $NAME { start | stop | restart }" >&2
exit 1
;;
esac

umask $OLDMASK
exit 0

"/etc/init.d/ekpd"ファイルのパーミッションを変更します。

$ sudo chmod 755 /etc/init.d/ekpd

$ ls -la /etc/init.d/ekpd
-rwxr-xr-x 1 root root 774 2008-09-10 07:38 /etc/init.d/ekpd

ekpdデーモンの自動起動設定を行います。

$ sudo update-rc.d ekpd defaults
Adding system startup for /etc/init.d/ekpd ...
/etc/rc0.d/K20ekpd -> ../init.d/ekpd
/etc/rc1.d/K20ekpd -> ../init.d/ekpd
/etc/rc6.d/K20ekpd -> ../init.d/ekpd
/etc/rc2.d/S20ekpd -> ../init.d/ekpd
/etc/rc3.d/S20ekpd -> ../init.d/ekpd
/etc/rc4.d/S20ekpd -> ../init.d/ekpd
/etc/rc5.d/S20ekpd -> ../init.d/ekpd

ekpdデーモンを起動します。

$ sudo /etc/init.d/ekpd start
Starting ekpd: ekpd.

ekpdデーモンの起動を確認します。

$ ps -ef | grep ekpd
root 6135 1 0 10:21 pts/0 00:00:00 /usr/local/EPKowa/printer/ekpd

CUPSサービスを再起動します。

Ubuntu 8.10 の場合

$ sudo /etc/init.d/cups restart
* Restarting Common Unix Printing System: cupsd [ OK ]

プリンターのUSBケーブルを接続し、プリンターの電源をオンにします。画面上にプリンターを認識したことを知らせるメッセージが表示されます。"設定"ボタンをクリックします。

上記画面が表示されない場合は、システムメニューから[システム管理]-[印刷]を選択します。

プリンターの設定画面

"製造元とモデル"に"EPSON PM-A900, Photo Image Print System"と表示されていることを確認します。"テストページの印刷"ボタンをクリックしてプリンターからテストページが無事印刷されれば、プリンターのインストールは終了です。

プリンターの設定画面

ステータスモニターを起動します。Ubuntu 8.04/8.10ではメッセージが文字化けしてしまうため、ekpstmを英語モードで起動させるために"LANG=C"を付加して起動します。

$ LANG=C ekpstm

ステータスモニター画面が表示されることを確認します。


参考 Ubuntu 8.04/8.10 への
Photo Image Print System for Linux v2.6 CUPS版のインストール方法

Mail Environment

SynapticでPostfixをインストール

Postfixでは標準でMailbox形式なので、
/etc/postfix/main.cfの最後に
home_mailbox = Maildir/

sudo /etc/rc.d/init.d/postfix restart

Dovecotをインストール

このMDAは始めてです。
VineではCourie-IMAPを使ってましたが、
Ubuntuではこちらが標準のようです。
SynapticでPackageを検索
dovecot-common
dovecot-imapd

/etc/dovecot/dovecot.conf
mail_location = maildir:~/Maildir

sudo /etc/rc.d/init.d/dovecot restart

Thanderbirdを設定するがdovecotにloginできない。

To use with Thunderbird, edit the file /etc/dovecot/dovecot.conf:

protocol imap {
...
login_greeting_capability = yes
imap_client_workarounds = tb-extra-mailbox-sep
}

In Thunderbird, under Server Settings -> Advanced, uncheck "Show only subscribed folders".

Ubuntu Documentation Dovecot

上記の設定で、Thunderbirdは無事に動いたので、Fetchmailの設定

Synapticでfetchmailをインストール
~/.fetchmailrcはVineのものから少し変更
procmailをMDAに使っていたが、なくても大丈夫みたいなので、コメントアウト
fetchmail -v エラーが出るがちゃんと動く
自動起動の設定
$ crontab -e
0-59/1 * * * * /usr/bin/fetchmail > /dev/null 2>&1

DVD Playback

MedibuntuをRepositoryに追加してlibdvdcss2 packageをインストール

sudo wget http://www.medibuntu.org/sources.list.d/intrepid.list --output-document=/etc/apt/sources.list.d/medibuntu.list
sudo apt-get update
sudo apt-get install medibuntu-keyring
sudo apt-get update
sudo apt-get install libdvdcss2

Windows multimedia codecsもインストール

sudo apt-get install w32codecs


Medibuntu
ライセンスの関係でDistributionに含まれていない、CodicなどのRepository

参考 ubuntuguide.org/wiki/Ubuntu:Jaunty_ja#CDs_and_DVDs 

2009年6月1日月曜日

Ubuntu 9.04 (Jaunty Jackalope) Install

インストール

Ubuntu Desktop 日本語 Remix CD はソフトウェアRAIDにインストールできないので、
Low-Power Intel Architecture alternate install CD を利用
問題なくインストールできました。

Japanese Teamによる追加パッケージを利用

wget -q https://www.ubuntulinux.jp/ubuntu-ja-archive-keyring.gpg -O- | sudo apt-key add -
wget -q https://www.ubuntulinux.jp/ubuntu-jp-ppa-keyring.gpg -O- | sudo apt-key add -
sudo wget https://www.ubuntulinux.jp/sources.list.d/jaunty.list -O /etc/apt/sources.list.d/ubuntu-ja.list
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install ubuntu-desktop-ja

参考 Ubuntuの日本語環境

日本語環境セットアップ・ヘルパ

メニューのシステム、システム管理に、日本語環境セットアップ・ヘルパがある。
起動するとAdoveReaderや追加日本語フォントなど必要なパッケージを選んでインストールできる。

2009年5月28日木曜日

Vine Linux Install

システムをCopyしてみたが、起動しないのであきらめて再インストール
Vine4.2のインストールはなれたもの
hda1 /boot format
md0 / format
md1/home keep
問題なく起動、usr設定もちゃんと引き継がれた
Synapticでupdate

メール環境設定
Courier-IMAPをインストール
Postfixでは標準でMailbox形式なので、/etc/postfix/main.cfを編集
home_mailbox = Maildir/
/etc/rc.d/init.d/postfix restart
Thunderbirdをインストール

参考 Courier-IMAPのインストールと設定

fetchmailをインストール
~/.fetchmailrcは前のままのがCopyされているのでOK
自動起動の設定
$ crontab -e
0-59/1 * * * * /usr/bin/fetchmail > /dev/null 2>&1

参考 FetchMail象歩

うまくいきました。/home をそのままコピーしているのでFirefoxの設定等も引き継がれました。

2009年5月24日日曜日

Test Copied System

Copyができたら必要な修正をする。

Fetchmailでメールを取り込んでるので、片方だけに入らないように
/home/~/.fetchmailrcを修正する。
コメントを示す行頭の"#"を削除して、defaultsセクションに"keep"を追加。

defaults
proto pop3
no rewrite
keep
fetchall

Copyedシステムでは、物理ドライブのアサインが変わっているので、fstabを修正

Old systemをbootするときは、hdaからboot
Current systemをbootするときは、sdaからboot
ブートドライブと/bootパーティションの位置は変更ないので、grubの設定はそのまま
Current sda hda1 (hd0,0)
Old hda1 (hd0,0)
後で必要に応じ、menu.lstを編集

Copy Current System

まず、Copy先のパーティションをきれいに消します。
rootでnautilusを起動して慎重に。

現在のシステムを/oldにCopy
cp -ax / /mnt/old/
cp -ax /home /mnt/old/
cp -ax /boot /mnt/old/

-a, --archive
コピー先で、できる限り元のファイルの構成と属性を 保
持する (ディレクトリ構造体は保存しない)。 -dpR と同
じ。
-x, --one-file-system
コピーを始めたディレクトリと異なるファイルシステ ム
上 にあるサブディレクトリをコピーをしない。マウント
ポイントは同じファイルシステム上にあるのでコピー さ
れる。

念のためファイル構造をパーティションごとに確認。
umount /mnt/old/boot
umount /mnt/old/home
umount /mnt/old
fsck /dev/hda1
fsck /dev/md1
fsck /dev/md0
mount /mnt/old
mount /mnt/old/home
mount /mnt/old/boot

ちゃんとCopyされてるか確認します。
find / -path /proc -prune -o -path /mnt -prune -o -xtype f -exec cmp {} /mnt/old{} \;
かなり時間がかかります。ときどき、log fileやcache fileの違いが報告されます。

参考
Hard Disk Upgrade Mini How-To

grub

HDが3台あるので、どのHDからでも起動できるように、
全部のドライブのMBRにbrubをインストールする。

GNU GRUB manual
より抜粋

(hd0,1)
Here, hd means it is a hard disk drive. The first integer `0 indicates the drive number, that is, the first hard disk, while the second integer, `1 indicates the partition number (or the pc slice number in the BSD terminology). Once again, please note that the partition numbers are counted from zero, not from one. This expression means the second partition of the first hard disk drive. In this case, GRUB uses one partition of the disk, instead of the whole disk.

(hd0,4)
This specifies the first extended partition of the first hard disk drive. Note that the partition numbers for extended partitions are counted from `4', regardless of the actual number of primary partitions on your hard disk.
Note that GRUB does not distinguish IDE from SCSI - it simply counts the drive numbers from zero, regardless of their type. Normally, any IDE drive number is less than any SCSI drive number, although that is not true if you change the boot sequence by swapping IDE and SCSI drives in your BIOS.

BIOSの設定でどのドライブがhd0になるか決まる!


If you decide to install GRUB in the native environment, which is definitely desirable, you'll need to create a GRUB boot disk, and reboot your computer with it. Otherwise, see Installing GRUB using grub-install.


Once started, GRUB will show the command-line interface (see Command-line interface). First, set the GRUB's root device4 to the partition containing the boot directory, like this:


grub> root (hd0,0)
(stage1のファイルがあるパーティションを指定)

Once you've set the root device correctly, run the command setup (see setup):

grub> setup (hd0)  
(hd0ブートしたドライブのMBRにgrubをインストール)
grubのインストール

2009年5月23日土曜日

$ df -h

$ df -h
ファイルシステム サイズ 使用 残り 使用% マウント位置
/dev/md4 21G 3.8G 16G 20% /
/dev/md2 190M 26M 155M 15% /boot
none 251M 0 251M 0% /dev/shm
/dev/md5 125G 31G 88G 26% /home
/dev/sdb10 165G 11G 146G 7% /mnt/new
/dev/md0 9.4G 4.7G 4.3G 52% /mnt/old
/dev/md1 46G 44G 587M 99% /mnt/old/home
/dev/hda1 99M 7.2M 87M 8% /mnt/old/boot

$ cat /proc/mdstat

$ cat /proc/mdstat
Personalities : [raid1]
md2 : active raid1 sdb1[1] sda1[0]
200704 blocks [2/2] [UU]

md3 : active raid1 sdb2[1] sda2[0]
2208832 blocks [2/2] [UU]

md4 : active raid1 sdb5[1] sda5[0]
21687616 blocks [2/2] [UU]

md5 : active raid1 sdb6[1] sda6[0]
132190720 blocks [2/2] [UU]

md1 : active raid1 sdb9[1] hda6[0]
48949952 blocks [2/2] [UU]

md0 : active raid1 sdb8[1] hda5[0]
10000320 blocks [2/2] [UU]

fdisk

Disk /dev/hda: 61.4 GB, 61492838400 bytes
255 heads, 63 sectors/track, 7476 cylinders
Units = シリンダ数 of 16065 * 512 = 8225280 bytes

デバイス Boot Start End Blocks Id System
/dev/hda1 * 1 13 104391 83 Linux
/dev/hda2 14 137 996030 82 Linux swap / Solaris
/dev/hda3 138 7476 58950517+ 5 拡張領域
/dev/hda5 138 1382 10000431 fd Linux raid 自動検出
/dev/hda6 1383 7476 48950023+ fd Linux raid 自動検出

Disk /dev/sda: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders
Units = シリンダ数 of 16065 * 512 = 8225280 bytes

デバイス Boot Start End Blocks Id System
/dev/sda1 * 1 25 200781 fd Linux raid 自動検出
/dev/sda2 26 300 2208937+ fd Linux raid 自動検出
/dev/sda3 301 19457 153878602+ 5 拡張領域
/dev/sda5 301 3000 21687718+ fd Linux raid 自動検出
/dev/sda6 3001 19457 132190821 fd Linux raid 自動検出

Disk /dev/sdb: 400.0 GB, 400088457216 bytes
255 heads, 63 sectors/track, 48641 cylinders
Units = シリンダ数 of 16065 * 512 = 8225280 bytes

デバイス Boot Start End Blocks Id System
/dev/sdb1 * 1 25 200781 fd Linux raid 自動検出
/dev/sdb2 26 300 2208937+ fd Linux raid 自動検出
/dev/sdb3 301 48641 388299082+ 5 拡張領域
/dev/sdb5 301 3000 21687718+ fd Linux raid 自動検出
/dev/sdb6 3001 19457 132190821 fd Linux raid 自動検出
/dev/sdb7 19458 19470 104391 83 Linux
/dev/sdb8 19471 20715 10000431 fd Linux raid 自動検出
/dev/sdb9 20716 26809 48950023+ fd Linux raid 自動検出
/dev/sdb10 26810 48641 175365508+ 83 Linux

Ubuntu

VineからUbuntu
Thank you Vine