環境構築を支えるUnionfsとcloop

以下のテキストは、執筆時当時の情報を元に書いたものであり、 現在の情勢にそぐわないことを含む場合があるので注意されたい。 また、テキストは最終提出原稿で校正を経る前のものなので、実際にOSM 本誌に記載されたものとは異なる。誤字脱字等そのままである。

致命的な誤り以外は加筆修正等は行なわないので情報の鮮度に気をつけつつ 利用して欲しい。

目次


����������������������������������!��

������������������������������������������������������������������������
������������������������������������������������������������������������
������������������������������������������������������������������������
������������������������������������������������������������������������
������������������������������������������������������������������������
������������������������������������������������������������������������
��������������������������������������������������������

������������������������������������������������������������������������
����������������������������

======================================================================
Part1: ����������������Unionfs��cloop
======================================================================


��
��Unionfs������������������������
��

Part* ������������Unionfs����������������������������KNOPPIX��FreeSBIE��
��������������1CD��������������������������������������������������������
����������������������������������������������Unionfs������������������
������������������������������������������������������������������������
����������������������������������

����������������������������������

��������������������������������Unix������������������������������������
��������������������������������������������������������������������������
Unix��OS����������������Web������������������������������������������������
������������������������������������������������������������������root��
������������������������������������������������������������������������
������������������������������������������������������������������������
������������������������������������

������������������������������������������������������������������������
����������������������������������������������������������������chroot
jail������������������chroot()������������������������������������������
������������������������������chroot()����������������������������������
��������������������

������������������������������������������������������������������������
����������������������Web��������chroot������������������������chroot����
������������������2������������������������������������������������������
������������������������������������������������������������������������
���������������������� /bin /sbin /usr/bin /usr/bin ������OS������������
������������������������������������������������������������������������
������������������������������������������������������������������������
������������������������������������������������������������������������
��������������������root������������������������������������������������
������������������������������������

������������������������������������������������������������������������
����������������������������������������������������������

������������������������������������������������������������������������
��������������Union file system(Plan9, BSD, Linux), Loopback file
system(SunOS), Null file system(BSD) ����������������������������������
����������������������������������������������������

������������������������

������������������������������������������������������������������������
������������������������������������������������������������������������
������������������������������������������������������������������������
����������������������������������������������������������������chroot��
������������������������������������������������������������������������
����������������������������chroot��������������������������������������
Unionfs����������������������������������������������������������������
����������������

��CD1��������������������

CD��OS������������������������������������������������������������������
����������������������������������Unionfs��CD����������������������������
������������������������������������������������������������������������
������FreeSBIE��KNOPPIX��������������������������������������������
Unionfs����������������������������������������1CD����������������������
����������������

��
��Unionfs����������
��

Unionfs������������������������������������������������������������������
������������������������������������������������������ Unionfs ������������
����������������������������������������������������������

����������2���������������� a �� b ���� ��������������������������������
����������

---[�� ��]------------------------------------------------------------

 +--- ������������ a/ ---+     +--- ������������ b/ ---+
 |                       |     |                       |
 |    OSM                |     |    OSM                |
 |    foo                |     |    hoge               |
 |    bar                |     |    hero               |
 |                       |     |                       |
 +-----------------------+     +-----------------------+
----------------------------------------------------------------------

��������������������������

��Linux Unionfs ������
Linux��������Unionfs���������� ��������
A Stackable Unification File System
http://www.fsl.cs.sunysb.edu/project-unionfs.html

---[�� ��]------------------------------------------------------------
Linux������������������������������������������ Unionfs ����������������
��������������Part3��������FUSE�������������� Unionfs ��2��(������������
����)����������������������������������������������������������������A
Stackable Unification File System���������������� Linux Unionfs ��������
----------------------------------------------------------------------

������������������������Linux Unionfs��������������������KNOPPIX��������
����������������������2006��9������������������KNOPPIX 5.0.1������������
������������������������������

������������������������������

	* a/ �� b/ ����������������������������������(�������� u/) ��
	  ����������
	* ����������������������������������������������������������
	  ����������������������������������������������������������

�������������� Unionfs ����������������������

����������KNOPPIX����������unionfs��������������������������������������
��������������KNOPPIX������������������������������ su ������������������
��������������

root@ttyp1[~]# mount -tunionfs
/UNIONFS on /UNIONFS type unionfs (rw,dirs=/ramdisk=rw:/KNOPPIX=ro,delete=whiteout)


����������unionfs����������������������������������unionfs��������������
��������������������������������������������������
    ============================
�������������� /ramdisk ����������������

--------------------------------------------------------------��������
# mkdir /ramdisk/uniontest
# cd /ramdisk/uniontest
# mkdir a b u
# touch a/{foo,bar} b/{hoge,hero}
# echo This is in A > a/OSM
# echo B dayo > b/OSM
# ls -l a b u
a:
���� 4
-rw-r--r-- 1 root root 13 2006-08-18 10:58 OSM
-rw-r--r-- 1 root root  0 2006-08-18 10:58 bar
-rw-r--r-- 1 root root  0 2006-08-18 10:58 foo

b:
���� 4
-rw-r--r-- 1 root root 7 2006-08-18 10:58 OSM
-rw-r--r-- 1 root root 0 2006-08-18 10:58 hero
-rw-r--r-- 1 root root 0 2006-08-18 10:58 hoge

u:
���� 0
--------------------------------------------------------------��������

��������a/ �� b/ ���������������� u/ ��������������������

--------------------------------------------------------------��������
# mount -t unionfs -o dirs=a:b unionfs u
# ls -l u
���� 4
-rw-r--r-- 1 root root 13 2006-08-18 10:58 OSM
-rw-r--r-- 1 root root  0 2006-08-18 10:58 bar
-rw-r--r-- 1 root root  0 2006-08-18 10:58 foo
-rw-r--r-- 1 root root  0 2006-08-18 10:58 hero
-rw-r--r-- 1 root root  0 2006-08-18 10:58 hoge
# cat u/OSM
This is in A
--------------------------------------------------------------��������

�������������� OSM �� a/ ��������������������mount ��������������������
������������������������������������������������������������������������
���������� unionctl ��������������������

--------------------------------------------------------------��������
# unionctl u --list
        /ramdisk/uniontest/a (rw-)
        /ramdisk/uniontest/b (rw-)
--------------------------------------------------------------��������

������������������������������������������������������������������������
������������������������������������������mount������������������������
������ =rw ��������=ro ����������������������������������������rw������
��������������

--------------------------------------------------------------��������
# umount u
# mount -t unionfs -o dirs=a=rw:b=ro unionfs u
--------------------------------------------------------------��������

����������������b����������������������������������

--------------------------------------------------------------��������
# \rm u/hoge			(union����������������hoge������)
# ls -la a b u			(-a����������������)
a:
���� 4
drwxr-xr-x 2 root root 120 2006-08-18 11:03 .
drwxr-xr-x 5 root root 100 2006-08-18 10:55 ..
-rwxr-xr-x 1 root root   0 2006-08-18 11:03 .wh.hoge
-rw-r--r-- 1 root root  13 2006-08-18 10:58 OSM
-rw-r--r-- 1 root root   0 2006-08-18 10:58 bar
-rw-r--r-- 1 root root   0 2006-08-18 10:58 foo

b:
���� 4
drwxr-xr-x 2 root root 100 2006-08-18 11:02 .
drwxr-xr-x 5 root root 100 2006-08-18 10:55 ..
-rw-r--r-- 1 root root   7 2006-08-18 10:58 OSM
-rw-r--r-- 1 root root   0 2006-08-18 10:58 hero
-rw-r--r-- 1 root root   0 2006-08-18 11:02 hoge

u:
���� 4
drwxr-xr-x 2 root root 120 2006-08-18 11:03 .
drwxr-xr-x 5 root root 100 2006-08-18 10:55 ..
-rw-r--r-- 1 root root  13 2006-08-18 10:58 OSM
-rw-r--r-- 1 root root   0 2006-08-18 10:58 bar
-rw-r--r-- 1 root root   0 2006-08-18 10:58 foo
-rw-r--r-- 1 root root   0 2006-08-18 10:58 hero
--------------------------------------------------------------��������

a�������������� .wh.hoge ����������������������������b/hoge ������������
��������������������������������������������������������������������
a/.wh.hero �������� u/hero ����������������

--------------------------------------------------------------��������
# touch a/.wh.hero
# ls u
OSM  bar  foo
--------------------------------------------------------------��������





��BSD unionfs������

4.4BSD������������ Unionfs ����������FreeBSD/NetBSD��������������������
���������������������������� ������
---[�� ��]------------------------------------------------------------
FreeBSD��Unionfs������������������������������������������������
��������Part2��������������������������������������Unionfs��������������
��������Unionfs��������������������������������������������������������
��������������������������������������������
----------------------------------------------------------------------

BSD unionfs�� Linux ����������������������������������������������������
����������(����������)��������������������������������������BSD unionfs��
���������������� ������������������������������������������������������
��������������������������������BSD Unionfs����������������������������
��������������������������������b������������������������������

--------------------------------------------------------------��������
# mkdir /tmp/uniontest
# cd /tmp/uniontest
# mkdir a b
# touch a/{foo,bar} b/{hoge,hero}
# echo This is in A > a/OSM
# echo B dayo > b/OSM
# ls -l a b
a:
total 1
-rw-r--r--  1 root  wheel  13 Aug 18 14:19 OSM
-rw-r--r--  1 root  wheel   0 Aug 18 14:19 bar
-rw-r--r--  1 root  wheel   0 Aug 18 14:19 foo

b:
total 1
-rw-r--r--  1 root  wheel  7 Aug 18 14:19 OSM
-rw-r--r--  1 root  wheel  0 Aug 18 14:19 hero
-rw-r--r--  1 root  wheel  0 Aug 18 14:19 hoge
--------------------------------------------------------------��������

mount -t unionfs �� Unionfs �������������������� Linux ������������������
����������������������������������������������������������������

--------------------------------------------------------------��������
# mount -t unionfs /tmp/uniontest/a b
# ls -l b
total 1
-rw-r--r--  1 root  wheel  13 Aug 18 14:27 OSM
-rw-r--r--  1 root  wheel   0 Aug 18 14:27 bar
-rw-r--r--  1 root  wheel   0 Aug 18 14:27 foo
-rw-r--r--  1 root  wheel   0 Aug 18 14:27 hero
-rw-r--r--  1 root  wheel   0 Aug 18 14:27 hoge
# cat b/OSM
This is in A
--------------------------------------------------------------��������

����������(b)������������������ hoge ��������������
--------------------------------------------------------------��������
# rm b/hoge
# ls -l b
total 1
-rw-r--r--  1 root  wheel  13 Aug 18 14:27 OSM
-rw-r--r--  1 root  wheel   0 Aug 18 14:27 bar
-rw-r--r--  1 root  wheel   0 Aug 18 14:27 foo
-rw-r--r--  1 root  wheel   0 Aug 18 14:27 hero
--------------------------------------------------------------��������

���������������������� a/ ������������ hoge ����������������������������
��������������������������
--------------------------------------------------------------��������
# ls -l a
-rw-r--r--  1 root  wheel  13 Aug 18 14:27 OSM
-rw-r--r--  1 root  wheel   0 Aug 18 14:27 bar
-rw-r--r--  1 root  wheel   0 Aug 18 14:27 foo
--------------------------------------------------------------��������

ls �� -W ������������������������������

--------------------------------------------------------------��������
# ls -lW a
total 1
-rw-r--r--  1 root  wheel  13 Aug 18 14:27 OSM
-rw-r--r--  1 root  wheel   0 Aug 18 14:27 bar
-rw-r--r--  1 root  wheel   0 Aug 18 14:27 foo
w---------  0 root  wheel   0 Jan  1  1970 hoge
--------------------------------------------------------------��������

�������������� w �� whiteout ����������������������������������Unionfs��
������������������������������������������������������������������������
������������������hoge����������������������������������������������
whiteout������������������������ rm �� -W ������������������

--------------------------------------------------------------��������
# rm a/hoge
rm: b/hoge: No such file or directory
# rm -W a/hoge
# ls b
OSM   bar   foo   hero  hoge
--------------------------------------------------------------��������


��
��cloop����������
��

���������������������������������������������������� loop ��������
(Linux)��vnode ��������(FreeBSD/NetBSD)����������������������������������
��������������������������������������cloop��������

�������������������������� foo.img ��������������������������������������
������������������������������������������������

Linux������
--------------------------------------------------------------��������
# insmod cloop.o file=foo.img
# mount -t ��FS�������� /dev/cloop ��������������������
--------------------------------------------------------------��������

FreeBSD������
--------------------------------------------------------------��������
# kldload geom_uzip
# mount -t ��FS�������� \
     /dev/`mdconfig -a -t vnode foo.img`.uzip ��������������������
--------------------------------------------------------------��������

������������Unix������������������������CD��ISO������������������������
������������������������������������CD����������������������������������
��������������������������������

��
��������������������������������
��

������������������������������������������������������������������������
��������������������������������������������������������������������������
������������������������������������������������������������

������������������������������������������swap������������������������
��������������������������������������������������������������CD��������
������Linux�������� tmpfs��FreeBSD�������� malloc ����������������������
��������������������������

����������32MB���������������� /mem ������������������������

��Linux��
# mount -t tmpfs -o size=32m /mem

��FreeBSD��
# mdmfs -M -s 32m md /mem

��
��������������������1CD������������
��

Part1�������� Unionfs, cloop, ������������������������������������������
������������������������������������������������������������Part2��������
��������������������������������������1CD��������������������������������
��������


---[�� ��]------------------------------------------------------------
----------------------------------------------------------------------
��������

http://www.usenix.org/publications/library/proceedings/neworl/full_papers/mckusick.a


yuuji@example.org
Fingerprint16 = FF F9 FF CC E0 FE 5C F7 19 97 28 24 EC 5D 39 BA
HIROSE Yuuji - ASTROLOGY / BIKE / EPO / GUEST BOOK / YaTeX [Tweet]