{"id":190,"date":"2025-01-24T18:19:51","date_gmt":"2025-01-24T18:19:51","guid":{"rendered":"https:\/\/qlch.de\/blog\/?p=190"},"modified":"2025-01-30T09:37:41","modified_gmt":"2025-01-30T09:37:41","slug":"incus-auf-debian-mit-openzfs","status":"publish","type":"post","link":"https:\/\/qlch.de\/blog\/2025\/01\/24\/incus-auf-debian-mit-openzfs\/","title":{"rendered":"Incus auf Debian mit OpenZFS"},"content":{"rendered":"\n<p>Vielleicht schreib ich sp\u00e4ter noch was zum Warum, hier erst mal, was ich mir aufgesetzt habe:<\/p>\n\n\n\n<p>Nach der Anleitung <a href=\"https:\/\/openzfs.github.io\/openzfs-docs\/Getting%20Started\/index.html\">hier<\/a> bzw. <a href=\"https:\/\/openzfs.github.io\/openzfs-docs\/Getting%20Started\/Debian\/Debian%20Bookworm%20Root%20on%20ZFS.html\">hier<\/a> habe ich Debian Bookworm auf ZFS mit nativer Encryption und Dropbear installiert.<\/p>\n\n\n\n<p>Es war schon sp\u00e4t und ich habe 2 Fehler gemacht, vor denen ich warnen m\u00f6chte: <\/p>\n\n\n\n<p>1.) in der Anleitung wird 2x das root passwort gesetzt und ich dachte mir beim 2. Mal, so ein Quatsch, hab ich doch grade erst. Tja, das erste war f\u00fcr die Installationsumgebung (u.a. damit man per ssh drauf kommt und nicht im ILO installieren mu\u00df (Grusel)), das zweite w\u00e4re f\u00fcr das zu installierende System gewesen. Nun, als ich dann fertig war, stellte ich fest, da\u00df mein neu installiertes System keine User\/PW-Kombi hatte, mit der man rein k\u00e4me und stellte dabei auch fest, da\u00df Debian zwischenzeitlich im single-User Mode niemanden mehr rein l\u00e4sst, der sich nicht als root ausweisen kann. <\/p>\n\n\n\n<p>2.) Mein <a href=\"https:\/\/www.servethehome.com\/hpe-proliant-microserver-gen10-plus-ultimate-customization-guide\/\">HPE Microserver Gen10 plus<\/a> hat 4x 10TB-Festplatten und 2x USB3.2 angebundene 1TB-SSDs (die ich erst mal nicht nutze). Eine der beiden Anleitungen, die ich parallel verfolgte wies darauf hin, man solle unbedingt disk-by-id Pfade f\u00fcr ZFS nutzen. Nachdem der Server bislang immer verl\u00e4sslich die Platten als sda, sdb, sdc und sdd identifizierte, hielt ich das f\u00fcr \u00fcbervorsichtig und lie\u00df es sein. Hatte beim 1. Versuch (ohne Vergabe des root-PWs) auch funktioniert &#8230; Bereits beim 2. Versuch ging es schief und ich hatte erhebliche Probleme (mangels Routine mit ZFS) damit, ZFS von den SSDs runterzukratzen (bei diesem Installationsversuch waren unter sda, sdb, sdc und sdd zwei der SSDs drunter&#8230;)<\/p>\n\n\n\n<p>im 3. Versuch war dann alles wie es sein sollte. Ich habe aus den Backports noch ZFS 2.2 installiert, weil das f\u00fcr die Overlays bei Containern notwendige Features mitbringt.<\/p>\n\n\n\n<p>Incus kam dann nach der Anleitung von <a href=\"https:\/\/linuxcontainers.org\/incus\/docs\/main\/installing\/#installing\">hier<\/a> bzw. <a href=\"https:\/\/linuxcontainers.org\/incus\/docs\/main\/tutorial\/first_steps\/\">hier<\/a> installiert mit dem Repository von Zabbly.<\/p>\n\n\n\n<p>Ich habe dann einen LXContainer mit Debian installiert, in dem ich Docker installiert habe. Incus kann zwar inzwischen auch OIContainer installieren, da fehlt mir aber noch einiges zum gewohnten Docker-Compose.<\/p>\n\n\n\n<p>Die LXContainer erhalten by default Netzwerk-Adressen im 172.-er Netz, die von au\u00dfen erstmal nicht erreichbar sind, ich wollte aber einen LXContainer (quasi statt einer VM) aufsetzen, in dem ich docker compose nutzen kann und der &#8220;nat\u00fcrlich&#8221; auch IP-Adresse von meinem DHCP-Server aus dem 192.-er Netz kriegen sollte, die von au\u00dfen erreichbar sind.<\/p>\n\n\n\n<p>Dazu habe ich auf dem Host ein Bridge-Interface eingerichtet, dem ich die Mac-Adresse des physischen Interfaces gab (damit die IP stabil bleibt):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>in der Datei \/etc\/network\/interfaces.d\/br0-setup\n\n# Define the bridge interface\nauto br0\niface br0 inet dhcp\n    bridge_ports ens1f0\n    bridge_stp off\n    bridge_fd 0\n    bridge_maxwait 0\n    bridge_hw aa:bb:cc:dd:ee:ff<\/code><\/pre>\n\n\n\n<p>das &#8220;zugeh\u00f6rige&#8221; physische Interface ens1f0 wird nicht initialisiert (weil ich sonst 2 IP-Adresse aus dem gleichen 192-Segment kriege, was z.B. NFS \u00fcberhaupt nicht leiden kann). Die MAC-Adresse von ens1f0 wird f\u00fcr br0 \u00fcbernommen in der letzten Zeile.<\/p>\n\n\n\n<p>Damit auch der incus-LXContainer (der bei mir &#8220;docker&#8221; hei\u00dft wg. der beabsichtigten Verwendung) sich an diese Bridge klemmt erstellt man auf dem Host ein Networkprofile f\u00fcr incus (ich denke ich bin <a href=\"https:\/\/blog.simos.info\/how-to-make-your-lxd-containers-get-ip-addresses-from-your-lan-using-a-bridge\/\">dieser Anleitung<\/a> gefolgt):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>root@hpe:~# incus profile create mainlan\nProfile mainlan2 created\nroot@hpe:~# incus profile device add mainlan eth0 nic \\ nictype=bridged parent=br0\nDevice eth0 added to mainlan\nroot@hpe:~# incus profile show mainlan\nconfig: {}\ndescription: \"\"\ndevices:\n  eth0:\n    nictype: bridged\n    parent: br0\n    type: nic\nname: mainlan\nused_by: &#91;]\nproject: default<\/code><\/pre>\n\n\n\n<p>Dann habe ich den container erzeugt und dabei das Profile genutzt (eine Zeile!):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>incus launch images:debian\/12 docker --profile default --profile mainlan -c boot.autostart=true   -c security.nesting=true   -c security.syscalls.intercept.mknod=true   -c security.syscalls.intercept.setxattr=true<\/code><\/pre>\n\n\n\n<p>Die -c (config) Parameter mit &#8220;security.&#8221; sind notwendig, um im LXContainer sp\u00e4ter Docker-Container nutzbar zu machen. boot.autostart=true ist selbsterkl\u00e4rend \ud83d\ude42<\/p>\n\n\n\n<p>F\u00fcr die Docker-Installation bin ich einer Anleitung wie <a href=\"https:\/\/www.cyberciti.biz\/faq\/how-to-run-docker-inside-incus-containers\/\">dieser<\/a> gefolgt (bis auf zfs statt btrfs Storage backend f\u00fcr incus)<\/p>\n\n\n\n<p>Hier noch (weitgehend unkommentiert und unredigiert) meine Notizen w\u00e4hrend der Installation:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># boot live Cd\n\nsudo -i\napt install --yes openssh-server\necho  PermitRootLogin Yes >>\/etc\/ssh\/sshd_config:\n\npasswd # set temp-root-password for live-system\t\n\nsudo systemctl restart ssh\n\nssh root@&lt;ip-address> # to avoid typing on console \/ getting copy+paste\n\nvi \/etc\/apt\/sources.list #add contrib\ndeb http:\/\/deb.debian.org\/debian bookworm main contrib non-free-firmware\n\napt update\napt install --yes debootstrap gdisk zfsutils-linux\n\nDISKS=\"\/dev\/disk\/by-id\/wwn-0x5000000000000001 \/dev\/disk\/by-id\/wwn-0x5000000000000002 \/dev\/disk\/by-id\/wwn-0x5000000000000003 \/dev\/disk\/by-id\/wwn-0x5000000000000004\" \n\n# never use \u201c\/dev\/sda\u201d etc. !!!!\n\nswapoff --all\n\nfor DISK in $DISKS\ndo\nwipefs -a $DISK\nsgdisk --zap-all $DISK\nsgdisk  -a1 -n1:24K:+1000K -t1:EF02 -I $DISK\nsgdisk     -n2:1M:+512M   -t2:EF00 -I $DISK\nsgdisk     -n3:0:+1G      -t3:BF01 -I $DISK\nsgdisk     -n4:0:0        -t4:BF00 -I $DISK #for unencrypted or zfs native crypt\ndone\n\n# additional\/optional for flash storage:\nfor DISK in \"\/dev\/disk\/by-id\/usb-Samsung_PSSD_T7_S5T4NS0R000001M-0:0\" \"\/dev\/disk\/by-id\/usb-Samsung_PSSD_T7_S5T4NS0R000001M-0:0\"\ndo\nblkdiscard -f $DISK\ndone \n\nzpool create -f \\\n    -o ashift=12 \\\n    -o autotrim=on \\\n    -o compatibility=grub2 \\\n    -o cachefile=\/etc\/zfs\/zpool.cache \\\n    -O devices=off \\\n    -O acltype=posixacl -O xattr=sa \\\n    -O compression=lz4 \\\n    -O normalization=formD \\\n    -O relatime=on \\\n    -O canmount=off -O mountpoint=\/boot -R \/mnt \\\n    bpool raidz \/dev\/disk\/by-id\/wwn-0x5000000000000001-part3 \/dev\/disk\/by-id\/wwn-0x5000000000000002-part3 \/dev\/disk\/by-id\/wwn-0x5000000000000003-part3 \/dev\/disk\/by-id\/wwn-0x5000000000000001-part3\n\nzpool create -f \\\n    -o ashift=12 \\\n    -o autotrim=on \\\n    -O encryption=on -O keylocation=prompt -O keyformat=passphrase \\\n    -O acltype=posixacl -O xattr=sa -O dnodesize=auto \\\n    -O compression=lz4 \\\n    -O normalization=formD \\\n    -O relatime=on \\\n    -O canmount=off -O mountpoint=\/ -R \/mnt \\\n    rpool raidz \/dev\/disk\/by-id\/wwn-0x5000000000000001-part4 \/dev\/disk\/by-id\/wwn-0x5000000000000002-part4 \/dev\/disk\/by-id\/wwn-0x5000000000000003-part4 \/dev\/disk\/by-id\/wwn-0x5000000000000004-part4\n\n\nzfs create -o canmount=off -o mountpoint=none rpool\/ROOT\nzfs create -o canmount=off -o mountpoint=none bpool\/BOOT\n\n\n\nzfs create -o canmount=noauto -o mountpoint=\/ rpool\/ROOT\/debian\nzfs mount rpool\/ROOT\/debian\nzfs create -o mountpoint=\/boot bpool\/BOOT\/debian\n\n\nzfs create                     rpool\/home\nzfs create -o mountpoint=\/root rpool\/home\/root\nchmod 700 \/mnt\/root\nzfs create -o canmount=off     rpool\/var\nzfs create -o canmount=off     rpool\/var\/lib\nzfs create                     rpool\/var\/log\nzfs create                     rpool\/var\/spool\n\n\nzfs create -o com.sun:auto-snapshot=false rpool\/var\/cache\nzfs create -o com.sun:auto-snapshot=false rpool\/var\/lib\/nfs\nzfs create -o com.sun:auto-snapshot=false rpool\/var\/tmp\nchmod 1777 \/mnt\/var\/tmp\n\nzfs create -o canmount=off rpool\/usr\nzfs create                 rpool\/usr\/local\n\nzfs create -o com.sun:auto-snapshot=false rpool\/var\/lib\/incus\n\nmkdir \/mnt\/run\nmount -t tmpfs tmpfs \/mnt\/run\nmkdir \/mnt\/run\/lock\n\ndebootstrap bookworm \/mnt\n\nmkdir \/mnt\/etc\/zfs\ncp \/etc\/zfs\/zpool.cache \/mnt\/etc\/zfs\/\n\nhostname hpe\nhostname > \/mnt\/etc\/hostname\nvi \/mnt\/etc\/hosts\n\n# add hostname and ip to \/mnt\/etc\/hosts\n\nip addr show\n\nvi \/mnt\/etc\/network\/interfaces.d\/ens1f0\n\nauto ens1f0\niface ens1f0 inet dhcp\n\n\/mnt\/apt\/sources.list:\n\ndeb http:\/\/deb.debian.org\/debian bookworm main contrib non-free-firmware\ndeb-src http:\/\/deb.debian.org\/debian bookworm main contrib non-free-firmware\n\ndeb http:\/\/deb.debian.org\/debian-security bookworm-security main contrib non-free-firmware\ndeb-src http:\/\/deb.debian.org\/debian-security bookworm-security main contrib non-free-firmware\n\ndeb http:\/\/deb.debian.org\/debian bookworm-updates main contrib non-free-firmware\ndeb-src http:\/\/deb.debian.org\/debian bookworm-updates main contrib non-free-firmware\n\nmount --make-private --rbind \/dev  \/mnt\/dev\nmount --make-private --rbind \/proc \/mnt\/proc\nmount --make-private --rbind \/sys  \/mnt\/sys\nchroot \/mnt \/usr\/bin\/env DISK=$DISK bash --login\n\napt update\napt install --yes console-setup locales\n\ndpkg-reconfigure locales tzdata keyboard-configuration console-setup\n\napt install --yes dpkg-dev linux-headers-generic linux-image-generic\napt install --yes zfs-initramfs\necho REMAKE_INITRD=yes > \/etc\/dkms\/zfs.conf\n\napt install systemd-timesyncd\napt install ntp\n\nDISK=\"\/dev\/disk\/by-id\/wwn-0x5000000000000001\"\n# ggf. auch f\u00fcr die anderen Disks einrichten\n\napt install dosfstools\n\nmkdosfs -F 32 -s 1 -n EFI ${DISK}-part2\nmkdir \/boot\/efi\necho \/dev\/disk\/by-uuid\/$(blkid -s UUID -o value ${DISK}-part2) \\\n   \/boot\/efi vfat defaults 0 0 >> \/etc\/fstab\nmount \/boot\/efi\napt install --yes grub-efi-amd64 shim-signed\n\napt purge --yes os-prober\n\npasswd\n\n!!!\n\nvi \/etc\/systemd\/system\/zfs-import-bpool.service :\n\n\n&#91;Unit]\nDefaultDependencies=no\nBefore=zfs-import-scan.service\nBefore=zfs-import-cache.service\n\n&#91;Service]\nType=oneshot\nRemainAfterExit=yes\nExecStart=\/sbin\/zpool import -N -o cachefile=none bpool\n# Work-around to preserve zpool cache:\nExecStartPre=-\/bin\/mv \/etc\/zfs\/zpool.cache \/etc\/zfs\/preboot_zpool.cache\nExecStartPost=-\/bin\/mv \/etc\/zfs\/preboot_zpool.cache \/etc\/zfs\/zpool.cache\n\n&#91;Install]\nWantedBy=zfs-import.target\n\napt install --yes --no-install-recommends dropbear-initramfs\nmkdir -p \/etc\/dropbear\/initramfs\n\n# Optional: Convert OpenSSH server keys for Dropbear\nfor type in ecdsa ed25519 rsa ; do\n    cp \/etc\/ssh\/ssh_host_${type}_key \/tmp\/openssh.key\n    ssh-keygen -p -N \"\" -m PEM -f \/tmp\/openssh.key\n    dropbearconvert openssh dropbear \\\n        \/tmp\/openssh.key \\\n        \/etc\/dropbear\/initramfs\/dropbear_${type}_host_key\ndone\nrm \/tmp\/openssh.key\n\n\n\ncat >\/etc\/apt\/apt.conf  &lt;&lt;-EOF\nAPT::Install-Recommends \u201c0\u201d;\nAPT::Install-Suggests \"0\";\nEOF\n\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Vielleicht schreib ich sp\u00e4ter noch was zum Warum, hier erst mal, was ich mir aufgesetzt habe: Nach der Anleitung hier bzw. hier habe ich Debian Bookworm auf ZFS mit nativer Encryption und Dropbear installiert. Es war schon sp\u00e4t und ich habe 2 Fehler gemacht, vor denen ich warnen m\u00f6chte: 1.) in der Anleitung wird 2x [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[21],"tags":[],"class_list":["post-190","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/qlch.de\/blog\/wp-json\/wp\/v2\/posts\/190","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/qlch.de\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/qlch.de\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/qlch.de\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/qlch.de\/blog\/wp-json\/wp\/v2\/comments?post=190"}],"version-history":[{"count":4,"href":"https:\/\/qlch.de\/blog\/wp-json\/wp\/v2\/posts\/190\/revisions"}],"predecessor-version":[{"id":197,"href":"https:\/\/qlch.de\/blog\/wp-json\/wp\/v2\/posts\/190\/revisions\/197"}],"wp:attachment":[{"href":"https:\/\/qlch.de\/blog\/wp-json\/wp\/v2\/media?parent=190"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/qlch.de\/blog\/wp-json\/wp\/v2\/categories?post=190"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/qlch.de\/blog\/wp-json\/wp\/v2\/tags?post=190"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}