Difference between revisions of "Overlay file system linux"
From Teknologisk videncenter
m (→Links) |
m |
||
(5 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
+ | =Single lower directory example= | ||
+ | <source lang=bash> | ||
+ | #/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 | ||
+ | </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://ops.tips/notes/practical-look-into-overlayfs/ Pratical look into overlay fs] | *[https://ops.tips/notes/practical-look-into-overlayfs/ Pratical look into overlay fs] | ||
*https://www.grant.pizza/blog/overlayfs/ | *https://www.grant.pizza/blog/overlayfs/ | ||
[[Category:Linux]] | [[Category:Linux]] |
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