{"id":406,"date":"2019-08-20T15:49:48","date_gmt":"2019-08-20T05:49:48","guid":{"rendered":"https:\/\/blog.hegars.com\/?p=406"},"modified":"2025-04-21T19:27:55","modified_gmt":"2025-04-21T09:27:55","slug":"aufs","status":"publish","type":"post","link":"https:\/\/blog.hegars.com\/?p=406","title":{"rendered":"Mounting immutable file-system with AUFS or OverlayFS"},"content":{"rendered":"\n<p>I needed a way of mounting a md-raid set readonly but needed the ability to change permissions without affecting the original disks<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Methods<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Issues<\/h3>\n\n\n\n<p>copy_up operation <br>overlay2 needs kernel 4+<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">AUFS <\/h3>\n\n\n\n<p><a href=\"https:\/\/www.thegeekstuff.com\/2013\/05\/linux-aufs\/\">https:\/\/www.thegeekstuff.com\/2013\/05\/linux-aufs\/<br><\/a><a href=\"https:\/\/packages.debian.org\/search?keywords=fsprotect\">https:\/\/packages.debian.org\/search?keywords=fsprotect<\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">OverlayFS<\/h3>\n\n\n\n<p><a href=\"https:\/\/docs.docker.com\/storage\/storagedriver\/overlayfs-driver\/\">https:\/\/docs.docker.com\/storage\/storagedriver\/overlayfs-driver\/<\/a><br><a href=\"https:\/\/blog.programster.org\/overlayfs\">https:\/\/blog.programster.org\/overlayfs<\/a> <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Procedure <\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Prepping the Images<\/h3>\n\n\n\n<p><strong>Install the required package<br><\/strong># apt-get install aufs-tools<br># apt-get install fuse-overlayfs  <br><br><strong>Make the directories for the test<br><\/strong># mkdir \/mnt\/diskro<br># mkdir \/mnt\/diskram<br># mkdir \/mnt\/diskcombi<br><br><strong>Create an image file for use as a read-only source<\/strong><br># dd if=\/dev\/zero of=\/root\/disk.img bs=512 count=2024000<br># mkfs.ext4 \/root\/disk.img<br><br><strong>Mount RO image and copy some files to the drive and remount as RO<br><\/strong># mount \/root\/disk.img \/mnt\/diskro<br># cp &#8211; R something \/mnt\/diskro<br># mount -o remount,ro \/root\/disk.img \/mnt\/diskro<br><br><strong>Create a temp file system on ram<br><\/strong># mount -t tmpfs -o size=1G none \/mnt\/diskram<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Mounting the images using different methods.<\/h3>\n\n\n\n<p><strong>Using AUFS to<\/strong> <strong>mount the RO file system with the RAM drive for writes.<br><\/strong># mount -t aufs -o br:\/mnt\/diskram\/:\/mnt\/diskro\/=ro none \/mnt\/diskcombi\/  <\/p>\n\n\n\n<p><strong>Using OverlayFS to mount as above<br><\/strong># mount -t overlay -o lowerdir=\/mnt\/diskro,upperdir=\/mnt\/diskram\/upperdir,workdir=\/mnt\/diskram\/workdir none \/mnt\/diskcombi<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I needed a way of mounting a md-raid set readonly but needed the ability to change permissions without affecting the original disks Methods Issues copy_up operation overlay2 needs kernel 4+ AUFS https:\/\/www.thegeekstuff.com\/2013\/05\/linux-aufs\/https:\/\/packages.debian.org\/search?keywords=fsprotect OverlayFS https:\/\/docs.docker.com\/storage\/storagedriver\/overlayfs-driver\/https:\/\/blog.programster.org\/overlayfs Procedure Prepping the Images Install the required package# apt-get install aufs-tools# apt-get install fuse-overlayfs Make the directories for the test# mkdir [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"site-container-style":"default","site-container-layout":"default","site-sidebar-layout":"default","disable-article-header":"default","disable-site-header":"default","disable-site-footer":"default","disable-content-area-spacing":"default","footnotes":""},"categories":[6],"tags":[],"_links":{"self":[{"href":"https:\/\/blog.hegars.com\/index.php?rest_route=\/wp\/v2\/posts\/406"}],"collection":[{"href":"https:\/\/blog.hegars.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.hegars.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.hegars.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.hegars.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=406"}],"version-history":[{"count":23,"href":"https:\/\/blog.hegars.com\/index.php?rest_route=\/wp\/v2\/posts\/406\/revisions"}],"predecessor-version":[{"id":2609,"href":"https:\/\/blog.hegars.com\/index.php?rest_route=\/wp\/v2\/posts\/406\/revisions\/2609"}],"wp:attachment":[{"href":"https:\/\/blog.hegars.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=406"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.hegars.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=406"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.hegars.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=406"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}