<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
     xmlns:content="http://purl.org/rss/1.0/modules/content/"
     xmlns:wfw="http://wellformedweb.org/CommentAPI/"
     xmlns:dc="http://purl.org/dc/elements/1.1/"
     xmlns:atom="http://www.w3.org/2005/Atom"
     xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
     xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
     xmlns:georss="http://www.georss.org/georss"
     xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"
     xmlns:media="http://search.yahoo.com/mrss/"><channel>
  <title>~cdrmack RSS</title>
  <atom:link href="https://cdrmack.dev/rss.xml" rel="self" type="application/rss+xml" />
  <link>https://cdrmack.dev</link>
  <description><![CDATA[~cdrmack RSS]]></description>
  <language>en</language>
  <pubDate>Thu, 19 Feb 2026 14:36:53 +0100</pubDate>
  <lastBuildDate>Thu, 19 Feb 2026 14:36:53 +0100</lastBuildDate>
  <generator>Emacs 31.0 Org-mode 9.7.11</generator>
  <webMaster> (cdrmack)</webMaster>
  <image>
    <url>https://orgmode.org/img/org-mode-unicorn-logo.png</url>
    <title>~cdrmack RSS</title>
    <link>https://cdrmack.dev</link>
  </image>

  <item>
    <title>wireguard</title>
    <link>https://cdrmack.dev/posts/2026-02-19_wireguard.html</link>
    <author> (cdrmack)</author>
    <guid isPermaLink="false">https://cdrmack.dev/posts/2026-02-19_wireguard.html</guid>
    <pubDate>Thu, 19 Feb 2026 00:00:00 +0100</pubDate>

    <description><![CDATA[<p>
    Check if kernel module is loaded, load if needed.
    </p>

    <div class="org-src-container">
    <pre class="src src-sh">kldstat | grep wg
    kldload if_wg
    </pre>
    </div>
    <div id="outline-container-orgeabdbd9" class="outline-3">
    <h3 id="orgeabdbd9"><span class="section-number-3">1.1.</span> start</h3>
    <div class="outline-text-3" id="text-1-1">
    <p>
    Create WireGuard interface.
    </p>

    <div class="org-src-container">
    <pre class="src src-sh">ifconfig wg create name wg0
    </pre>
    </div>

    <p>
    Set config for that new interface.
    </p>

    <div class="org-src-container">
    <pre class="src src-sh">wg setconf wg0 /usr/local/etc/wireguard/wg0.conf
    </pre>
    </div>

    <p>
    Sample config from <code>wg(8)</code>.
    </p>

    <pre class="example" id="org2185d74">
    [Interface]
    PrivateKey = yAnz5TF+lXXJte14tji3zlMNq+hd2rYUIgJBgB3fBmk=
    ListenPort = 51820

    [Peer]
    PublicKey = xTIBA5rboUvnH4htodjb6e697QjLERt1NAB4mZqp8Dg=
    Endpoint = 192.95.5.67:1234
    AllowedIPs = 10.192.122.3/32, 10.192.124.1/24
    </pre>

    <p>
    Finish configuration.
    </p>

    <div class="org-src-container">
    <pre class="src src-sh">ifconfig wg0 inet &lt;ip&gt;/&lt;mask&gt; alias # ip/mask from provider
    ifconfig wg0 mtu 1420 # optional
    ifconfig wg0 up
    </pre>
    </div>

    <p>
    With interface up and running set DNS and routing.
    </p>

    <div class="org-src-container">
    <pre class="src src-sh">echo "nameserver &lt;dns&gt;" | resolvconf -a wg0 -x # optional, dns from provider
    route -q -n add -inet 0.0.0.0/1 -interface wg0
    route -q -n add -inet 128.0.0.0/1 -interface wg0
    route -q -n delete -inet &lt;peer_endpoint&gt;
    route -q -n add -inet &lt;peer_endpoint&gt; -gateway 192.168.0.1
    </pre>
    </div>

    <p>
    Check stuff.
    </p>

    <div class="org-src-container">
    <pre class="src src-sh">wg show wg0
    wg showconf wg0
    </pre>
    </div>
    </div>
    </div>
    <div id="outline-container-orgf7395f3" class="outline-3">
    <h3 id="orgf7395f3"><span class="section-number-3">1.2.</span> stop</h3>
    <div class="outline-text-3" id="text-1-2">
    <p>
    To stop WireGuard.
    </p>

    <div class="org-src-container">
    <pre class="src src-sh">ifconfig wg0 destroy
    resolvconf -d wg0
    route -q -n delete -inet &lt;peer_endpoint&gt;
    </pre>
    </div>
    </div>
    </div>
    ]]></description>
  </item>
  <item>
    <title>thick jail</title>
    <link>https://cdrmack.dev/posts/2026-01-21_thick_jail.html</link>
    <author> (cdrmack)</author>
    <guid isPermaLink="false">https://cdrmack.dev/posts/2026-01-21_thick_jail.html</guid>
    <pubDate>Wed, 21 Jan 2026 00:00:00 +0100</pubDate>

    <description><![CDATA[<p>
    Enable jails.
    </p>

    <div class="org-src-container">
    <pre class="src src-conf">sysrc jail_enable=YES
    Sysrc jail_parallel_start=YES
    </pre>
    </div>

    <p>
    Create zfs datasets.
    </p>

    <div class="org-src-container">
    <pre class="src src-sh">zfs create -o mountpoint=/jails zroot/jails
    zfs create zroot/jails/media
    zfs create zroot/jails/base
    </pre>
    </div>

    <p>
    Fetch userland.
    </p>

    <div class="org-src-container">
    <pre class="src src-sh">fetch https://download.freebsd.org/ftp/releases/$(uname -m)/$(freebsd-version -k)/base.txz -o /jails/media/$(freebsd-version -k)-base.txz
    </pre>
    </div>

    <p>
    Extract it to base.
    </p>

    <div class="org-src-container">
    <pre class="src src-sh">cd /jails
    tar -xf media/$(freebsd-version)-base.txz -C base --unlink
    ls -l base
    </pre>
    </div>

    <p>
    Copy DNS and time zone configurations to the template.
    </p>

    <div class="org-src-container">
    <pre class="src src-sh">cp /etc/resolv.conf base/etc/
    cp /etc/localtime base/etc/
    </pre>
    </div>

    <p>
    Patch base.
    </p>

    <div class="org-src-container">
    <pre class="src src-sh">freebsd-update -b /jails/base fetch install
    </pre>
    </div>

    <p>
    Bootstrap pkg (execute <code>pkg(8)</code> inside a <code>chroot(8)</code>).
    </p>

    <div class="org-src-container">
    <pre class="src src-sh">pkg -c /jails/base install -y pkg
    </pre>
    </div>

    <p>
    Install <code>git</code> as an example.
    </p>

    <div class="org-src-container">
    <pre class="src src-sh">pkg -c /jails/base install -y git
    </pre>
    </div>

    <p>
    Create snapshot, this will become a template.
    </p>

    <div class="org-src-container">
    <pre class="src src-sh">zfs snapshot zroot/jails/base@$(freebsd-version)-$(date +%d-%b-%y)
    </pre>
    </div>

    <p>
    Clone template for new jail.
    </p>

    <div class="org-src-container">
    <pre class="src src-sh">zfs clone zroot/jails/base@&lt;snapshot from above&gt; zroot/jails/alcatraz
    </pre>
    </div>

    <p>
    Set default configuration in <code>/etc/jail.conf</code>.
    </p>

    <div class="org-src-container">
    <pre class="src src-conf">exec.start = "/bin/sh /etc/rc";
    exec.stop = "/bin/sh /etc/rc.shutdown jail";

    allow.raw_sockets;
    exec.clean;
    mount.devfs;

    devfs_ruleset=4;
    enforce_statfs=1;
    securelevel=2;

    .include "/etc/jail.conf.d/*.conf";
    </pre>
    </div>

    <p>
    Jail specific configurations should go inside <code>/etc/jail.conf.d/</code>.
    </p>

    <div class="org-src-container">
    <pre class="src src-conf">alcatraz {
    exec.consolelog = "/var/log/jail_console_${name}.log";

    host.hostname = "${name}.jail";
    path = "/jails/${name}";

    ip4.addr = 192.168.0.63;
    interface = re0;
    }
    </pre>
    </div>

    <p>
    Add new jail to the rc.
    </p>

    <div class="org-src-container">
    <pre class="src src-sh">sysrc jail_list+="alcatraz"
    </pre>
    </div>

    <p>
    Jail is ready to go.
    </p>

    <div class="org-src-container">
    <pre class="src src-sh">jls
    service jail start alcatraz
    jls
    jexec -u root alcatraz
    </pre>
    </div>
    ]]></description>
  </item>
  <item>
    <title>bhyve freebsd</title>
    <link>https://cdrmack.dev/posts/2025-12-17_bhyve_freebsd.html</link>
    <author> (cdrmack)</author>
    <guid isPermaLink="false">https://cdrmack.dev/posts/2025-12-17_bhyve_freebsd.html</guid>
    <pubDate>Wed, 17 Dec 2025 00:00:00 +0100</pubDate>

    <description><![CDATA[<p>
    Load bhyve kernel module.
    </p>

    <div class="org-src-container">
    <pre class="src src-sh">kldload vmm
    </pre>
    </div>

    <p>
    Create tap interface for the network device.
    </p>

    <div class="org-src-container">
    <pre class="src src-sh">ifconfig tap0 create
    sysctl net.link.tap.up_on_open=1
    </pre>
    </div>

    <p>
    Create bridge interface, add tap and physical interface to it.
    </p>

    <div class="org-src-container">
    <pre class="src src-sh">ifconfig bridge0 create
    ifconfig bridge0 addm tap0
    ifconfig bridge0 addm re0
    ifconfig bridge0 up
    </pre>
    </div>

    <p>
    Create ZFS datasets.
    </p>

    <div class="org-src-container">
    <pre class="src src-sh">zfs create -o mountpoint=/bhyve zroot/bhyve
    zfs create zroot/bhyve/media
    zfs create zroot/bhyve/freebsd
    </pre>
    </div>

    <p>
    Download FreeBSD image.
    </p>

    <div class="org-src-container">
    <pre class="src src-sh">cd /bhyve/media
    fetch https://download.freebsd.org/releases/amd64/amd64/ISO-IMAGES/15.0/FreeBSD-15.0-RELEASE-amd64-bootonly.iso
    </pre>
    </div>

    <p>
    Create virtual disk for the guest machine.
    It's a block device (ZFS volume), not directory.
    </p>

    <div class="org-src-container">
    <pre class="src src-sh">zfs create -V 16G -o volmode=dev zroot/bhyve/freebsd/guest
    </pre>
    </div>

    <p>
    Create and boot VM.
    </p>

    <div class="org-src-container">
    <pre class="src src-sh">bhyve -AHP \
    -c 4 \
    -m 8G \
    -s 0:0,hostbridge \
    -s 1:0,lpc \
    -s 2:0,virtio-net,tap0 \
    -s 3:0,virtio-blk,/dev/zvol/zroot/bhyve/freebsd/guest \
    -s 4:0,ahci-cd,/bhyve/media/FreeBSD-15.0-RELEASE-amd64-bootonly.iso \
    -l bootrom,/usr/local/share/uefi-firmware/BHYVE_UEFI.fd \
    -l com1,stdio \
    freebsd
    </pre>
    </div>

    <p>
    It's possible to use null modem device.
    </p>

    <div class="org-src-container">
    <pre class="src src-sh">kldload nmdm
    </pre>
    </div>

    <p>
    Replace <code>stdio</code> with <code>/dev/nmdm0A</code>.
    </p>

    <p>
    You can connect with <code>cu(1)</code> (drop connection by pressing <code>RET ~. RET</code>).
    </p>

    <div class="org-src-container">
    <pre class="src src-sh">cu -l /dev/nmdm0B
    </pre>
    </div>

    <p>
    You can also connect with <code>screen(4)</code>.
    </p>

    <div class="org-src-container">
    <pre class="src src-sh">screen /dev/nmdm0B 115200
    </pre>
    </div>

    <p>
    See currently running VMs.
    </p>

    <div class="org-src-container">
    <pre class="src src-sh">ls -l /dev/vmm/
    </pre>
    </div>

    <p>
    Use <code>bhyvectl(8)</code> to control instances.
    </p>

    <p>
    Start previously created VM.
    </p>

    <div class="org-src-container">
    <pre class="src src-sh">bhyve -AHP \
    -c 4 \
    -m 8G \
    -s 0:0,hostbridge \
    -s 1:0,lpc \
    -s 2:0,virtio-net,tap0 \
    -s 3:0,virtio-blk,/dev/zvol/zroot/bhyve/freebsd/guest \
    -l bootrom,/usr/local/share/uefi-firmware/BHYVE_UEFI.fd \
    -l com1,/dev/nmdm0A \
    freebsd &amp;
    </pre>
    </div>

    <p>
    There is an example script for running VM in FreeBSD.
    </p>

    <div class="org-src-container">
    <pre class="src src-sh">sh /usr/share/examples/bhyve/vmrun.sh -h
    </pre>
    </div>

    <p>
    Use VNC for GUI.
    </p>

    <div class="org-src-container">
    <pre class="src src-sh">bhyve -AHP \
    -c 4 \
    -m 8G \
    -s 0:0,hostbridge \
    -s 1:0,lpc \
    -s 2:0,virtio-net,tap0 \
    -s 3:0,virtio-blk,/dev/zvol/zroot/bhyve/freebsd/guest \
    -s 4:0,fbuf,tcp=127.0.0.1:5900,w=800,h=600 \
    -l bootrom,/usr/local/share/uefi-firmware/BHYVE_UEFI.fd \
    -l com1,/dev/nmdm0A \
    freebsd &amp;
    </pre>
    </div>

    <p>
    Connect to <code>127.0.0.1:5900</code> with your VNC client.
    </p>
    ]]></description>
  </item>
  <item>
    <title>missing ethernet adapter driver</title>
    <link>https://cdrmack.dev/posts/2025-12-08_missing_ethernet_adapter_driver.html</link>
    <author> (cdrmack)</author>
    <guid isPermaLink="false">https://cdrmack.dev/posts/2025-12-08_missing_ethernet_adapter_driver.html</guid>
    <pubDate>Mon, 08 Dec 2025 00:00:00 +0100</pubDate>

    <description><![CDATA[<p>
    This is what I did when my fresh FreeBSD install didn't have network driver but there was a kmod available in the pkgs.
    </p>

    <p>
    I used another machine to download <code>pkg(8)</code> and the missing kmod.
    To find the correct package names I checked "packages" section on <a href="https://www.freshports.org/">freshports</a> website.
    In my case I was looking for FreeBSD:15:quarterly, amd64.
    I needed <code>pkg-2.4.2.pkg</code> and <code>realtek-re-kmod-1100.00.1500068_1.pkg</code>.
    </p>

    <p>
    I used <a href="https://pkg.freebsd.org">pkg.freebsd</a> with the following URL schema to download the files:
    <code>https://pkg.freebsd.org/FreeBSD:15:aarch64/quarterly/All/&lt;pkg_name&gt;.pkg</code>
    </p>

    <p>
    I used a USB thumb-drive formatted with FAT32 and moved downloaded files there.
    Then I was ready to go back to the machine that was offline.
    </p>

    <div class="org-src-container">
    <pre class="src src-sh">dmesg | tail
    mkdir -p /mnt/usb
    mount -t msdosfs /dev/da0s1 /mnt/usb
    cp -R /mnt/usb/ tmp/
    </pre>
    </div>

    <div class="org-src-container">
    <pre class="src src-sh">tar xf pkg-2.4.2.pkg
    usr/local/sbin/pkg-static add pkg-2.4.2.pkg
    </pre>
    </div>

    <p>
    This is a chicken-and-egg situation.
    We need to pkg to install pkg. <code>¯\_(ツ)_/¯</code>
    </p>

    <div class="org-src-container">
    <pre class="src src-sh">pkg add realtek-re-kmod-1100.00.1500068_1.pkg
    </pre>
    </div>

    <div class="org-src-container">
    <pre class="src src-sh"># /boot/loader.conf
    if_re_load="YES"
    if_re_name="/boot/modules/if_re.ko"
    </pre>
    </div>

    <div class="org-src-container">
    <pre class="src src-sh"># /init/rc.conf
    ifconfig_re0="DHCP"
    </pre>
    </div>
    ]]></description>
  </item>
  <item>
    <title>linuxulator</title>
    <link>https://cdrmack.dev/posts/2025-09-16_linuxulator.html</link>
    <author> (cdrmack)</author>
    <guid isPermaLink="false">https://cdrmack.dev/posts/2025-09-16_linuxulator.html</guid>
    <pubDate>Tue, 16 Sep 2025 00:00:00 +0200</pubDate>

    <description><![CDATA[<p>
    FreeBSD can run some GNU/Linux binaries thanks to the binary compatibility, commonly referred to as Linuxulator, <code>linux(4)</code>.
    </p>

    <div class="org-src-container">
    <pre class="src src-shell">sysrc linux_enable="YES"
    service linux start
    </pre>
    </div>

    <p>
    Double check if service is running.
    </p>

    <div class="org-src-container">
    <pre class="src src-shell">service -e | grep linux
    </pre>
    </div>

    <p>
    Kernel modules and filesystems should be visible under <code>/compat/linux</code>.
    </p>

    <p>
    There are some binaries already available in packages, names start with "linux-".
    </p>

    <div class="org-src-container">
    <pre class="src src-shell">pkg search ^linux
    </pre>
    </div>

    <p>
    I decided to check "Discord" which is not available on FreeBSD 14.3-RELEASE.
    </p>

    <div class="org-src-container">
    <pre class="src src-shell">pkg install linux-discord
    </pre>
    </div>

    <p>
    In my case there are over 550MB to be downloaded.
    This is because GNU/Linux binaries require userland which is downloaded and installed automatically alongside the package.
    </p>
    ]]></description>
  </item>
  <item>
    <title>zfs snapshots</title>
    <link>https://cdrmack.dev/posts/2025-09-14_zfs_snapshots.html</link>
    <author> (cdrmack)</author>
    <guid isPermaLink="false">https://cdrmack.dev/posts/2025-09-14_zfs_snapshots.html</guid>
    <pubDate>Sun, 14 Sep 2025 00:00:00 +0200</pubDate>

    <description><![CDATA[<div class="org-src-container">
    <pre class="src src-shell">touch foo.txt
    zfs snapshot zroot/home/user@create_foo
    touch bar.txt
    zfs snapshot zroot/home/user@create_bar
    </pre>
    </div>

    <div class="org-src-container">
    <pre class="src src-shell">zfs list -t snapshot
    </pre>
    </div>

    <div class="org-src-container">
    <pre class="src src-nil">NAME                         USED  AVAIL  REFER  MOUNTPOINT
    zroot/home/user@create_foo    64K      -   132K  -
    zroot/home/user@create_bar     0B      -   140K  -
    </pre>
    </div>

    <p>
    Let's say I've removed <code>foo.txt</code> by a mistake.
    </p>

    <div class="org-src-container">
    <pre class="src src-shell">rm foo.txt
    </pre>
    </div>

    <p>
    I can now rollback to my latest snapshot to get it back.
    </p>

    <div class="org-src-container">
    <pre class="src src-shell">zfs rollback zroot/home/user@create_bar
    </pre>
    </div>

    <p>
    I can't rollback to the <code>user@create_foo</code>, it has to be the latest one.
    </p>
    ]]></description>
  </item>
  <item>
    <title>jail with bastille</title>
    <link>https://cdrmack.dev/posts/2025-07-19_jail_with_bastille.html</link>
    <author> (cdrmack)</author>
    <guid isPermaLink="false">https://cdrmack.dev/posts/2025-07-19_jail_with_bastille.html</guid>
    <pubDate>Sat, 19 Jul 2025 00:00:00 +0200</pubDate>

    <description><![CDATA[<p>
    As as new user I should first run the <code>setup</code> command.
    This should configure the networking, storage and firewall.
    </p>

    <div class="org-src-container">
    <pre class="src src-shell">bastille setup
    </pre>
    </div>

    <p>
    There should be now <code>bastille0</code> interface visible when running <code>ifconfig</code>.
    </p>

    <p>
    Next I will bootstrap FreeBSD release that I will use for my jail.
    </p>

    <div class="org-src-container">
    <pre class="src src-shell">bastille bootstrap 14.3-RELEASE
    </pre>
    </div>

    <p>
    Bastille can create few different type of jails.
    I will start with the "thin" one since this is the default one.
    I would pick "thick" if I wanted my jail to act like a full, independent FreeBSD install.
    </p>

    <div class="org-src-container">
    <pre class="src src-shell">bastille create alcatraz 14.3-RELEASE 192.168.19.63
    </pre>
    </div>

    <p>
    Then I double check if jail was created and if it's running.
    </p>

    <div class="org-src-container">
    <pre class="src src-shell">bastille list all
    </pre>
    </div>

    <p>
    If already running I'm free to launch a login shell inside that jail.
    </p>

    <div class="org-src-container">
    <pre class="src src-shell">bastille console alcatraz
    </pre>
    </div>
    ]]></description>
  </item>
  <item>
    <title>gpg examples</title>
    <link>https://cdrmack.dev/posts/2025-07-12_gpg_examples.html</link>
    <author> (cdrmack)</author>
    <guid isPermaLink="false">https://cdrmack.dev/posts/2025-07-12_gpg_examples.html</guid>
    <pubDate>Sat, 12 Jul 2025 00:00:00 +0200</pubDate>

    <description><![CDATA[<p>
    Install <code>gnupg(1)</code> and generate keys.
    </p>

    <div class="org-src-container">
    <pre class="src src-shell">pkg install gnupg
    gpg --full-generate-key
    gpg --list-keys
    </pre>
    </div>

    <p>
    Sign and encrypt single file.
    </p>

    <div class="org-src-container">
    <pre class="src src-shell">gpg -r gpg.5kky7@passmail.net -e -s foo.txt
    # gpg --recipient gpg.5kky7@passmail.net --encrypt --sign foo.txt
    </pre>
    </div>

    <p>
    Decrypt file (will also verify as long as there is a signature).
    </p>

    <div class="org-src-container">
    <pre class="src src-shell">gpg -o foo.txt -d foo.txt.gpg
    # gpg --output foo.txt --decrypt foo.txt.gpg
    </pre>
    </div>

    <p>
    The following won't work because gpg first signs then encodes the data.
    Because of that the signature is hidden.
    </p>

    <div class="org-src-container">
    <pre class="src src-shell">gpg --verify foo.txt.gpg
    </pre>
    </div>

    <p>
    I use <code>gpgtar(1)</code> for encoding directories.
    </p>

    <p>
    It's also possible to encode (and sign) with symmetric key (password).
    </p>

    <div class="org-src-container">
    <pre class="src src-shell">gpg --symmetric -s --cipher-algo AES256 foo.txt
    gpg -o foo.txt -d foo.txt.gpg
    </pre>
    </div>
    ]]></description>
  </item>
  <item>
    <title>doas</title>
    <link>https://cdrmack.dev/posts/2025-06-21_doas.html</link>
    <author> (cdrmack)</author>
    <guid isPermaLink="false">https://cdrmack.dev/posts/2025-06-21_doas.html</guid>
    <pubDate>Sat, 21 Jun 2025 00:00:00 +0200</pubDate>

    <description><![CDATA[<p>
    I use <code>doas(1)</code> to execute commands as another user (mostly as a root)
    </p>

    <p>
    Config file can be pretty minimal.
    </p>

    <div class="org-src-container">
    <pre class="src src-conf"># /usr/local/etc/doas.conf
    permit nopass cdrmack as root
    </pre>
    </div>

    <p>
    After installing <code>doas</code> there should be an example config "<code>doas.conf.sample</code>" available under <code>/usr/local/etc/</code>.
    </p>
    ]]></description>
  </item>
  <item>
    <title>erase usb stick</title>
    <link>https://cdrmack.dev/posts/2025-06-19_erase_usb_stick.html</link>
    <author> (cdrmack)</author>
    <guid isPermaLink="false">https://cdrmack.dev/posts/2025-06-19_erase_usb_stick.html</guid>
    <pubDate>Thu, 19 Jun 2025 00:00:00 +0200</pubDate>

    <description><![CDATA[<p>
    First of all I plug in USB stick and run <code>dmesg</code> to find the attached device, for example <code>/dev/da0</code>.
    </p>

    <p>
    Then I check current partition information with <code>gpart show /dev/da0</code>.
    </p>

    <p>
    I use <code>dd(1)</code> to fill the device with a bunch of zeroes.
    </p>

    <div class="org-src-container">
    <pre class="src src-shell">dd if=/dev/zero of=/dev/da0 bs=1M status=progress
    </pre>
    </div>
    <div id="outline-container-org8810813" class="outline-3">
    <h3 id="org8810813"><span class="section-number-3">10.1.</span> reuse</h3>
    <div class="outline-text-3" id="text-10-1">
    <p>
    To make that stick usable again it has to have a partitioning scheme and a filesystem.
    </p>

    <p>
    Here is an example for GPT with UFS.
    </p>

    <div class="org-src-container">
    <pre class="src src-shell">gpart create -s gpt /dev/da0
    gpart add -t freebsd-ufs /dev/da0
    newfs /dev/da0p1
    </pre>
    </div>

    <p>
    Ready to be used.
    </p>

    <div class="org-src-container">
    <pre class="src src-shell">mount /dev/da0p1 /media/usb
    # do stuff
    umount /media/usb
    </pre>
    </div>
    </div>
    </div>
    <div id="outline-container-org863ac86" class="outline-3">
    <h3 id="org863ac86"><span class="section-number-3">10.2.</span> throw away</h3>
    <div class="outline-text-3" id="text-10-2">
    <p>
    If I want to throw away that thing I also encrypt it.
    </p>

    <p>
    Initialize GELI on the whole USB disk.
    </p>

    <div class="org-src-container">
    <pre class="src src-shell">geli init /dev/da0
    </pre>
    </div>

    <p>
    Destroy the encryption key.
    </p>

    <div class="org-src-container">
    <pre class="src src-shell">geli clear /dev/da0
    </pre>
    </div>
    </div>
    </div>
    ]]></description>
  </item>
  <item>
    <title>debian vm with bhyve</title>
    <link>https://cdrmack.dev/posts/2025-02-26_debian_vm_with_bhyve.html</link>
    <author> (cdrmack)</author>
    <guid isPermaLink="false">https://cdrmack.dev/posts/2025-02-26_debian_vm_with_bhyve.html</guid>
    <pubDate>Wed, 26 Feb 2025 00:00:00 +0100</pubDate>

    <description><![CDATA[<p>
    <code>bhyve(8)</code> is a hypervisor available on FreeBSD.
    I personally use <code>vm-bhyve(8)</code> to manage my virtual machines because I find it a bit easier.
    </p>

    <div class="org-src-container">
    <pre class="src src-shell">pkg install vm-bhyve
    pkg install bhyve-firmware
    </pre>
    </div>

    <p>
    First of all I need dataset for virtual machines (if ZFS is being used).
    </p>

    <div class="org-src-container">
    <pre class="src src-shell">zfs create zroot/bhyve
    </pre>
    </div>

    <p>
    Then update my system configuration (<code>rc.conf(5)</code>).
    </p>

    <div class="org-src-container">
    <pre class="src src-shell">sysrc vm_enable="YES"
    sysrc vm_dir="zfs:zroot/bhyve"
    </pre>
    </div>

    <p>
    I run <code>vm init</code> to finish initialisation.
    This will create subdirectories inside the dataset.
    </p>

    <div class="org-src-container">
    <pre class="src src-shell">vm init
    </pre>
    </div>

    <p>
    To enable network for the VMs I create virtual switch and attach my network interface to it.
    </p>

    <div class="org-src-container">
    <pre class="src src-shell">iconfig
    vm switch create public
    vm switch add public re0
    ifconfig
    </pre>
    </div>

    <p>
    Now I'm ready to create Debian's VM. There should be a sample config for this already.
    </p>

    <div class="org-src-container">
    <pre class="src src-shell">cp /usr/local/share/examples/vm-bhyve/debian.conf /zroot/bhyve/.templates/
    </pre>
    </div>

    <p>
    In my case I want to use debian template (<code>-t</code>) and specify disk image size (<code>-s</code>) to be 40G.
    The following command will create directory with config, disk image and log.
    This is also a good moment to edit VM's config file and set things like RAM.
    </p>

    <div class="org-src-container">
    <pre class="src src-shell">vm create -t debian -s 40G debian_vm
    </pre>
    </div>

    <p>
    VM is now created but nothing is yet installed on it.
    I need installation image, it can be downloaded with <code>vm iso</code> (it will be placed inside <code>/zroot/bhyve/.iso/</code>).
    </p>

    <div class="org-src-container">
    <pre class="src src-shell">vm iso https://cdimage.debian.org/debian-cd/current/amd64/iso-dvd/debian-12.9.0-amd64-DVD-1.iso
    </pre>
    </div>

    <p>
    Now I can install Debian on my new VM.
    </p>

    <div class="org-src-container">
    <pre class="src src-shell">vm install -f debian_vm debian-12.9.0-amd64-DVD-1.iso
    </pre>
    </div>

    <p>
    I don't use <code>-f</code> if I plan to connect via VNC.
    Otherwise guest will be started in in the foreground on stdio.
    </p>

    <p>
    After the installation VM is ready to be used.
    </p>

    <div class="org-src-container">
    <pre class="src src-shell">vm start debian_vm
    vm console debian_vm
    </pre>
    </div>

    <p>
    <code>vm(8)</code> uses <code>cu(1)</code>, to exit console back to the host use <code>~^D or ~.~</code>.
    </p>

    <p>
    GUI is available via VNC (works only with <code>uefi</code>).
    There should be sample configs available.
    </p>

    <div class="org-src-container">
    <pre class="src src-shell">egrep "^graphics" -R /usr/local/share/examples/vm-bhyve/
    </pre>
    </div>
    ]]></description>
  </item>
  <item>
    <title>ssh to VM</title>
    <link>https://cdrmack.dev/posts/2024-10-18_ssh_to_vm.html</link>
    <author> (cdrmack)</author>
    <guid isPermaLink="false">https://cdrmack.dev/posts/2024-10-18_ssh_to_vm.html</guid>
    <pubDate>Fri, 18 Oct 2024 00:00:00 +0200</pubDate>

    <description><![CDATA[<pre class="example" id="org87818ba">
    Host: FreeBSD
    Guest (VM): NetBSD
    </pre>

    <p>
    Make sure <code>sshd(8)</code> is running on the guest.
    </p>

    <div class="org-src-container">
    <pre class="src src-shell">service sshd status
    </pre>
    </div>

    <p>
    If it's not you might need to add that daemon to the <code>rc.conf(5)</code>.
    </p>

    <div class="org-src-container">
    <pre class="src src-shell">sysrc sshd_enable="YES"
    </pre>
    </div>

    <p>
    It should run automatically after reboot but for now you probably have to start it manually.
    </p>

    <div class="org-src-container">
    <pre class="src src-shell">service sshd start
    </pre>
    </div>

    <p>
    With sshd enabled on guest make sure you try to connect to the correct system (VM) from the host.
    </p>

    <p>
    Run the following command on the guest to display fingerprint of its public key file.
    </p>

    <div class="org-src-container">
    <pre class="src src-shell">ssh-keygen -l -f /etc/ssh/ssh_host_ed25519_key.pub
    </pre>
    </div>

    <p>
    Try to ssh to the guest from host and compare fingerprints.
    </p>

    <div class="org-src-container">
    <pre class="src src-shell">ssh &lt;guest_IP&gt;
    </pre>
    </div>

    <hr />

    <p>
    Transfer host's public key to the guest with <code>scp(1)</code>.
    </p>

    <div class="org-src-container">
    <pre class="src src-shell">scp ~/.ssh/&lt;host_public_key&gt;.pub &lt;guest_user&gt;@&lt;guest_IP&gt;:
    </pre>
    </div>

    <p>
    Authorize host's public key on guest.
    </p>

    <div class="org-src-container">
    <pre class="src src-shell">cat &lt;host_public_key&gt;.pub &gt;&gt; ~/.ssh/authorized_keys
    </pre>
    </div>

    <p>
    It should be now possible to ssh to guest without credentials.
    </p>

    <div class="org-src-container">
    <pre class="src src-shell">ssh &lt;guest_user&gt;@&lt;guest_IP&gt;
    </pre>
    </div>

    <p>
    Consider adding entry to the <code>~/.ssh/config</code> to make it even easier.
    </p>

    <div class="org-src-container">
    <pre class="src src-example">Host &lt;name&gt;
    User &lt;guest_user&gt;
    HostName &lt;guest_IP&gt;
    IdentityFile ~/.ssh/&lt;host_private_key&gt;
    </pre>
    </div>

    <p>
    Now it's even better.
    </p>

    <div class="org-src-container">
    <pre class="src src-shell">ssh &lt;name&gt;
    </pre>
    </div>
    ]]></description>
  </item>
  <item>
    <title>crontab for individual users</title>
    <link>https://cdrmack.dev/posts/2024-10-16_crontab_for_individual_users.html</link>
    <author> (cdrmack)</author>
    <guid isPermaLink="false">https://cdrmack.dev/posts/2024-10-16_crontab_for_individual_users.html</guid>
    <pubDate>Wed, 16 Oct 2024 00:00:00 +0200</pubDate>

    <description><![CDATA[<p>
    I used to use root's <code>crontab(1)</code> even for things specific to my regular user.
    I didn't know that each user can have their own.
    </p>

    <p>
    Comparing to the root's <code>/etc/crontab</code> I don't have to specify as a "who" the command should be run.
    </p>

    <div class="org-src-container">
    <pre class="src src-shell">crontab -e
    </pre>
    </div>

    <pre class="example" id="org19c61ae">
    #minute	hour	mday	month	wday	command
    0	*	*	*	*	echo "do stuff every hour"
    </pre>
    ]]></description>
  </item>
  <item>
    <title>ssh agent</title>
    <link>https://cdrmack.dev/posts/2024-05-17_ssh_agent.html</link>
    <author> (cdrmack)</author>
    <guid isPermaLink="false">https://cdrmack.dev/posts/2024-05-17_ssh_agent.html</guid>
    <pubDate>Fri, 17 May 2024 00:00:00 +0200</pubDate>

    <description><![CDATA[<p>
    To use <code>ssh(1)</code> I first start <code>ssh-agent(1)</code>.
    I use <code>-c</code> to generate C-shell commands on stdout for csh-style shells and send that to <code>eval</code>.
    </p>

    <div class="org-src-container">
    <pre class="src src-shell">eval `ssh-agent -c`
    </pre>
    </div>

    <p>
    With ssh-agent running I use <code>ssh-add(1)</code> to add private key to it.
    </p>

    <div class="org-src-container">
    <pre class="src src-shell">ssh-add ~/.ssh/&lt;private_key&gt;
    </pre>
    </div>

    <p>
    That's it, <code>ssh-agent</code> will now hold that private key and use it for the public key authentication.
    If I want to list all identities currently represented by the agent I use <code>ssh-agent -l</code> command.
    </p>
    ]]></description>
  </item>
  <item>
    <title>amfora</title>
    <link>https://cdrmack.dev/posts/2024-04-04_amfora.html</link>
    <author> (cdrmack)</author>
    <guid isPermaLink="false">https://cdrmack.dev/posts/2024-04-04_amfora.html</guid>
    <pubDate>Thu, 04 Apr 2024 00:00:00 +0200</pubDate>

    <description><![CDATA[<p>
    If you want to play around with the <a href="https://geminiprotocol.net/">Gemini Protocol</a> on FreeBSD you can use program called <code>amfora</code> to view Gemini Capsules.
    It's a terminal browser easily available via <code>pkg(8)</code>.
    </p>

    <div class="org-src-container">
    <pre class="src src-shell">pkg install amfora
    </pre>
    </div>

    <p>
    When I run <code>amfora</code> I can press <code>?</code> to see list of shortcuts.
    </p>

    <p>
    My most used shortcuts:
    <code>1-0</code> go to links 0-10
    <code>SPC</code> enter address or link ID
    <code>b</code> go back in history
    <code>f</code> go forward in history
    <code>C-b</code> open bookmarks
    <code>C-d</code> add, change or remove bookmark
    </p>

    <p>
    If I want to go to the link "11" I press <code>SPC</code> and then provide link ID (11).
    </p>
    ]]></description>
  </item>
  <item>
    <title>fonts location</title>
    <link>https://cdrmack.dev/posts/2024-02-27_fonts_location.html</link>
    <author> (cdrmack)</author>
    <guid isPermaLink="false">https://cdrmack.dev/posts/2024-02-27_fonts_location.html</guid>
    <pubDate>Tue, 27 Feb 2024 00:00:00 +0100</pubDate>

    <description><![CDATA[<p>
    I've always stored my fonts inside the <code>~/.fonts</code> directory.
    </p>

    <p>
    I've decided to move all of them to <code>/usr/local/share/fonts/</code> after reading <code>/usr/local/etc/fonts/fonts.conf</code> file.
    </p>

    <div class="org-src-container">
    <pre class="src src-shell">&lt;!-- Font directory list --&gt;

    &lt;dir&gt;/usr/local/share/fonts&lt;/dir&gt;

    &lt;dir prefix="xdg"&gt;fonts&lt;/dir&gt;
    &lt;!-- the following element will be removed in the future --&gt;
    &lt;dir&gt;~/.fonts&lt;/dir&gt;
    </pre>
    </div>

    <p>
    Based on the comment "the following element will be removed in the future" I think it's safe to assume that <code>~/.fonts</code> might stop working at some point.
    </p>

    <p>
    Remember to run <code>fc-cache(1)</code> to scan the font directories and build cache files.
    I usually run it with <code>-f</code> flag to force re-generation.
    </p>
    ]]></description>
  </item>
  <item>
    <title>wg-quick</title>
    <link>https://cdrmack.dev/posts/2023-11-28_wg_quick.html</link>
    <author> (cdrmack)</author>
    <guid isPermaLink="false">https://cdrmack.dev/posts/2023-11-28_wg_quick.html</guid>
    <pubDate>Tue, 28 Nov 2023 00:00:00 +0100</pubDate>

    <description><![CDATA[<p>
    After upgrading my system to FreeBSD 14.0, I've decided to finally try WireGuard.
    I didn't have to install it manually since it's now part of the FreeBSD kernel.
    </p>

    <p>
    Rather than use <code>wg(8)</code> directly, I've decided to play around with <code>wg-quick(8)</code> (<code>wireguard-tools</code> package).
    </p>

    <div class="org-src-container">
    <pre class="src src-shell">pkg install wireguard-tools
    </pre>
    </div>

    <p>
    WireGuard supports INI-like config files, see the example below (taken from the <code>wg(8)</code>).
    </p>

    <pre class="example" id="org3092431">
    [Interface]
    PrivateKey = yAnz5TF+lXXJte14tji3zlMNq+hd2rYUIgJBgB3fBmk=
    ListenPort = 51820

    [Peer]
    PublicKey = xTIBA5rboUvnH4htodjb6e697QjLERt1NAB4mZqp8Dg=
    Endpoint = 192.95.5.67:1234
    AllowedIPs = 10.192.122.3/32, 10.192.124.1/24
    </pre>

    <p>
    I've put few config files from my provider inside <code>/usr/local/etc/wireguard/</code>.
    These files can be used to add and set up interfaces.
    </p>

    <div class="org-src-container">
    <pre class="src src-shell">wg-quick up /etc/wireguard/sample.conf
    </pre>
    </div>

    <p>
    I can skip the full path and just use the config name.
    </p>

    <div class="org-src-container">
    <pre class="src src-shell">wg-quick up sample
    </pre>
    </div>

    <p>
    This works because <code>wg-quick</code> looks for configs inside <code>/usr/local/etc/wireguard/</code> directory.
    </p>

    <p>
    When I'm done with the given interface I use <code>wg-quick down</code> to tear it down.
    </p>

    <div class="org-src-container">
    <pre class="src src-shell">wg-quick down sample
    </pre>
    </div>

    <p>
    To show current WireGuard configuration and runtime information I simply call <code>wg</code>.
    </p>
    ]]></description>
  </item>
  <item>
    <title>emacs server</title>
    <link>https://cdrmack.dev/posts/2023-11-04_emacs_server.html</link>
    <author> (cdrmack)</author>
    <guid isPermaLink="false">https://cdrmack.dev/posts/2023-11-04_emacs_server.html</guid>
    <pubDate>Sat, 04 Nov 2023 00:00:00 +0100</pubDate>

    <description><![CDATA[<p>
    I start Emacs in "server-mode" alongside my graphical environment.
    Whenever I want to use it, everything is already loaded and ready to go.
    Thanks to that, from my perspective it opens pretty much instantly.
    </p>

    <p>
    It can be easily set by editing <code>~/.xinitrc</code> file.
    This file is being used by <code>xinit(1)</code> to start the X Window System server and a first client program.
    </p>

    <div class="org-src-container">
    <pre class="src src-shell"># .xinitrc
    # ...
    emacs --daemon
    # ...
    </pre>
    </div>

    <p>
    According to <code>emacs(1)</code> the <code>emacs --daemon</code> command starts Emacs as daemon (o rly?), enables Emacs server and disconnects from the terminal.
    </p>

    <p>
    With server running in the background, I can connect to it with the <code>emacsclient(1)</code> command.
    </p>

    <div class="org-src-container">
    <pre class="src src-shell">% emacsclient -c -a ""
    </pre>
    </div>

    <p>
    To create a new frame, the flag <code>-c</code> is used.
    This is particularly useful when Emacs is already open but I don't want to reuse the existing frame.
    The second flag, <code>-a</code>, initiates an alternate editor if the Emacs server is not running.
    If it is left empty, as in this case, it runs <code>emacs --daemon</code> and attempts to connect to it.
    </p>

    <p>
    To make my life easier, I've placed that line in a file named <code>ec</code>, made it executable, and saved it in a directory within my <code>PATH</code> (<code>/usr/local/bin/</code>, to be specific).
    Now, I can launch Emacs client just like any other program.
    </p>
    ]]></description>
  </item>
</channel>
</rss>
