{"title":"ivxvm.github.io","link":[{"@attributes":{"href":"https:\/\/ivxvm.github.io\/atom.xml","rel":"self","type":"application\/atom+xml"}},{"@attributes":{"href":"https:\/\/ivxvm.github.io"}}],"generator":"Zola","updated":"2026-11-04T00:00:00+00:00","id":"https:\/\/ivxvm.github.io\/atom.xml","entry":[{"title":"Clearnet netns","published":"2026-11-04T00:00:00+00:00","updated":"2026-11-04T00:00:00+00:00","link":[{"@attributes":{"href":"https:\/\/ivxvm.github.io\/clearnet-netns\/"}},{"@attributes":{"rel":"alternate","href":"https:\/\/ivxvm.github.io\/clearnet-netns\/","type":"text\/html"}}],"id":"https:\/\/ivxvm.github.io\/clearnet-netns\/","content":"<p>When using VPNs I often find myself willing to have a simple escape hatch that I can use at any moment to route certain specific traffic through normal clearnet connection. Fortunately, Linux has especially nice tools for this. My personal favorite at the moment is network namespaces (netns).<\/p>\n<p>Lets say my internet goes through <code>eno1<\/code> (ethernet) and VPN is <code>wg-CH-123<\/code> (wireguard connection managed by <code>wg-quick<\/code> service). I want website tabs in my browser to route through VPN by default, but I also want to be able to open specific new tabs going through clearnet, I also want to route torrents through clearnet.<\/p>\n<p>Another important concern here is that even though for now it might only be a few apps that I want to tunnel outside of VPN, it is possible that in future I might want to add more. Working with per-app workarounds would not be the best solution, it's much more promising to find a way to put arbitrary apps under a single umbrella such that this split tunneling setup scales for any number of apps later. Fortunately, in Linux there is a thing called \"network namespaces\" which allows to achieve this.<\/p>\n<p>There are many alternative setups with network namespaces. For example, it's possible to create network namespace that only knows about ethernet connection and isn't aware of wireguard at all. In this case traffic originating from network namespace will go through ethernet even in presence of active wireguard. This kind of netns would be the one linked to host network via something called macvlan. It's probably the most simple approach for basic usecases, but it has a downside: it complicates connections originating from host and going into namespace.<\/p>\n<p>In my setup in addition to torrent app I also want to run tinyproxy inside netns to use it in browser to route only specific browser tabs through clearnet. For usecases where connection from host into netns to specific port is needed, there exists another netns link type which is called veth - a bridge consisting of two veth links is created: one on the host side and another inside of ns. Through this bridge traffic is routed between netns and host network. There is an important caveat however: with macvlan, netns traffic completely ignores any routing rules existing in host network, while veth traffic will go through the whole host routing chain.<\/p>\n<p>When using wireguard with wg-quick, host network will get a bunch of routing rules that redirect all traffic through wg connection excluding packets marked with fwmark flag. Which means that with veth (as opposed to macvlan), traffic coming from netns will be affected as well. This is why in this scenario additional routing rule has to be created to automark all packets originating from netns with fwmark, so that they bypass wg connection.<\/p>\n<h1 id=\"example-setup\">Example setup<a class=\"zola-anchor\" href=\"#example-setup\" aria-label=\"Anchor link for: example-setup\"><i class=\"fas fa-link\"><\/i><\/a> \n<\/h1>\n<p>Keep in mind that network namespaces and nftables don't survive reboot on their own, so if you want automatic setup, you need to execute this code from a service (easy to do with systemd, openrc, and probably any other init system).<\/p>\n<pre class=\"giallo\" style=\"color: #E0DEF4; background-color: #191724;\" ><code data-lang=\"shellscript\"><span class=\"giallo-l\"><span style=\"font-style: italic;\">NS<\/span><span style=\"color: #EB6F92;\">=<\/span><span style=\"color: #F6C177;\">&quot;<\/span><span style=\"color: #9CCFD8;\">clearnet<\/span><span style=\"color: #F6C177;\">&quot;<\/span><\/span>\n<span class=\"giallo-l\"><span style=\"font-style: italic;\">UPLINK<\/span><span style=\"color: #EB6F92;\">=<\/span><span style=\"color: #F6C177;\">&quot;<\/span><span style=\"color: #9CCFD8;\">eno1<\/span><span style=\"color: #F6C177;\">&quot;<\/span><span style=\"color: #6E6A86;font-style: italic;\"> # network interface for clearnet traffic, ethernet in this case<\/span><\/span>\n<span class=\"giallo-l\"><span style=\"font-style: italic;\">CLEARNET_DNS<\/span><span style=\"color: #EB6F92;\">=<\/span><span style=\"color: #F6C177;\">&quot;<\/span><span style=\"color: #9CCFD8;\">9.9.9.9<\/span><span style=\"color: #F6C177;\">&quot;<\/span><span style=\"color: #6E6A86;font-style: italic;\"> # you may want to use DNS of your ISP instead<\/span><\/span>\n<span class=\"giallo-l\"><span style=\"font-style: italic;\">SUBNET<\/span><span style=\"color: #EB6F92;\">=<\/span><span style=\"color: #F6C177;\">&quot;<\/span><span style=\"color: #9CCFD8;\">10.200.0.0\/24<\/span><span style=\"color: #F6C177;\">&quot;<\/span><\/span>\n<span class=\"giallo-l\"><\/span>\n<span class=\"giallo-l\"><span style=\"font-style: italic;\">VETH_HOST<\/span><span style=\"color: #EB6F92;\">=<\/span><span style=\"color: #F6C177;\">&quot;<\/span><span style=\"color: #9CCFD8;\">veth-cn-host<\/span><span style=\"color: #F6C177;\">&quot;<\/span><\/span>\n<span class=\"giallo-l\"><span style=\"font-style: italic;\">VETH_NS<\/span><span style=\"color: #EB6F92;\">=<\/span><span style=\"color: #F6C177;\">&quot;<\/span><span style=\"color: #9CCFD8;\">veth-cn-ns<\/span><span style=\"color: #F6C177;\">&quot;<\/span><\/span>\n<span class=\"giallo-l\"><\/span>\n<span class=\"giallo-l\"><span style=\"font-style: italic;\">MARK<\/span><span style=\"color: #EB6F92;\">=<\/span><span style=\"color: #F6C177;\">&quot;<\/span><span style=\"color: #9CCFD8;\">0xca6c<\/span><span style=\"color: #F6C177;\">&quot;<\/span><\/span>\n<span class=\"giallo-l\"><\/span>\n<span class=\"giallo-l\"><span style=\"color: #6E6A86;font-style: italic;\"># forwarded ports for apps like torrents, tor, etc<\/span><\/span>\n<span class=\"giallo-l\"><span style=\"color: #6E6A86;font-style: italic;\"># you may add more and then add corresponding rules to nftables<\/span><\/span>\n<span class=\"giallo-l\"><span style=\"font-style: italic;\">FWD_PORT_1<\/span><span style=\"color: #EB6F92;\">=<\/span><span style=\"color: #F6C177;\">&quot;<\/span><span style=\"color: #9CCFD8;\">9001<\/span><span style=\"color: #F6C177;\">&quot;<\/span><\/span>\n<span class=\"giallo-l\"><span style=\"font-style: italic;\">FWD_PORT_2<\/span><span style=\"color: #EB6F92;\">=<\/span><span style=\"color: #F6C177;\">&quot;<\/span><span style=\"color: #9CCFD8;\">32854<\/span><span style=\"color: #F6C177;\">&quot;<\/span><\/span>\n<span class=\"giallo-l\"><\/span>\n<span class=\"giallo-l\"><span style=\"color: #6E6A86;font-style: italic;\">### Create netns<\/span><\/span>\n<span class=\"giallo-l\"><\/span>\n<span class=\"giallo-l\"><span style=\"color: #C4A7E7;\">ip<\/span><span style=\"color: #9CCFD8;\"> netns add<\/span><span style=\"color: #6E6A86;\"> ${<\/span><span style=\"font-style: italic;\">NS<\/span><span style=\"color: #6E6A86;\">}<\/span><span style=\"color: #EB6F92;\"> || return<\/span><span style=\"color: #EBBCBA;\"> 1<\/span><\/span>\n<span class=\"giallo-l\"><span style=\"color: #C4A7E7;\">ip<\/span><span style=\"color: #9CCFD8;\"> link add<\/span><span style=\"color: #6E6A86;\"> ${<\/span><span style=\"font-style: italic;\">VETH_HOST<\/span><span style=\"color: #6E6A86;\">}<\/span><span style=\"color: #9CCFD8;\"> type veth peer name<\/span><span style=\"color: #6E6A86;\"> ${<\/span><span style=\"font-style: italic;\">VETH_NS<\/span><span style=\"color: #6E6A86;\">}<\/span><\/span>\n<span class=\"giallo-l\"><span style=\"color: #C4A7E7;\">ip<\/span><span style=\"color: #9CCFD8;\"> link set<\/span><span style=\"color: #6E6A86;\"> ${<\/span><span style=\"font-style: italic;\">VETH_NS<\/span><span style=\"color: #6E6A86;\">}<\/span><span style=\"color: #9CCFD8;\"> netns<\/span><span style=\"color: #6E6A86;\"> ${<\/span><span style=\"font-style: italic;\">NS<\/span><span style=\"color: #6E6A86;\">}<\/span><\/span>\n<span class=\"giallo-l\"><\/span>\n<span class=\"giallo-l\"><span style=\"color: #C4A7E7;\">ip<\/span><span style=\"color: #9CCFD8;\"> addr add 10.200.0.1\/24 dev<\/span><span style=\"color: #6E6A86;\"> ${<\/span><span style=\"font-style: italic;\">VETH_HOST<\/span><span style=\"color: #6E6A86;\">}<\/span><\/span>\n<span class=\"giallo-l\"><span style=\"color: #C4A7E7;\">ip<\/span><span style=\"color: #9CCFD8;\"> link set<\/span><span style=\"color: #6E6A86;\"> ${<\/span><span style=\"font-style: italic;\">VETH_HOST<\/span><span style=\"color: #6E6A86;\">}<\/span><span style=\"color: #9CCFD8;\"> up<\/span><\/span>\n<span class=\"giallo-l\"><span style=\"color: #C4A7E7;\">ip<\/span><span style=\"color: #EBBCBA;\"> -n<\/span><span style=\"color: #6E6A86;\"> ${<\/span><span style=\"font-style: italic;\">NS<\/span><span style=\"color: #6E6A86;\">}<\/span><span style=\"color: #9CCFD8;\"> addr add 10.200.0.2\/24 dev<\/span><span style=\"color: #6E6A86;\"> ${<\/span><span style=\"font-style: italic;\">VETH_NS<\/span><span style=\"color: #6E6A86;\">}<\/span><\/span>\n<span class=\"giallo-l\"><span style=\"color: #C4A7E7;\">ip<\/span><span style=\"color: #EBBCBA;\"> -n<\/span><span style=\"color: #6E6A86;\"> ${<\/span><span style=\"font-style: italic;\">NS<\/span><span style=\"color: #6E6A86;\">}<\/span><span style=\"color: #9CCFD8;\"> link set<\/span><span style=\"color: #6E6A86;\"> ${<\/span><span style=\"font-style: italic;\">VETH_NS<\/span><span style=\"color: #6E6A86;\">}<\/span><span style=\"color: #9CCFD8;\"> up<\/span><\/span>\n<span class=\"giallo-l\"><span style=\"color: #C4A7E7;\">ip<\/span><span style=\"color: #EBBCBA;\"> -n<\/span><span style=\"color: #6E6A86;\"> ${<\/span><span style=\"font-style: italic;\">NS<\/span><span style=\"color: #6E6A86;\">}<\/span><span style=\"color: #9CCFD8;\"> link set lo up<\/span><\/span>\n<span class=\"giallo-l\"><span style=\"color: #C4A7E7;\">ip<\/span><span style=\"color: #EBBCBA;\"> -n<\/span><span style=\"color: #6E6A86;\"> ${<\/span><span style=\"font-style: italic;\">NS<\/span><span style=\"color: #6E6A86;\">}<\/span><span style=\"color: #9CCFD8;\"> route add default via<\/span><span style=\"color: #EBBCBA;\"> 10.200.0.1<\/span><\/span>\n<span class=\"giallo-l\"><\/span>\n<span class=\"giallo-l\"><span style=\"color: #6E6A86;font-style: italic;\">### Configure routing (nftables)<\/span><\/span>\n<span class=\"giallo-l\"><\/span>\n<span class=\"giallo-l\"><span style=\"color: #C4A7E7;\">sysctl<\/span><span style=\"color: #EBBCBA;\"> -qw<\/span><span style=\"color: #9CCFD8;\"> net.ipv4.ip_forward=<\/span><span style=\"color: #EBBCBA;\">1<\/span><\/span>\n<span class=\"giallo-l\"><\/span>\n<span class=\"giallo-l\"><span style=\"color: #C4A7E7;\">nft<\/span><span style=\"color: #9CCFD8;\"> delete table ip clearnet<\/span><span style=\"color: #EB6F92;\"> 2&gt;<\/span><span style=\"color: #9CCFD8;\">\/dev\/null<\/span><\/span>\n<span class=\"giallo-l\"><span style=\"color: #C4A7E7;\">nft<\/span><span style=\"color: #EBBCBA;\"> -f<\/span><span style=\"color: #9CCFD8;\"> -<\/span><span style=\"color: #EB6F92;\"> &lt;&lt;<\/span><span style=\"color: #F6C177;\">EOF<\/span><\/span>\n<span class=\"giallo-l\"><span style=\"color: #9CCFD8;\">table ip clearnet {<\/span><\/span>\n<span class=\"giallo-l\"><span style=\"color: #9CCFD8;\">    chain pre {<\/span><\/span>\n<span class=\"giallo-l\"><span style=\"color: #9CCFD8;\">        type filter hook prerouting priority -149; policy accept;<\/span><\/span>\n<span class=\"giallo-l\"><span style=\"color: #9CCFD8;\">        iifname &quot;<\/span><span style=\"color: #6E6A86;\">${<\/span><span style=\"font-style: italic;\">VETH_HOST<\/span><span style=\"color: #6E6A86;\">}<\/span><span style=\"color: #9CCFD8;\">&quot; meta mark set <\/span><span style=\"color: #6E6A86;\">${<\/span><span style=\"font-style: italic;\">MARK<\/span><span style=\"color: #6E6A86;\">}<\/span><\/span>\n<span class=\"giallo-l\"><span style=\"color: #9CCFD8;\">    }<\/span><\/span>\n<span class=\"giallo-l\"><span style=\"color: #9CCFD8;\">    chain portfwd {<\/span><\/span>\n<span class=\"giallo-l\"><span style=\"color: #9CCFD8;\">        type nat hook prerouting priority dstnat; policy accept;        <\/span><\/span>\n<span class=\"giallo-l\"><span style=\"color: #9CCFD8;\">        # forwarded ports, add new constants and rules when needed<\/span><\/span>\n<span class=\"giallo-l\"><span style=\"color: #9CCFD8;\">        iifname &quot;<\/span><span style=\"color: #6E6A86;\">${<\/span><span style=\"font-style: italic;\">UPLINK<\/span><span style=\"color: #6E6A86;\">}<\/span><span style=\"color: #9CCFD8;\">&quot; tcp dport <\/span><span style=\"color: #6E6A86;\">${<\/span><span style=\"font-style: italic;\">FWD_PORT_1<\/span><span style=\"color: #6E6A86;\">}<\/span><span style=\"color: #9CCFD8;\"> dnat to 10.200.0.2:<\/span><span style=\"color: #6E6A86;\">${<\/span><span style=\"font-style: italic;\">FWD_PORT_1<\/span><span style=\"color: #6E6A86;\">}<\/span><\/span>\n<span class=\"giallo-l\"><span style=\"color: #9CCFD8;\">        iifname &quot;<\/span><span style=\"color: #6E6A86;\">${<\/span><span style=\"font-style: italic;\">UPLINK<\/span><span style=\"color: #6E6A86;\">}<\/span><span style=\"color: #9CCFD8;\">&quot; tcp dport <\/span><span style=\"color: #6E6A86;\">${<\/span><span style=\"font-style: italic;\">FWD_PORT_2<\/span><span style=\"color: #6E6A86;\">}<\/span><span style=\"color: #9CCFD8;\"> dnat to 10.200.0.2:<\/span><span style=\"color: #6E6A86;\">${<\/span><span style=\"font-style: italic;\">FWD_PORT_2<\/span><span style=\"color: #6E6A86;\">}<\/span><span style=\"color: #9CCFD8;\">        <\/span><\/span>\n<span class=\"giallo-l\"><span style=\"color: #9CCFD8;\">        # force dns requests go through clearnet dns<\/span><\/span>\n<span class=\"giallo-l\"><span style=\"color: #9CCFD8;\">        iifname &quot;<\/span><span style=\"color: #6E6A86;\">${<\/span><span style=\"font-style: italic;\">VETH_HOST<\/span><span style=\"color: #6E6A86;\">}<\/span><span style=\"color: #9CCFD8;\">&quot; ip daddr != <\/span><span style=\"color: #6E6A86;\">${<\/span><span style=\"font-style: italic;\">CLEARNET_DNS<\/span><span style=\"color: #6E6A86;\">}<\/span><span style=\"color: #9CCFD8;\"> udp dport 53 counter dnat to <\/span><span style=\"color: #6E6A86;\">${<\/span><span style=\"font-style: italic;\">CLEARNET_DNS<\/span><span style=\"color: #6E6A86;\">}<\/span><\/span>\n<span class=\"giallo-l\"><span style=\"color: #9CCFD8;\">        iifname &quot;<\/span><span style=\"color: #6E6A86;\">${<\/span><span style=\"font-style: italic;\">VETH_HOST<\/span><span style=\"color: #6E6A86;\">}<\/span><span style=\"color: #9CCFD8;\">&quot; ip daddr != <\/span><span style=\"color: #6E6A86;\">${<\/span><span style=\"font-style: italic;\">CLEARNET_DNS<\/span><span style=\"color: #6E6A86;\">}<\/span><span style=\"color: #9CCFD8;\"> tcp dport 53 counter dnat to <\/span><span style=\"color: #6E6A86;\">${<\/span><span style=\"font-style: italic;\">CLEARNET_DNS<\/span><span style=\"color: #6E6A86;\">}<\/span><\/span>\n<span class=\"giallo-l\"><span style=\"color: #9CCFD8;\">    }<\/span><\/span>\n<span class=\"giallo-l\"><span style=\"color: #9CCFD8;\">    chain post {<\/span><\/span>\n<span class=\"giallo-l\"><span style=\"color: #9CCFD8;\">        type nat hook postrouting priority 100; policy accept;<\/span><\/span>\n<span class=\"giallo-l\"><span style=\"color: #9CCFD8;\">        ip saddr <\/span><span style=\"color: #6E6A86;\">${<\/span><span style=\"font-style: italic;\">SUBNET<\/span><span style=\"color: #6E6A86;\">}<\/span><span style=\"color: #9CCFD8;\"> oifname != &quot;<\/span><span style=\"color: #6E6A86;\">${<\/span><span style=\"font-style: italic;\">VETH_HOST<\/span><span style=\"color: #6E6A86;\">}<\/span><span style=\"color: #9CCFD8;\">&quot; masquerade<\/span><\/span>\n<span class=\"giallo-l\"><span style=\"color: #9CCFD8;\">    }<\/span><\/span>\n<span class=\"giallo-l\"><span style=\"color: #9CCFD8;\">}<\/span><\/span>\n<span class=\"giallo-l\"><span style=\"color: #F6C177;\">EOF<\/span><\/span>\n<span class=\"giallo-l\"><\/span><\/code><\/pre><h1 id=\"example-usage\">Example usage<a class=\"zola-anchor\" href=\"#example-usage\" aria-label=\"Anchor link for: example-usage\"><i class=\"fas fa-link\"><\/i><\/a> \n<\/h1>\n<p>To run apps inside of clearnet netns:<\/p>\n<pre class=\"giallo\" style=\"color: #E0DEF4; background-color: #191724;\" ><code data-lang=\"shellscript\"><span class=\"giallo-l\"><span style=\"color: #C4A7E7;\">sudo<\/span><span style=\"color: #EBBCBA;\"> -E<\/span><span style=\"color: #9CCFD8;\"> ip netns exec vps-ns runuser<\/span><span style=\"color: #EBBCBA;\"> -u<\/span><span style=\"color: #9CCFD8;\"> ivxvm<\/span><span style=\"color: #EBBCBA;\"> --<\/span><span style=\"color: #9CCFD8;\"> flatpak run org.qbittorrent.qBittorrent<\/span><\/span><\/code><\/pre>\n<p>However this requires sudo which doesn't work well with usual userspace infrastructure like KDE autostarts and application launchers. It's possible to have a wrapper that works without sudo, but the setup is a bit more involved:<\/p>\n<pre class=\"giallo\" style=\"color: #E0DEF4; background-color: #191724;\" ><code data-lang=\"shellscript\"><span class=\"giallo-l\"><span style=\"color: #6E6A86;font-style: italic;\">#!\/bin\/sh<\/span><\/span>\n<span class=\"giallo-l\"><span style=\"color: #6E6A86;\">[<\/span><span style=\"color: #EB6F92;\"> -n<\/span><span style=\"color: #F6C177;\"> &quot;<\/span><span style=\"font-style: italic;\">$SUDO_USER<\/span><span style=\"color: #F6C177;\">&quot;<\/span><span style=\"color: #6E6A86;\"> ] &amp;&amp; [<\/span><span style=\"color: #F6C177;\"> &quot;<\/span><span style=\"font-style: italic;\">$SUDO_USER<\/span><span style=\"color: #F6C177;\">&quot;<\/span><span style=\"color: #EB6F92;\"> !=<\/span><span> root <\/span><span style=\"color: #6E6A86;\">]<\/span><span style=\"color: #EB6F92;\"> ||<\/span><span style=\"color: #6E6A86;\"> {<\/span><span style=\"color: #EB6F92;font-style: italic;\"> echo<\/span><span style=\"color: #F6C177;\"> &quot;<\/span><span style=\"color: #9CCFD8;\">run via sudo as a normal user<\/span><span style=\"color: #F6C177;\">&quot;<\/span><span style=\"color: #EB6F92;\"> &gt;&amp;2<\/span><span style=\"color: #6E6A86;\">;<\/span><span style=\"color: #EB6F92;font-style: italic;\"> exit<\/span><span style=\"color: #EBBCBA;\"> 1<\/span><span style=\"color: #6E6A86;\">; }<\/span><\/span>\n<span class=\"giallo-l\"><\/span>\n<span class=\"giallo-l\"><span style=\"font-style: italic;\">HOME_DIR<\/span><span style=\"color: #EB6F92;\">=<\/span><span style=\"color: #6E6A86;\">$(<\/span><span style=\"color: #C4A7E7;\">getent<\/span><span style=\"color: #9CCFD8;\"> passwd<\/span><span style=\"color: #F6C177;\"> &quot;<\/span><span style=\"font-style: italic;\">$SUDO_USER<\/span><span style=\"color: #F6C177;\">&quot;<\/span><span style=\"color: #EB6F92;\"> |<\/span><span style=\"color: #C4A7E7;\"> cut<\/span><span style=\"color: #EBBCBA;\"> -d: -f6<\/span><span style=\"color: #6E6A86;\">)<\/span><\/span>\n<span class=\"giallo-l\"><span style=\"color: #EB6F92;font-style: italic;\">exec<\/span><span style=\"color: #9CCFD8;\"> ip netns exec clearnet runuser<\/span><span style=\"color: #EBBCBA;\"> -u<\/span><span style=\"color: #F6C177;\"> &quot;<\/span><span style=\"font-style: italic;\">$SUDO_USER<\/span><span style=\"color: #F6C177;\">&quot;<\/span><span style=\"color: #EBBCBA;\"> -- \\<\/span><\/span>\n<span class=\"giallo-l\"><span style=\"color: #9CCFD8;\">  env HOME=<\/span><span style=\"color: #F6C177;\">&quot;<\/span><span style=\"font-style: italic;\">$HOME_DIR<\/span><span style=\"color: #F6C177;\">&quot;<\/span><span style=\"color: #9CCFD8;\"> USER=<\/span><span style=\"color: #F6C177;\">&quot;<\/span><span style=\"font-style: italic;\">$SUDO_USER<\/span><span style=\"color: #F6C177;\">&quot;<\/span><span style=\"color: #9CCFD8;\"> LOGNAME=<\/span><span style=\"color: #F6C177;\">&quot;<\/span><span style=\"font-style: italic;\">$SUDO_USER<\/span><span style=\"color: #F6C177;\">&quot; &quot;<\/span><span style=\"color: #C4A7E7;font-style: italic;\">$@<\/span><span style=\"color: #F6C177;\">&quot;<\/span><\/span>\n<span class=\"giallo-l\"><\/span>\n<span class=\"giallo-l\"><span style=\"color: #6E6A86;font-style: italic;\">## ^ \/usr\/local\/libexec\/clearnet-exec<\/span><\/span><\/code><\/pre><pre class=\"giallo\" style=\"color: #E0DEF4; background-color: #191724;\" ><code data-lang=\"shellscript\"><span class=\"giallo-l\"><span style=\"color: #C4A7E7;\">Defaults!\/usr\/local\/libexec\/clearnet-exec<\/span><span style=\"color: #9CCFD8;\"> env_keep+=<\/span><span style=\"color: #F6C177;\">&quot;<\/span><span style=\"color: #9CCFD8;\">DISPLAY WAYLAND_DISPLAY XAUTHORITY XDG_RUNTIME_DIR DBUS_SESSION_BUS_ADDRESS<\/span><span style=\"color: #F6C177;\">&quot;<\/span><\/span>\n<span class=\"giallo-l\"><span style=\"color: #C4A7E7;\">ivxvm<\/span><span style=\"color: #9CCFD8;\"> ALL=<\/span><span style=\"color: #6E6A86;\">(<\/span><span style=\"color: #C4A7E7;\">root<\/span><span style=\"color: #6E6A86;\">)<\/span><span style=\"color: #9CCFD8;\"> NOPASSWD: \/usr\/local\/libexec\/clearnet-exec<\/span><\/span>\n<span class=\"giallo-l\"><\/span>\n<span class=\"giallo-l\"><span style=\"color: #6E6A86;font-style: italic;\">## ^ \/etc\/sudoers.d\/clearnet<\/span><\/span><\/code><\/pre><pre class=\"giallo\" style=\"color: #E0DEF4; background-color: #191724;\" ><code data-lang=\"shellscript\"><span class=\"giallo-l\"><span style=\"color: #6E6A86;font-style: italic;\">#!\/bin\/sh<\/span><\/span>\n<span class=\"giallo-l\"><span style=\"color: #EB6F92;font-style: italic;\">exec<\/span><span style=\"color: #9CCFD8;\"> sudo \/usr\/local\/libexec\/clearnet-exec<\/span><span style=\"color: #F6C177;\"> &quot;<\/span><span style=\"color: #C4A7E7;font-style: italic;\">$@<\/span><span style=\"color: #F6C177;\">&quot;<\/span><\/span>\n<span class=\"giallo-l\"><\/span>\n<span class=\"giallo-l\"><span style=\"color: #6E6A86;font-style: italic;\">## ^ ~\/bin\/clearnet<\/span><\/span><\/code><\/pre>\n<p>With setup above you can do things like this, and you can put it into application launchers and autostarts:<\/p>\n<pre class=\"giallo\" style=\"color: #E0DEF4; background-color: #191724;\" ><code data-lang=\"shellscript\"><span class=\"giallo-l\"><span style=\"color: #C4A7E7;\">clearnet<\/span><span style=\"color: #9CCFD8;\"> flatpak run org.qbittorrent.qBittorrent<\/span><\/span><\/code><\/pre>\n<p>But don't forget to put <code>~\/bin<\/code> on your <code>PATH<\/code>.<\/p>\n<p>Some apps like qBittorrent, are capable of creating KDE autostart entry for themselves, by default it's configured as following:<\/p>\n<pre class=\"giallo\" style=\"color: #E0DEF4; background-color: #191724;\" ><code data-lang=\"shellscript\"><span class=\"giallo-l\"><span style=\"color: #6E6A86;font-style: italic;\"># Program:<\/span><\/span>\n<span class=\"giallo-l\"><span style=\"color: #C4A7E7;\">sh<\/span><\/span>\n<span class=\"giallo-l\"><span style=\"color: #6E6A86;font-style: italic;\"># Arguments:<\/span><\/span>\n<span class=\"giallo-l\"><span style=\"color: #C4A7E7;\">-c<\/span><span style=\"color: #F6C177;\"> &#39;<\/span><span style=\"color: #9CCFD8;\">date &gt;&gt; \/tmp\/qbt-autostart.log; flatpak run org.qbittorrent.qBittorrent &gt;&gt; \/tmp\/qbt-autostart.log 2&gt;&amp;1<\/span><span style=\"color: #F6C177;\">&#39;<\/span><\/span><\/code><\/pre>\n<p>To make it launch inside of clearnet netns, it's enough to modify it slightly:<\/p>\n<pre class=\"giallo\" style=\"color: #E0DEF4; background-color: #191724;\" ><code data-lang=\"shellscript\"><span class=\"giallo-l\"><span style=\"color: #6E6A86;font-style: italic;\"># Program:<\/span><\/span>\n<span class=\"giallo-l\"><span style=\"color: #C4A7E7;\">sh<\/span><\/span>\n<span class=\"giallo-l\"><span style=\"color: #6E6A86;font-style: italic;\"># Arguments:<\/span><\/span>\n<span class=\"giallo-l\"><span style=\"color: #C4A7E7;\">-c<\/span><span style=\"color: #F6C177;\"> &#39;<\/span><span style=\"color: #9CCFD8;\">sleep 5; date &gt;&gt; \/tmp\/qbt-autostart.log; \/home\/ivxvm\/bin\/clearnet flatpak run org.qbittorrent.qBittorrent &gt;&gt; \/tmp\/qbt-autostart.log 2&gt;&amp;1<\/span><span style=\"color: #F6C177;\">&#39;<\/span><\/span><\/code><\/pre>\n<p>Extra sleep is added to give netns script\/service some time to launch properly after boot.<\/p>\n<h1 id=\"clearnet-browser-tabs\">Clearnet browser tabs<a class=\"zola-anchor\" href=\"#clearnet-browser-tabs\" aria-label=\"Anchor link for: clearnet-browser-tabs\"><i class=\"fas fa-link\"><\/i><\/a> \n<\/h1>\n<p>I'll only cover Firefox here, but it's possible that similar technology exist for some other browsers.<\/p>\n<p>Firefox has container tabs which make all cookies and other data isolated from other containers and from non-containerized tabs. With <a rel=\"external\" href=\"https:\/\/addons.mozilla.org\/en-US\/firefox\/addon\/multi-account-containers\/\">Firefox Multi-Account Containers<\/a> plugin developed by Firefox itself, it's also possible to configure proxy per container. This is exactly how I route specific tabs through clearnet. Inside of clearnet netns I run tinyproxy with the following config:<\/p>\n<pre class=\"giallo\" style=\"color: #E0DEF4; background-color: #191724;\" ><code data-lang=\"shellscript\"><span class=\"giallo-l\"><span style=\"color: #C4A7E7;\">Port<\/span><span style=\"color: #EBBCBA;\"> 4321<\/span><\/span>\n<span class=\"giallo-l\"><span style=\"color: #C4A7E7;\">Listen<\/span><span style=\"color: #EBBCBA;\"> 10.200.0.2<\/span><\/span>\n<span class=\"giallo-l\"><span style=\"color: #C4A7E7;\">Allow<\/span><span style=\"color: #EBBCBA;\"> 10.200.0.1<\/span><\/span>\n<span class=\"giallo-l\"><span style=\"color: #C4A7E7;\">Timeout<\/span><span style=\"color: #EBBCBA;\"> 600<\/span><\/span>\n<span class=\"giallo-l\"><span style=\"color: #C4A7E7;\">MaxClients<\/span><span style=\"color: #EBBCBA;\"> 50<\/span><\/span>\n<span class=\"giallo-l\"><span style=\"color: #C4A7E7;\">PidFile<\/span><span style=\"color: #F6C177;\"> &quot;<\/span><span style=\"color: #9CCFD8;\">\/tmp\/tinyproxy-clearnet.pid<\/span><span style=\"color: #F6C177;\">&quot;<\/span><\/span>\n<span class=\"giallo-l\"><span style=\"color: #C4A7E7;\">LogFile<\/span><span style=\"color: #F6C177;\"> &quot;<\/span><span style=\"color: #9CCFD8;\">\/tmp\/tinyproxy-clearnet.log<\/span><span style=\"color: #F6C177;\">&quot;<\/span><\/span>\n<span class=\"giallo-l\"><\/span>\n<span class=\"giallo-l\"><span style=\"color: #6E6A86;font-style: italic;\">## ^ ~\/.config\/tinyproxy-clearnet.conf<\/span><\/span><\/code><\/pre>\n<p>I start tinyproxy on boot by using KDE Plasma autostart entry, sleep is just a bit of safety net to make sure service or script setting up clearnet netns itself runs first, so that clearnet network namespace is already available:<\/p>\n<pre class=\"giallo\" style=\"color: #E0DEF4; background-color: #191724;\" ><code data-lang=\"shellscript\"><span class=\"giallo-l\"><span style=\"color: #6E6A86;font-style: italic;\"># Program:<\/span><\/span>\n<span class=\"giallo-l\"><span style=\"color: #C4A7E7;\">sh<\/span><\/span>\n<span class=\"giallo-l\"><span style=\"color: #6E6A86;font-style: italic;\"># Arguments:<\/span><\/span>\n<span class=\"giallo-l\"><span style=\"color: #C4A7E7;\">-c<\/span><span style=\"color: #F6C177;\"> &#39;<\/span><span style=\"color: #9CCFD8;\">sleep 5; \/home\/ivxvm\/bin\/clearnet tinyproxy -c \/home\/ivxvm\/.config\/tinyproxy-clearnet.conf<\/span><span style=\"color: #F6C177;\">&#39;<\/span><\/span><\/code><\/pre>\n<p>Then in Firefox in container proxy settings I set its IP and port as a proxy:<\/p>\n<pre class=\"giallo\" style=\"color: #E0DEF4; background-color: #191724;\" ><code data-lang=\"plain\"><span class=\"giallo-l\"><span>http:\/\/10.200.0.2:4321<\/span><\/span><\/code><\/pre><h1 id=\"further-reading\">Further reading<a class=\"zola-anchor\" href=\"#further-reading\" aria-label=\"Anchor link for: further-reading\"><i class=\"fas fa-link\"><\/i><\/a> \n<\/h1>\n<ul>\n<li><a rel=\"external\" href=\"https:\/\/www.man7.org\/linux\/man-pages\/man7\/network_namespaces.7.html\">https:\/\/www.man7.org\/linux\/man-pages\/man7\/network_namespaces.7.html<\/a><\/li>\n<li><a rel=\"external\" href=\"https:\/\/developers.redhat.com\/articles\/2026\/04\/03\/introduction-to-linux-interfaces-for-virtual-networking\">https:\/\/developers.redhat.com\/articles\/2026\/04\/03\/introduction-to-linux-interfaces-for-virtual-networking<\/a><\/li>\n<li><a rel=\"external\" href=\"https:\/\/en.wikipedia.org\/wiki\/Nftables\">https:\/\/en.wikipedia.org\/wiki\/Nftables<\/a><\/li>\n<li><a rel=\"external\" href=\"https:\/\/support.mozilla.org\/en-US\/kb\/how-use-firefox-containers\">https:\/\/support.mozilla.org\/en-US\/kb\/how-use-firefox-containers<\/a><\/li>\n<li><a rel=\"external\" href=\"https:\/\/tinyproxy.github.io\">https:\/\/tinyproxy.github.io<\/a><\/li>\n<\/ul>\n"},{"title":"Btrfs for daily driving","published":"2026-10-23T00:00:00+00:00","updated":"2026-10-23T00:00:00+00:00","link":[{"@attributes":{"href":"https:\/\/ivxvm.github.io\/btrfs-for-daily-driving\/"}},{"@attributes":{"rel":"alternate","href":"https:\/\/ivxvm.github.io\/btrfs-for-daily-driving\/","type":"text\/html"}}],"id":"https:\/\/ivxvm.github.io\/btrfs-for-daily-driving\/","content":"<p>Initially I wanted to name this post \"btrfs for desktop use\" to create contrast with server scenarios, but I realized it may be confusing because the term \"desktop\" is sometimes also used in contrast to \"laptop\", but in this case I actually mean both desktops and laptops and probably some other personal devices. \"Daily driving\" might sound a bit \"too memey\", but it feels like a better choice here.<\/p>\n<p>I first encountered btrfs when I used Bazzite - gaming-oriented atomic immutable distro - a heavily customized Fedora Atomic. I didn't think much of it and the only thing I noticed is that this filesystem was used by default on such a \"set it and forget it\" distro for gamers. Never had any major issues during my year of using that distro other than being annoyed by needing to use things like distrobox and rpm-ostree to get anything that's not covered by just flatpaks and brew.<\/p>\n<p>Later, when I moved to Gentoo I also picked btrfs for my system volume because it was one of recommended and well-supported options and I already had an impression of it being a good modern general-purpose filesystem after seeing it used in Bazzite. At that point I wasn't really aware of properties of btrfs on deeper level, so it wasn't super deliberate. However, I started discovering them very soon.<\/p>\n<p>Because of Gentoo not being atomic itself, it means things like kernel and driver updates, or just global software updates in general, are more risky: if something goes wrong during update process, there is a possibility of system ending up in broken inconsistent state. Different ways to make it safer exist, the one I decided to try is to use snapshots which btrfs supports natively. Because this filesystem uses copy-on-write (COW), it naturally makes snapshots zero-cost: they don't copy anything until you change any of the files at which point new modified copy of the file will be created while the old one will stay in place, still referenced by snapshot. Many tools exist to automate creating snapshots, however I decided to stick to native btrfs cli, because it turned out very easy to use - I simply have to invoke a single command before doing system updates or anything risky:<\/p>\n<pre class=\"giallo\" style=\"color: #E0DEF4; background-color: #191724;\" ><code data-lang=\"shellscript\"><span class=\"giallo-l\"><span style=\"color: #C4A7E7;\">btrfs<\/span><span style=\"color: #9CCFD8;\"> subvolume snapshot \/ \/snapshots\/2026_10_16<\/span><\/span><\/code><\/pre>\n<p>And that's basically it: zero-cost = no copying anything without need = no disk space wasted (and no LLMs, even though I written \"no\" quite a few times). What's the catch though, why wouldn't anyone just use filesystems like btrfs universally? That's where I started researching more and got surprised by how unstable and experimental it was considered in its early days according to decade old posts and discussions. Most of those early issues, however, were addressed and fixed long time ago and nowadays the most problematic aspect turns out to be fragmentation which only happens during very specific circumstances. This issue is rather fundamental and stems mostly from COW itself and from other similarly fundamental filesystem design choices. So what are those conditions and how to deal with them?<\/p>\n<h2 id=\"1-big-files-that-are-modified-often-and-in-random-order-db-vm-volumes\">1. Big files that are modified often and in random order (DB &amp; VM volumes)<a class=\"zola-anchor\" href=\"#1-big-files-that-are-modified-often-and-in-random-order-db-vm-volumes\" aria-label=\"Anchor link for: 1-big-files-that-are-modified-often-and-in-random-order-db-vm-volumes\"><i class=\"fas fa-link\"><\/i><\/a> \n<\/h2>\n<p>This is the edge case that is well known on the internet, and is one of the first things to find when looking for problematic btrfs scenarios. The root of the problem is that due to COW, btrfs can't perform random writes in place: each write will allocate new data and old block becomes dead space. Over time this leads to massive fragmentation: the file's physical content gets scattered across the disk as many small extents.<\/p>\n<p>I personally stumbled upon this one in my bitmagnet setup: turns out it uses postgres database for bookkeeping and even though I only kept it spinning for a week or two, when checking fragmentation these postgres files were at multiple dozen thousands extents.<\/p>\n<p>Fortunately, there is a solution to this problem: disable COW! Yep, turns out btrfs supports disabling COW for individual files and folders, and in the later case, all new files and folders created within such a folder, will also have COW automatically disabled.<\/p>\n<pre class=\"giallo\" style=\"color: #E0DEF4; background-color: #191724;\" ><code data-lang=\"shellscript\"><span class=\"giallo-l\"><span style=\"color: #6E6A86;font-style: italic;\"># disable COW<\/span><\/span>\n<span class=\"giallo-l\"><span style=\"color: #C4A7E7;\">chattr<\/span><span style=\"color: #9CCFD8;\"> +C ~\/bitmagnet\/data<\/span><\/span>\n<span class=\"giallo-l\"><span style=\"color: #6E6A86;font-style: italic;\"># check flags (big letter &#39;C&#39; means COW is disabled)<\/span><\/span>\n<span class=\"giallo-l\"><span style=\"color: #C4A7E7;\">lsattr<\/span><span style=\"color: #9CCFD8;\"> ~\/bitmagnet\/data<\/span><\/span><\/code><\/pre><h2 id=\"2-big-files-that-are-initialized-in-small-chunks-in-random-order-torrented-media\">2. Big files that are initialized in small chunks in random order (torrented media)<a class=\"zola-anchor\" href=\"#2-big-files-that-are-initialized-in-small-chunks-in-random-order-torrented-media\" aria-label=\"Anchor link for: 2-big-files-that-are-initialized-in-small-chunks-in-random-order-torrented-media\"><i class=\"fas fa-link\"><\/i><\/a> \n<\/h2>\n<p>This one is more tricky, initially I expected +C to solve all problems with COW-related fragmentation, but this is not the case unfortunately: when checking my media drive for files with heavy fragmentation, to my surprise the worst cases were all torrented videos. The problem with those is that in many cases torrent clients by default work with sparse files, and when new data arrives in random order those arrivals are not overwrites to existing data, instead it's new allocations which create fragmented extents. In some torrent clients it's possible to configure them to preallocate the whole file beforehands, which will fix the problem when combined with +C. Otherwise, the solution would be to defragment torrented files manually as a periodic maintenance.<\/p>\n<pre class=\"giallo\" style=\"color: #E0DEF4; background-color: #191724;\" ><code data-lang=\"shellscript\"><span class=\"giallo-l\"><span style=\"color: #6E6A86;font-style: italic;\"># defragment file<\/span><\/span>\n<span class=\"giallo-l\"><span style=\"color: #C4A7E7;\">btrfs<\/span><span style=\"color: #9CCFD8;\"> filesystem defrag<\/span><span style=\"color: #EBBCBA;\"> -v -t<\/span><span style=\"color: #9CCFD8;\"> 32M file<\/span><\/span>\n<span class=\"giallo-l\"><span style=\"color: #6E6A86;font-style: italic;\"># check file fragmentation<\/span><\/span>\n<span class=\"giallo-l\"><span style=\"color: #C4A7E7;\">filefrag<\/span><span style=\"color: #9CCFD8;\"> file<\/span><\/span><\/code><\/pre><h2 id=\"snapshots-and-c\">Snapshots and +C<a class=\"zola-anchor\" href=\"#snapshots-and-c\" aria-label=\"Anchor link for: snapshots-and-c\"><i class=\"fas fa-link\"><\/i><\/a> \n<\/h2>\n<p>Another important concern is that in case of snapshots, copy-on-write will still happen on the first write to files that are referenced by snapshots even if they have +C flag. So if your DB or VM files live on btrfs volume that you are snapshotting, you might lose quite some disk space after every new snapshot (on the next write to corresponding DB or VM files). The best solution to this I am aware of is to create separate subvolumes for those DB\/VM files, because when snapshotting a volume, btrfs will simply ignore any subvolumes and not include them into snapshots. It's not as annoying as it sounds because btrfs makes it easy to create arbitrary subvolumes at arbitrary paths - so that you can have for example <code>~\/bitmagnet\/data<\/code> as a separate subvolume, while <code>\/<\/code> is the main volume that you take snapshots of.<\/p>\n<pre class=\"giallo\" style=\"color: #E0DEF4; background-color: #191724;\" ><code data-lang=\"shellscript\"><span class=\"giallo-l\"><span style=\"color: #C4A7E7;\">btrfs<\/span><span style=\"color: #9CCFD8;\"> subvolume create ~\/bitmagnet\/data<\/span><\/span>\n<span class=\"giallo-l\"><span style=\"color: #C4A7E7;\">chattr<\/span><span style=\"color: #9CCFD8;\"> +C ~\/bitmagnet\/data<\/span><\/span><\/code><\/pre><h2 id=\"ssd-vs-hdd\">SSD vs HDD<a class=\"zola-anchor\" href=\"#ssd-vs-hdd\" aria-label=\"Anchor link for: ssd-vs-hdd\"><i class=\"fas fa-link\"><\/i><\/a> \n<\/h2>\n<p>I use btrfs both for my system SSD and external HDD, and there are some important differences. Because SSDs are very fast, they are more forgiving to fragmentation, but because they also wear off, they benefit from minimizing writes by using compression. This is why I ignore some mild cases of fragmentation on SSD - those where files are not frequently written - and use it with zstd compression:<\/p>\n<pre class=\"giallo\" style=\"color: #E0DEF4; background-color: #191724;\" ><code data-lang=\"shellscript\"><span class=\"giallo-l\"><span style=\"font-style: italic;\">UUID<\/span><span style=\"color: #EB6F92;\">=<\/span><span style=\"color: #9CCFD8;\">...<\/span><span style=\"color: #C4A7E7;\">   \/<\/span><span style=\"color: #9CCFD8;\">   btrfs   rw,relatime,ssd,compress=zstd:3,space_cache=v2,subvol=\/<\/span><span style=\"color: #EBBCBA;\"> 0 0<\/span><\/span><\/code><\/pre>\n<p>On my external HDD there is a lot of space and it's significantly slower than SSD. Btrfs compression also leads to some additional fragmentation in certain scenarios, so using compression would be a bad choice for HDD:<\/p>\n<pre class=\"giallo\" style=\"color: #E0DEF4; background-color: #191724;\" ><code data-lang=\"shellscript\"><span class=\"giallo-l\"><span style=\"font-style: italic;\">UUID<\/span><span style=\"color: #EB6F92;\">=<\/span><span style=\"color: #9CCFD8;\">...<\/span><span style=\"color: #C4A7E7;\">  \/mnt\/expansion<\/span><span style=\"color: #9CCFD8;\">  btrfs  defaults,noatime<\/span><span style=\"color: #EBBCBA;\">  0  0<\/span><\/span><\/code><\/pre>\n<p><code>noatime<\/code> flag prevents rewriting metadata on file access which improves performance in some cases and it might be useful on HDDs. On my main system SSD I decided to leave the default <code>relatime<\/code> in place because some sources say certain system software may need proper access times.<\/p>\n<h2 id=\"impressions-so-far\">Impressions so far<a class=\"zola-anchor\" href=\"#impressions-so-far\" aria-label=\"Anchor link for: impressions-so-far\"><i class=\"fas fa-link\"><\/i><\/a> \n<\/h2>\n<p>It really does feel great to be able to instantly create snapshots that take zero extra disk space (until later). But it's definitely not without a price, and in this case the price is maintenance. I don't see btrfs as a filesystem you can just use and never think about it, in my opinion you need to pay attention: at the very least check fragmentation periodically, move specific types of files into subvolumes and set certain flags when needed. But when used properly, it does have many nice properties, and snapshotting is only one of them.<\/p>\n<h2 id=\"further-reading\">Further reading<a class=\"zola-anchor\" href=\"#further-reading\" aria-label=\"Anchor link for: further-reading\"><i class=\"fas fa-link\"><\/i><\/a> \n<\/h2>\n<p>This blogpost barely scratches the surface, but I believe those aspects I covered are the most important ones for everyday btrfs use. My top 3 resources to find information on btrfs would be:<\/p>\n<ul>\n<li><a rel=\"external\" href=\"https:\/\/btrfs.readthedocs.io\/en\/latest\/\">https:\/\/btrfs.readthedocs.io\/en\/latest\/<\/a><\/li>\n<li><a rel=\"external\" href=\"https:\/\/lore.kernel.org\/linux-btrfs\/\">https:\/\/lore.kernel.org\/linux-btrfs\/<\/a><\/li>\n<li><a rel=\"external\" href=\"https:\/\/www.reddit.com\/r\/btrfs\/\">https:\/\/www.reddit.com\/r\/btrfs\/<\/a><\/li>\n<\/ul>\n<h2 id=\"useful-scripts\">Useful scripts<a class=\"zola-anchor\" href=\"#useful-scripts\" aria-label=\"Anchor link for: useful-scripts\"><i class=\"fas fa-link\"><\/i><\/a> \n<\/h2>\n<pre class=\"giallo\" style=\"color: #E0DEF4; background-color: #191724;\" ><code data-lang=\"shellscript\"><span class=\"giallo-l\"><span style=\"color: #6E6A86;font-style: italic;\"># print fragmentation for all files in folder (recursively)<\/span><\/span>\n<span class=\"giallo-l\"><span style=\"color: #C4A7E7;\">find<\/span><span style=\"color: #9CCFD8;\"> \/mnt\/expansion\/videos<\/span><span style=\"color: #EBBCBA;\"> -type<\/span><span style=\"color: #9CCFD8;\"> f<\/span><span style=\"color: #EBBCBA;\"> -exec<\/span><span style=\"color: #9CCFD8;\"> filefrag {} +<\/span><\/span><\/code><\/pre><pre class=\"giallo\" style=\"color: #E0DEF4; background-color: #191724;\" ><code data-lang=\"shellscript\"><span class=\"giallo-l\"><span style=\"color: #6E6A86;font-style: italic;\"># find files larger than 10M that have &gt;= 1000 fragmentation extents<\/span><\/span>\n<span class=\"giallo-l\"><span style=\"color: #C4A7E7;\">sudo<\/span><span style=\"color: #9CCFD8;\"> find \/<\/span><span style=\"color: #EBBCBA;\"> -xdev -type<\/span><span style=\"color: #9CCFD8;\"> f<\/span><span style=\"color: #EBBCBA;\"> -size<\/span><span style=\"color: #9CCFD8;\"> +10M<\/span><span style=\"color: #EBBCBA;\"> -exec<\/span><span style=\"color: #9CCFD8;\"> filefrag {} +<\/span><span style=\"color: #EB6F92;\"> |<\/span><\/span>\n<span class=\"giallo-l\"><span style=\"color: #C4A7E7;\">\tsed<\/span><span style=\"color: #EBBCBA;\"> -nE<\/span><span style=\"color: #F6C177;\"> &#39;<\/span><span style=\"color: #9CCFD8;\">s\/(.+): ([0-9]+).*\/\\2 \\1\/p<\/span><span style=\"color: #F6C177;\">&#39;<\/span><span style=\"color: #EB6F92;\"> |<\/span><\/span>\n<span class=\"giallo-l\"><span style=\"color: #C4A7E7;\">\tawk<\/span><span style=\"color: #F6C177;\"> &#39;<\/span><span style=\"color: #9CCFD8;\">$1 &gt;= 1000<\/span><span style=\"color: #F6C177;\">&#39;<\/span><span style=\"color: #EB6F92;\"> |<\/span><\/span>\n<span class=\"giallo-l\"><span style=\"color: #C4A7E7;\">\tsort<\/span><span style=\"color: #EBBCBA;\"> -nr<\/span><\/span><\/code><\/pre>"},{"title":"Why I moved from Trilium Notes to Obsidian","published":"2026-08-23T00:00:00+00:00","updated":"2026-08-23T00:00:00+00:00","link":[{"@attributes":{"href":"https:\/\/ivxvm.github.io\/why-i-moved-from-trilium-notes-to-obsidian\/"}},{"@attributes":{"rel":"alternate","href":"https:\/\/ivxvm.github.io\/why-i-moved-from-trilium-notes-to-obsidian\/","type":"text\/html"}}],"id":"https:\/\/ivxvm.github.io\/why-i-moved-from-trilium-notes-to-obsidian\/","content":"<p>I've been using Trilium for a while and I really enjoyed it:<\/p>\n<ul>\n<li>Hierarchic notes<\/li>\n<li>Rich text formatting<\/li>\n<li>Embedded media formats support<\/li>\n<li>Templates<\/li>\n<li>Properties<\/li>\n<li>Scripting and customization<\/li>\n<\/ul>\n<p>However, after some time, some weak points also showed up:<\/p>\n<ul>\n<li>Database-backed, which means you won't see your note hierarchy as normal folders and files in filesystem, which has its pros and cons, but for me cons are overwhelming because it means I can't use regular tools, for example grep, or opening notes in other editors easily, or symlinking a folder from elsewhere as child items of the note<\/li>\n<li>No plugin infrastucture: even though Trilium is open-source, there's no built-in plugin support and rich plugin ecosystem like in Obsidian<\/li>\n<li>Even though rich text formatting is cool, it isn't great for compatibility, because it isn't always possible to convert this formatting to pure text formats: lossless export requires xml\/html in general<\/li>\n<li>Theming isn't great, weak support to popular themes like Rose Pine, compared to Obsidian<\/li>\n<\/ul>\n<p>Obsidian solves all those pain points for me. It also comes with its own set of issues though, and I'd like to address them:<\/p>\n<ul>\n<li>Built-in features are very lacking compared to Trilium: for example, folders by default can't be notes themselves, there's also no gallery view for folders of images, no custom sorting for notes, etc - all those issues are solvable with plugins thanks to the powerful plugin ecosystem, however it takes some time to set them up correctly<\/li>\n<li>Proprietary codebase: even though plugins are opensource, the Obsidian core app is proprietary, which is very unfortunate, but it is somewhat balanced out by its simple and open-ended architecture - the fact that everything in the vault is just regular folders and files makes it easy to create alternative frontends for the same vault format which don't even need to be associted to Obsidian itself in any way, and there are already examples of such projects: basalt (tui) and obsidian.nvim<\/li>\n<\/ul>\n<p>Special mention needs to be made regarding embeds and backups:<\/p>\n<ul>\n<li>In Trilium I had to back up the whole vault, including any embedded images, atomically, as a single archive, my single backup size lately was exceeding 1GB, which is crazy for something that is supposed to be mostly about text, it happened because of images and media embeds ofc, but those in my case don't really belong to notes themselves and would benefit to be references to separate places in filesystem<\/li>\n<li>Because in Obsidian vault is just normal files, it becomes possible to bring images in by symlinking picture folders elsewhere in my filesystem, backup strategy also becomes more open-ended and even allows using VCS, and there are already plugins for git and such<\/li>\n<\/ul>\n<p>Notable plugin mentions:<\/p>\n<ul>\n<li>Folder notes by Lost Paul - allows folders being notes themselves (actually there will be md file with the same name as folder either inside or outside of the corresponding folder depending on selected options, but Obsidian will show them as a single item in a smart way thanks to this plugin)<\/li>\n<li>Custom File Explorer sorting by SebastianMC - allows custom sorting of items in folders in multiple different ways, I use sortspec based approach which is very flexible and allows things like combining adhoc order for few items and then sorting the rest by metadata such as specified date property field in notes<\/li>\n<li>Gallery View by mkshp - allows using <code>```obs-gallery ...```<\/code> blocks in notes to render image galleries, I use it with image folders elsewhere in my filesystem symlinked into <code>vault\/Symlinks\/...<\/code>, I then use <code>path: \"Symlinks\/some_folder\"<\/code> and it just works<\/li>\n<li>Iconize by Florian Woelki - allows adding icons to folders and notes<\/li>\n<li>Minimal Theme Settings by @kepano and Style Settings by mgmeyers - for nice and easy theme customizations<\/li>\n<\/ul>\n"}]}