{"id":968,"date":"2011-05-05T19:14:37","date_gmt":"2011-05-05T13:44:37","guid":{"rendered":"http:\/\/judepereira.com\/blog\/?p=968"},"modified":"2011-05-05T19:21:46","modified_gmt":"2011-05-05T13:51:46","slug":"creating-unique-environments-chroot-snapshots-using-aufs2","status":"publish","type":"post","link":"https:\/\/judepereira.com\/blog\/creating-unique-environments-chroot-snapshots-using-aufs2\/","title":{"rendered":"creating unique environments &#8211; chroot snapshots &#8211;  using aufs2"},"content":{"rendered":"<p>What if you decided that you wanted to experiment and test within a chroot(ed) environment? And then something went wrong and you had to start all over again from scratch?  Big headache, too much pain, especially with RPM based distributions.<\/p>\n<p>Well don&#8217;t do that then, here&#8217;s an interesting approach. Use aufs2, a stackable filesystem. An actual filesystem with &#8220;<em>RAID-like<\/em>&#8221; support.<\/p>\n<p><a rel=\"attachment\" href=\"https:\/\/i0.wp.com\/judepereira.com\/blog\/wp-content\/uploads\/layers.gif\" class=\"highslide-image\" onclick=\"return hs.expand(this);\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"size-full\" title=\"chroot layers, using aufs2\" src=\"https:\/\/i0.wp.com\/judepereira.com\/blog\/wp-content\/uploads\/layers.gif?resize=279%2C266\" alt=\"chroot layers, using aufs2\" width=\"279\" height=\"266\" \/><\/a><\/p>\n<blockquote><p>You can inherit different environmental settings from various bases, much like the concept of object oriented programming.<\/p>\n<p><em><strong>Aufs is a stackable unification filesystem such as Unionfs, which unifies several directories and provides a merged single directory.<\/strong><\/em><em>(from <a href=\"http:\/\/aufs.sourceforge.net\/\">http:\/\/aufs.sourceforge.net\/<\/a>)<\/em><\/p><\/blockquote>\n<p>Setup aufs2. You need to patch your kernel. For gentoo, you can just merge sys-fs\/aufs2 with the following flags: &#8220;fuse inotify kernel-patch kernel_linux ramfs -debug -hardened -hfs -nfs&#8221;. The patch will be automatically applied, you just need to recompile it after merging. For other distributions, take a look at the homepage of <a href=\"http:\/\/aufs.sourceforge.net\/\">aufs2<\/a>.<\/p>\n<p>Setup your chroot as you normally do. Let&#8217;s say you&#8217;ve setup centos in a chroot environment, for developing. You&#8217;ve done yum groupinsall &#8220;Development Libraries&#8221; &#8220;Development Tools&#8221;. Let&#8217;s create a snapshot here of this environment.<br \/>\n[sourcecode lang=bash]<br \/>\n# mkdir env1<br \/>\n# mount -t aufs -o br=\/home\/jude\/env1\/:\/home\/jude\/centos-dev=ro none wor<br \/>\nk-dir<br \/>\n# chroot work-dir<br \/>\n[\/sourcecode]<br \/>\n&nbsp;<br \/>\nWhat does this do? As you can see, your first centos-dev has been branched as RO, <em>read-only<\/em>. Which means, any changes now made, are transparently written into env1 directory, with the very same structuring. Say, you&#8217;ve structured env1 as you want it to be, now you need a second environment, based on the first env1, you can simple do:<br \/>\n[sourcecode lang=bash]<br \/>\n# mkdir env2<br \/>\n# mount -t aufs -o br=\/home\/jude\/env2\/:\/home\/jude\/env1\/=ro:\/home\/jude\/ce<br \/>\nntos-dev=ro none work-dir<br \/>\n# chroot work-dir<br \/>\n[\/sourcecode]<br \/>\n&nbsp;<br \/>\nNow, env1 is RO, any changes now are further written to env2, keeping the structuring of every little change intact, just as the first. If you want to suddenly use env1, don&#8217;t add env2 to the RW branch, any branch that doesn&#8217;t have anything in front of it, is assumed to be RW, <em>read-write<\/em>.<\/p>\n<p>What happens when you delete a file\/directory from a branch mounted as RO? A file called .wh.filename is created in the RW branch, indicating to the overlaying filesystem to <strong>NOT<\/strong> index that file anymore.<\/p>\n<p>In this way, you could create several different environments, each being inheriting a base, and then depending on the needs, the other environments created.<\/p>\n<p><strong><em><small>You can comment if you get any errors, I&#8217;d be glad to help you out.<\/small><\/em><\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>What if you decided that you wanted to experiment and test within a chroot(ed) environment? And then something went wrong and you had to start all over again from scratch? Big headache, too much pain, especially with RPM based distributions. Well don&#8217;t do that then, here&#8217;s an interesting approach. Use aufs2, a stackable filesystem. An [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[11,10],"tags":[209,211,210,217,220,219,221,214,215,218,226,212,213,222,224,225,223,216],"class_list":["post-968","post","type-post","status-publish","format-standard","hentry","category-gen-sab-fed","category-linux","tag-aufs","tag-aufs-usage","tag-aufs2","tag-chroot","tag-chroot-dev","tag-chroot-devel","tag-chroot-developer","tag-chroot-different-env","tag-chroot-environment","tag-chroot-linux","tag-chroot-rpm-dev","tag-chroot-secure","tag-chroot-snapshot","tag-chroot-testing","tag-chroot-unstable","tag-chroot-user","tag-chroot-work","tag-config-environment"],"aioseo_notices":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/pqtyx-fC","jetpack-related-posts":[{"id":893,"url":"https:\/\/judepereira.com\/blog\/coloured-varlogmessages-at-tty12\/","url_meta":{"origin":968,"position":0},"title":"Coloured \/var\/log\/messages at tty12","author":"Jude Pereira","date":"April 26, 2011","format":false,"excerpt":"Reading logs could never become any more easier, at just a keystroke, you have your logs displayed where you want, in some fancy colour. They look great too. TTY's can be accessed by pressing Alt + Ctrl + F[1 - 12] simultaneously. In the following, you'll get a decent, colourized\u2026","rel":"","context":"In &quot;another snippet | code&quot;","block_context":{"text":"another snippet | code","link":"https:\/\/judepereira.com\/blog\/category\/code\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":694,"url":"https:\/\/judepereira.com\/blog\/visual-basic-6-revisited-linux-wine\/","url_meta":{"origin":968,"position":1},"title":"visual basic 6 revisited &#8211; linux &#8211; wine","author":"Jude Pereira","date":"August 5, 2010","format":false,"excerpt":"Earlier this year, I had written an article on running Visual Basic 6 on linux under wine, this is an update for it, the prior one is deprecated Getting Visual Basic 6 to work on linux is pretty easy, not much trouble, all the basic things work, as of what\u2026","rel":"","context":"In &quot;another snippet | code&quot;","block_context":{"text":"another snippet | code","link":"https:\/\/judepereira.com\/blog\/category\/code\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":289,"url":"https:\/\/judepereira.com\/blog\/sabayon-four-oh\/","url_meta":{"origin":968,"position":2},"title":"Sabayon fOuR oH","author":"Jude Pereira","date":"June 16, 2009","format":false,"excerpt":"Based on Gentoo, Sabayon 4.1, tells me: Great performance with less RAM(though you need like 1GB RAM for it to work well enough). Package Management System is absolutely fantastic, with it's new \"Entropy\". Totally the perfect distribution. A fine distribution for the newbie or the expert. This is what a\u2026","rel":"","context":"In &quot;gnu linux&quot;","block_context":{"text":"gnu linux","link":"https:\/\/judepereira.com\/blog\/category\/linux\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":64,"url":"https:\/\/judepereira.com\/blog\/faunos-shadow\/","url_meta":{"origin":968,"position":3},"title":"FaunOS Shadow","author":"Jude Pereira","date":"January 20, 2009","format":false,"excerpt":"It's a distribution based totally on Arch Linux... specialized for USB Portable installs and can also be used as primary OS has over 600 packages pre-installed (I know... it reminds you of Fedora and me too!). So that's to say that it comes with definitely all the packages you would\u2026","rel":"","context":"In &quot;gnu linux&quot;","block_context":{"text":"gnu linux","link":"https:\/\/judepereira.com\/blog\/category\/linux\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":2126,"url":"https:\/\/judepereira.com\/blog\/upgrading-to-debian-bookworm-on-qnap-ts-112-also-ts-11x-ts-12x\/","url_meta":{"origin":968,"position":4},"title":"Upgrading to Debian Bookworm on QNAP TS-112 (also TS-11x\/TS-12x)","author":"Jude Pereira","date":"October 16, 2024","format":false,"excerpt":"I decided to host Minio on a QNAP TS-112 device, bought from a second hand store. Here's a tale of me ditching the QNAP OS in favour of Debian Bookworm.","rel":"","context":"In &quot;gnu linux&quot;","block_context":{"text":"gnu linux","link":"https:\/\/judepereira.com\/blog\/category\/linux\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1855,"url":"https:\/\/judepereira.com\/blog\/nginx-ingress-helm-k8s-rbac\/","url_meta":{"origin":968,"position":5},"title":"Installing the Nginx Ingress Controller via Helm to a K8s cluster with RBAC enabled","author":"Jude Pereira","date":"October 1, 2018","format":false,"excerpt":"A lot of posts describe how to do this, but are fairly outdated, and do not mention the last supported K8s version. Here's a tried and tested way to do so via Helm. This has been tested on GKE, with the Kubernetes master version\u00a01.9.7-gke.6: Create the service account for Tiller\u2026","rel":"","context":"In &quot;another snippet | code&quot;","block_context":{"text":"another snippet | code","link":"https:\/\/judepereira.com\/blog\/category\/code\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/judepereira.com\/blog\/wp-json\/wp\/v2\/posts\/968","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/judepereira.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/judepereira.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/judepereira.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/judepereira.com\/blog\/wp-json\/wp\/v2\/comments?post=968"}],"version-history":[{"count":35,"href":"https:\/\/judepereira.com\/blog\/wp-json\/wp\/v2\/posts\/968\/revisions"}],"predecessor-version":[{"id":1004,"href":"https:\/\/judepereira.com\/blog\/wp-json\/wp\/v2\/posts\/968\/revisions\/1004"}],"wp:attachment":[{"href":"https:\/\/judepereira.com\/blog\/wp-json\/wp\/v2\/media?parent=968"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/judepereira.com\/blog\/wp-json\/wp\/v2\/categories?post=968"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/judepereira.com\/blog\/wp-json\/wp\/v2\/tags?post=968"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}