Difference between revisions of "Overlay file system linux"
From Teknologisk videncenter
m |
m |
||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
+ | =Single lower directory example= | ||
<source lang=bash> | <source lang=bash> | ||
#/usr/bin/env bash | #/usr/bin/env bash | ||
Line 4: | Line 5: | ||
mkdir upper1 work1 merged1 # Instance 1 fs | mkdir upper1 work1 merged1 # Instance 1 fs | ||
mkdir upper2 work2 merged2 # Instance 2 fs | mkdir upper2 work2 merged2 # Instance 2 fs | ||
+ | |||
+ | # Populate | ||
+ | touch lower/lib1 lower/lib2 upper1/file1-1 upper1/file1-2 upper2/file2-1 | ||
mount -t overlay overlay -o lowerdir=./lower,upperdir=./upper1,workdir=./work1 ./merged1 | mount -t overlay overlay -o lowerdir=./lower,upperdir=./upper1,workdir=./work1 ./merged1 | ||
− | mount -t overlay overlay -o lowerdir=./lower,upperdir=./upper2,workdir=./work2 | + | mount -t overlay overlay -o lowerdir=./lower,upperdir=./upper2,workdir=./work2 ./merged2 |
</source> | </source> | ||
+ | =Multiple lower directory example= | ||
+ | <source lang=bash> | ||
+ | #/usr/bin/env bash | ||
+ | mkdir lower # Common fs | ||
+ | mkdir lower1-1 lower1-2 lower1-3 | ||
+ | mkdir upper1 work1 merged1 # Instance 1 fs | ||
+ | mkdir upper2 work2 merged2 # Instance 2 fs | ||
+ | |||
+ | # Populate | ||
+ | touch lower/lib1 lower/lib2 lower1-1/lib1-1 lower1-2/lib1-2 lower1-3/lib1-3 upper1/file1-1 upper1/file1-2 upper2/file2-1 | ||
+ | |||
+ | mount -t overlay overlay -o lowerdir=./lower,upperdir=./upper1,workdir=./work1 ./merged1 | ||
+ | mount -t overlay overlay -o lowerdir=./lower,upperdir=./upper2,workdir=./work2 ./merged2 | ||
+ | </source> | ||
+ | |||
=Links= | =Links= | ||
*[https://www.kernel.org/doc/html/latest/filesystems/overlayfs.html The Linux Kernel Documentation - Overlay Filesystem] | *[https://www.kernel.org/doc/html/latest/filesystems/overlayfs.html The Linux Kernel Documentation - Overlay Filesystem] |
Latest revision as of 06:31, 20 September 2024
Single lower directory example
#/usr/bin/env bash
mkdir lower # Common fs
mkdir upper1 work1 merged1 # Instance 1 fs
mkdir upper2 work2 merged2 # Instance 2 fs
# Populate
touch lower/lib1 lower/lib2 upper1/file1-1 upper1/file1-2 upper2/file2-1
mount -t overlay overlay -o lowerdir=./lower,upperdir=./upper1,workdir=./work1 ./merged1
mount -t overlay overlay -o lowerdir=./lower,upperdir=./upper2,workdir=./work2 ./merged2
Multiple lower directory example
#/usr/bin/env bash
mkdir lower # Common fs
mkdir lower1-1 lower1-2 lower1-3
mkdir upper1 work1 merged1 # Instance 1 fs
mkdir upper2 work2 merged2 # Instance 2 fs
# Populate
touch lower/lib1 lower/lib2 lower1-1/lib1-1 lower1-2/lib1-2 lower1-3/lib1-3 upper1/file1-1 upper1/file1-2 upper2/file2-1
mount -t overlay overlay -o lowerdir=./lower,upperdir=./upper1,workdir=./work1 ./merged1
mount -t overlay overlay -o lowerdir=./lower,upperdir=./upper2,workdir=./work2 ./merged2