====== CentOS7へのaufs3のインストール ====== ふと思い立ったのでやってみた。\\ ===== 最低限のやること ===== * CentOS7のインストール * 最小構成インストールでOK * ネットワーク通信の確立 * DHCPで良い。/etc/sysconfig/network-scripts/ifcfg-*をいじいじ。 * 必要なパッケージのインストール * 必要なデータのダウンロード、展開 * カーネルソースへのAUFSパッチの適用 * カーネルのビルド * 再起動と動作確認 ===== 作業 ===== ==== CentOS7のインストール ==== 普通にインストール。\\ 最小構成インストールで良い。\\ 作業は面倒なので、rootで $ su - Password: === ネットワーク接続を有効に === **/etc/sysconfig/network-scripts/ifcfg-enp0s3**を編集しておく。 === 作業領域を作成 === # cd / # mkdir work # cd /work ==== 必要なパッケージを導入 ==== 必要なパッケージを導入しておく。\\ yumを実行 # yum -y install net-tools wget ncurses-devel git bc # yum -y groupinstall "Development Tools" ==== 必要なデータのダウンロード・展開 ==== 必要なデータをダウンロード、展開しておく。\\ もちろんaufsのデータも。\\ kernelはCentOS7が3.10.xなので、現状での3.10系の最新を使用。\\ それに合わせてaufsのパッチも適合するバージョンを使用。 # wget https://www.kernel.org/pub/linux/kernel/v3.x/linux-3.10.49.tar.xz # tar -Jxvf linux-3.10.49.tar.xz # git clone git://git.code.sf.net/p/aufs/aufs3-standalone # cd aufs3-standalone # git checkout aufs3.10.x # cd .. ==== カーネルソースへのパッチ適用 ==== aufsはカーネルにパッチを適用する必要があるので。 # cd linux-3.10.49 # patch -p1 < ../aufs3-standalone/aufs3-kbuild.patch # patch -p1 < ../aufs3-standalone/aufs3-base.patch # patch -p1 < ../aufs3-standalone/aufs3-mmap.patch # cp -R ../aufs3-standalone/Documentation/* Documentation/ # cp -R ../aufs3-standalone/fs/* fs/ # cp -R ../aufs3-standalone/include/uapi/linux/aufs_type.h include/uapi/linux/ ==== カーネルのビルド ==== カーネルをビルドする。\\ configファイルを/bootにあるものをコピーしてベースとして流用。 # make mrproper # cp /boot/config-3.10.0-123.el7.x86_64 ./.config # make menuconfig menuconfigではAUFSの設定を有効にしておく。 File System -> Miscellaneous filesystems <*> Aufs (Advanced multi layered unification filesystem) support Maximum number of branches (127) ---> [*] Detect direct branch access (bypassing aufs) method (fsnotify) ---> [*] NFS-exportable aufs [*] Readdir in userspace [*] Show whiteouts [*] Ramfs (initramfs/rootfs) as an aufs branch [*] Fuse fs as an aufs branch [ ] Debug aufs (NEW) カーネルのビルドを実行 make clean make bzImage make modules make modules_install make install ==== 再起動と動作確認 ==== カーネルのビルドが完了したら、再起動する。\\ 場合によってはgrubの設定をいじって、ビルドしたカーネルで自動起動するように設定しても良い。 === テストデータ準備 === $ su - Password: # cd /work # mkdir ro rw mnt # touch ro/sample1.txt # touch ro/sample2.txt # touch ro/sample3.txt # touch rw/sample4.txt === マウントする === mount -t tmpfs -o size=200M tmpfs /tmp mount -t aufs -o br:/work/rw:/work/ro=ro aufs /work/mnt aufsのマウント前に/tmpにtmpfsをマウントしているが、これはファイルシステムがext3とかなら多分不要。\\ CentOS7はデフォルトでxfsがファイルシステムとして適用されるが、xfsだとaufsが生成するファイルが書けないらしい。\\ tmpfsのマウントをしない状態でaufsのマウントを行うと、次のような良く見かけるエラーになる。 aufs au_xino_create:XXX:mount[XXXX]: xino doesn't support /tmp/.aufs.xino(xfs) mount: wrong fs type, bad option, bad superblock on aufs, missing codepage or helper program, or other error In some cases useful info is found in syslog - try dmesg | tail or so. 要は、.xinoファイルとやらがXFS上に作成される事に対応していない、ということらしい。\\ 今回のようにtmpfsを使ったり、EXT3などのファイルシステムなら問題にならない様子。 === 動作確認 === 現状の確認 # ls -la /work/ro/ 合計 0 drwxr-xr-x. 2 root root 60 7月 25 10:16 . drwxr-xr-x. 7 root root 104 7月 25 10:16 .. -rw-r--r--. 1 root root 0 7月 25 10:16 sample1.txt -rw-r--r--. 1 root root 0 7月 25 10:16 sample2.txt -rw-r--r--. 1 root root 0 7月 25 10:16 sample3.txt # ls -la /work/rw/ 合計 0 drwxr-xr-x. 4 root root 81 7月 25 21:55 . drwxr-xr-x. 7 root root 104 7月 25 10:16 .. -r--r--r--. 1 root root 0 7月 25 21:55 .wh..wh.aufs drwx------. 2 root root 6 7月 25 21:55 .wh..wh.orph drwx------. 2 root root 6 7月 25 21:55 .wh..wh.plnk -rw-r--r--. 1 root root 0 7月 25 10:16 sample4.txt # ls -la /work/mnt/ 合計 0 drwxr-xr-x. 4 root root 81 7月 25 21:55 . drwxr-xr-x. 7 root root 104 7月 25 10:16 .. -rw-r--r--. 1 root root 0 7月 25 10:16 sample1.txt -rw-r--r--. 1 root root 0 7月 25 10:16 sample2.txt -rw-r--r--. 1 root root 0 7月 25 10:16 sample3.txt -rw-r--r--. 1 root root 0 7月 25 10:16 sample4.txt データを追加してみる # touch /work/mnt/sample5.txt で、再度確認 # ls -la /work/ro/ 合計 0 drwxr-xr-x. 2 root root 60 7月 25 10:16 . drwxr-xr-x. 7 root root 104 7月 25 10:16 .. -rw-r--r--. 1 root root 0 7月 25 10:16 sample1.txt -rw-r--r--. 1 root root 0 7月 25 10:16 sample2.txt -rw-r--r--. 1 root root 0 7月 25 10:16 sample3.txt # ls -la /work/rw/ 合計 0 drwxr-xr-x. 4 root root 99 7月 25 21:56 . drwxr-xr-x. 7 root root 104 7月 25 10:16 .. -r--r--r--. 1 root root 0 7月 25 21:55 .wh..wh.aufs drwx------. 2 root root 6 7月 25 21:55 .wh..wh.orph drwx------. 2 root root 6 7月 25 21:55 .wh..wh.plnk -rw-r--r--. 1 root root 0 7月 25 10:16 sample4.txt -rw-r--r--. 1 root root 0 7月 25 21:56 sample5.txt # ls -la /work/mnt/ 合計 0 drwxr-xr-x. 4 root root 99 7月 25 21:56 . drwxr-xr-x. 7 root root 104 7月 25 10:16 .. -rw-r--r--. 1 root root 0 7月 25 10:16 sample1.txt -rw-r--r--. 1 root root 0 7月 25 10:16 sample2.txt -rw-r--r--. 1 root root 0 7月 25 10:16 sample3.txt -rw-r--r--. 1 root root 0 7月 25 10:16 sample4.txt -rw-r--r--. 1 root root 0 7月 25 21:56 sample5.txt 削除もしてみる # rm /work/mnt/sample3.txt で、再々度確認 # ls -la /work/ro/ 合計 0 drwxr-xr-x. 2 root root 60 7月 25 10:16 . drwxr-xr-x. 7 root root 104 7月 25 10:16 .. -rw-r--r--. 1 root root 0 7月 25 10:16 sample1.txt -rw-r--r--. 1 root root 0 7月 25 10:16 sample2.txt -rw-r--r--. 1 root root 0 7月 25 10:16 sample3.txt # ls -la /work/rw/ 合計 4 drwxr-xr-x. 4 root root 4096 7月 25 21:59 . drwxr-xr-x. 7 root root 104 7月 25 10:16 .. -r--r--r--. 2 root root 0 7月 25 21:55 .wh..wh.aufs drwx------. 2 root root 6 7月 25 21:55 .wh..wh.orph drwx------. 2 root root 6 7月 25 21:55 .wh..wh.plnk -r--r--r--. 2 root root 0 7月 25 21:55 .wh.sample3.txt -rw-r--r--. 1 root root 0 7月 25 10:16 sample4.txt -rw-r--r--. 1 root root 0 7月 25 21:56 sample5.txt # ls -la /work/mnt/ 合計 4 drwxr-xr-x. 4 root root 4096 7月 25 21:59 . drwxr-xr-x. 7 root root 104 7月 25 10:16 .. -rw-r--r--. 1 root root 0 7月 25 10:16 sample1.txt -rw-r--r--. 1 root root 0 7月 25 10:16 sample2.txt -rw-r--r--. 1 root root 0 7月 25 10:16 sample4.txt -rw-r--r--. 1 root root 0 7月 25 21:56 sample5.txt ま、こんな感じで。