|
From: Nathaniel S. <nr...@le...> - 2005-11-03 11:03:12
|
Almost right. You need to populate the View so that it refers to the
files in the read/only filesystem. For files in the View: directories
represent themselves, data files contain a path to the host file that
backs them (can be newline terminated or not) relative to the lookup
root (root=) mount parameter, other special files (symbolic links,
fifos, device nodes) just represent themselves.
export VIEW=/path/to/mapfs/view
export ROBASE=/path/to/robase
export RELROBASE=/path/to/robase/from/mapfs/lookup/root
cd $ROBASE
find . -print0 | xargs -0 --replace=FOO sh -c "
if [ -h FOO ]; then
cp -dp FOO $VIEW/FOO;
elif [ -d FOO ]; then
mkdir $VIEW/FOO;
chown --reference=FOO $VIEW/FOO;
chmod --reference=FOO $VIEW/FOO;
elif [ -f FOO ]; then
echo "$RELROBASE/FOO" > $VIEW/FOO;
chown --reference=FOO $VIEW/FOO;
chmod --reference=FOO $VIEW/FOO;
else
cp -dp FOO $VIEW/FOO;
fi"
Albrecht Gebhardt wrote:
>Hi,
>
>reading the announcement I tought it should be possible to make
>a readonly mounted path (eg. part of a mounted cdrom) writable by adding
>a COW layer on top of it (as other layer filesystems like unionfs,
>minifo_fs, mulafs do ...).
>
>I tried the following
>
>cd /tmp
>dd if=/dev/zero of=/tmp/ro.img bs=1M count=2
>mkfs.ext2 -F /tmp/ro.img
>mkdir /tmp/ro-tree
>mount -o loop /tmp/ro.img /tmp/ro-tree
>cat > /tmp/ro-tree/test.txt <<EOT
>test
>EOT
>mkdir /tmp/ro-tree/dir
>cp /tmp/ro-tree/test.txt /tmp/ro-tree/dir
>sync
>umount /tmp/ro-tree
>mount -o loop,ro /tmp/ro.img /tmp/ro-tree
>
>Now I have i readonly filesystem mounted at /tmp/ro-tree with some files
>in it:
>
># ls /tmp/ro-tree
>dir lost+found test.txt
># touch /tmp/ro-tree/xxx
>touch: cannot touch `/tmp/ro-tree/xxx': Read-only file system
>
>Now I want to mount this path with mapfs to /tmp/rw-tree where I would
>like to see the files from /tmp/ro-tree an would like to be able to
>modify/add/delete files in the /tmp/rw-tree (virtually including the
>files from /tmp/ro-tree).
>
>The rw directories:
>
>mkdir /tmp/rw-tree
>mkdir -p /tmp/mapfs/view
>mkdir -p /tmp/mapfs/overlay
>
>I tried
>
>mount -t mapfs -o \
>root=/tmp/ro-tree,\
>view=/tmp/mapfs/view,\
>overlay=/tmp/mapfs/overlay,\
>cow_base=/overlay none /tmp/rw-tree
>
>Does not work, the test.txt files from /tmp/ro-path are not visible
>in /tmp/rw-tree (Tough I can create and edit files in /tmp/rw-tree
>resulting in new files in the view and overlay location)
>
># ls -l /tmp/rw-tree
>total 0
>
>
>
>
Right... the View is empty, and it defines what appears in the mounted
MapFS filesystem (in this case /tmp/rw-tree). The MapFS Overlay
directory and any other filesystems you are going to want to map files
from into the MapFS view need to share a common parent so MapFS lookups
(which originate from the MapFS lookup root) can succeed for all of
them. cow_base should be set appropriately if the lookup root isn't /.
So, if the MapFS lookup root was /tmp (root=/tmp), then cow_base should
be /mapfs/overlay in your above command.
export VIEW=/tmp/mapfs/view
export ROBASE=/tmp/ro-tree
export RELROBASE=/ro-tree
cd $ROBASE
find ... (from above)
mount -t mapfs \
-o root=/tmp,view=/tmp/mapfs/view,\
overlay=/tmp/mapfs/overlay,\
cow_base=/mapfs/overlay \
none /tmp/rw-tree
>I even tried to move the (rw) view and overlay directories with mount
>--bind into the ro-tree:
>
>umount /tmp/rw-tree
>umount /tmp/ro-tree
>mount -o loop /tmp/ro.img /tmp/ro-tree
>mkdir /tmp/ro-tree/mapfs
>sync
>umount /tmp/ro-tree
>mount -o loop,ro /tmp/ro.img /tmp/ro-tree
>mount --bind /tmp/mapfs /tmp/ro-tree/mapfs
>
>and now:
>
>mount -t mapfs -o \
>root=/tmp/ro-tree,\
>view=/tmp/ro-tree/mapfs/view,\
>overlay=/tmp/ro-tree/mapfs/overlay,\
>cow_base=/mapfs/overlay none /tmp/rw-tree
>
>Still /tmp/rw-tree is empty.
>
>Do I miss something?
>
>Thanks
>
>Albrecht
>
>
>
>
|