<?xml version="1.0" encoding="utf-8" ?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title>Fun with ones and zeros</title>
<subtitle>Barry&#039;s notes on computer software and hardware</subtitle>
<link href="/blog"></link>
<updated>2026-05-03T03:08:58-07:00</updated>
<id>urn:uuid:80dc4343-4f43-6b46-3253-25bc9ec29072</id>
<entry>
<title>SNMP server not reporting disk size</title>
<link href="/blog/entries/snmp-server-not-reporting-disk-size"></link>
<id>urn:uuid:69d36474-60b6-0039-5d8d-e9bb77426a60</id>
<updated>2024-02-29T12:21:00-08:00</updated>
<author><name>Barry Pederson</name>
<email>bp@barryp.org</email>
</author>
<content type="html">&lt;p&gt;I was setting up snmpd on an Ubuntu box, and noticed that it was reporting weird numbers
for a couple of XFS filesystems I had setup for Minio.&lt;/p&gt;
&lt;p&gt;An snmpwalk showed values like this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;HOST-RESOURCES-MIB::hrStorageType.51 = OID: HOST-RESOURCES-TYPES::hrStorageFixedDisk
HOST-RESOURCES-MIB::hrStorageType.52 = OID: HOST-RESOURCES-TYPES::hrStorageFixedDisk
...
HOST-RESOURCES-MIB::hrStorageDescr.51 = STRING: /minio/disk1
HOST-RESOURCES-MIB::hrStorageDescr.52 = STRING: /minio/disk2
...
HOST-RESOURCES-MIB::hrStorageAllocationUnits.51 = INTEGER: 0 Bytes
HOST-RESOURCES-MIB::hrStorageAllocationUnits.52 = INTEGER: 0 Bytes
...
HOST-RESOURCES-MIB::hrStorageSize.51 = INTEGER: 0
HOST-RESOURCES-MIB::hrStorageSize.52 = INTEGER: 0
...
HOST-RESOURCES-MIB::hrStorageUsed.51 = INTEGER: 0
HOST-RESOURCES-MIB::hrStorageUsed.52 = INTEGER: 0&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;So it was reporting the existence of the disks, but with all 0 values.  The root ext4 filesystem showed up fine,
was it something to do with XFS?  &lt;/p&gt;
&lt;p&gt;Turns out the answer was NO, it was the permissions of the /minio directory
that the filesystems were mounted under.  I figured this out when I noticed
that &lt;code&gt;df -h&lt;/code&gt; showed the disks when I was running as root&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;/dev/sdb1        60G  461M   60G   1% /minio/disk1
/dev/sdc1        60G  461M   60G   1% /minio/disk2&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;But when running as non-root, such as the Debian-snmp user, &lt;code&gt;df -h&lt;/code&gt; didn&#039;t show the disks at all.&lt;/p&gt;
&lt;p&gt;Turns out I had been too strict with the permissions on &lt;code&gt;/minio&lt;/code&gt;, I had originally set that to&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;drwx------   4 minio-user root       4096 Feb 14 14:57 minio&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;But that apparently, and to my surprise, prevented snmpd from being able to read the size and usage
information for the mounts under that directory.  Changing that to &lt;code&gt;0755&lt;/code&gt; fixed the problem, and I just
made sure that the mountpoints had more strict permissions&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;drwxr-x--- 3 minio-user root 24 Feb 27 13:08 disk1
drwxr-x--- 3 minio-user root 24 Feb 27 13:08 disk2&lt;/code&gt;&lt;/pre&gt;</content>
</entry>
<entry>
<title>Proxmox NIC pass-through and machine type</title>
<link href="/blog/entries/proxmox-nic-passthrough"></link>
<id>urn:uuid:0208978d-4433-b81c-a9d3-d6c40130b13f</id>
<updated>2023-07-11T09:15:00-07:00</updated>
<author><name>Barry Pederson</name>
<email>bp@barryp.org</email>
</author>
<content type="html">&lt;p&gt;I picked up a little Topton fanless server a while back, that comes with 4 x 2.5Gb Intel i226 NICs, and
wanted to try running an OpenBSD VM on Proxmox with NIC pass-through.  There are some fairly
detailed &lt;a href=&quot;https://www.servethehome.com/how-to-pass-through-pcie-nics-with-proxmox-ve-on-intel-and-amd&quot;&gt;instructions on servethehome.com&lt;/a&gt;, but one important thing I found they left out was
the Proxmox &amp;quot;Machine&amp;quot; setting.  &lt;/p&gt;
&lt;p&gt;The default seems to be &amp;quot;i440fx&amp;quot;, and with that default I was sort of seeing the NIC inside OpenBSD, but with dmesg
entries like:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;igc0 at pci0 dev 16 function 0 &quot;Intel I226-V&quot; rev 0x04: not enough msi-x vectors
igc0: unable to map msi-x vector 0&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;and the interface wouldn&#039;t actually show up in &lt;code&gt;ifconfig&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;After finally finding some hints on the web that the &lt;code&gt;q35&lt;/code&gt; machine type adds PCIe support, I gave that a try
and now the &lt;code&gt;igc0&lt;/code&gt; interface on OpenBSD seems to be working!&lt;/p&gt;</content>
</entry>
<entry>
<title>Automatically restarting Percona XtraDB cluster</title>
<link href="/blog/entries/automatically-restarting-percona-xtradb-cluster"></link>
<id>urn:uuid:d1a316dd-db76-abce-d158-d28ddf61c8de</id>
<updated>2023-02-01T10:05:00-08:00</updated>
<author><name>Barry Pederson</name>
<email>bp@barryp.org</email>
</author>
<content type="html">&lt;body&gt;&lt;p&gt;I&#039;ve been experimenting with Percona XtraDB cluster, and found that by default it requires manual intervention
to restart the cluster from an all-nodes-down state when the nodes were gracefully shutdown.  The docs talk about
identifying which node has &lt;code&gt;safe_to_bootstrap: 1&lt;/code&gt; in it&#039;s &lt;code&gt;/var/lib/mysql/grastate.dat&lt;/code&gt; file, and on that node starting
the &lt;code&gt;mysql@boostrap&lt;/code&gt; service instead of just plain &lt;code&gt;mysql&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Looking at a file and acting on what&#039;s found seems like something that could be automated, so here&#039;s my take for an
Ubuntu 22.04 setup:&lt;/p&gt;
&lt;p&gt;On each node (yay Ansible!) I added this script as &lt;code&gt;/usr/local/sbin/choose-mysql-service.sh&lt;/code&gt;&lt;/p&gt;
&lt;div class=&quot;source&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class=&quot;ch&quot;&gt;#!/bin/bash&lt;/span&gt;

&lt;span class=&quot;nv&quot;&gt;GRASTATE&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;/var/lib/mysql/grastate.dat&quot;&lt;/span&gt;

&lt;span class=&quot;nv&quot;&gt;service&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;mysql&quot;&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# Start a different service if grastate.dat is present&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;# with safe_to_bootstrap: 1&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;#&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;-f&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$GRASTATE&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;k&quot;&gt;then&lt;/span&gt;
&lt;span class=&quot;w&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;grep&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;--quiet&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;^safe_to_bootstrap: 1&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$GRASTATE&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;k&quot;&gt;then&lt;/span&gt;
&lt;span class=&quot;w&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;service&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;mysql@bootstrap&quot;&lt;/span&gt;
&lt;span class=&quot;w&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;k&quot;&gt;fi&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;fi&lt;/span&gt;

&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Starting &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$service&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;
systemctl&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;start&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$service&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Then I added a one-shot systemd unit to execute at boot time, as &lt;code&gt;/etc/systemd/system/choose-mysql-service.service&lt;/code&gt;&lt;/p&gt;
&lt;div class=&quot;source&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;[Unit]&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;Description&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Choose MySQL service&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;After&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;network.target&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;[Service]&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;Type&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;oneshot&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;ExecStart&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;/usr/local/sbin/choose-mysql-service.sh&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;RemainAfterExit&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;true&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;[Install]&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;WantedBy&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;multi-user.target&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;And the disabled the default &lt;code&gt;mysql&lt;/code&gt; service and enabled my new unit with:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;systemctl daemon-reload
systemctl disable mysql
systemctl enable choose-mysql-service&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;So now when the OS boots, instead of just blindly trying to start &lt;code&gt;mysql&lt;/code&gt;, it looks at the &lt;code&gt;grastate.dat&lt;/code&gt; and if it has &lt;code&gt;safe_to_bootstrap: 1&lt;/code&gt; it starts &lt;code&gt;mysql@bootstrap&lt;/code&gt; instead - or otherwise falls back to the default of starting &lt;code&gt;mysql&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;I also shared this on the &lt;a href=&quot;https://forums.percona.com/t/pxc-8-auto-restart-after-graceful-shutdown/19850&quot;&gt;Percona Forum&lt;/a&gt;, look for feedback there&lt;/p&gt;&lt;/body&gt;</content>
</entry>
<entry>
<title>mysqldump: Got error: 1049: Unknown database when using LOCK TABLES</title>
<link href="/blog/entries/mysqldump-error-unknown-database"></link>
<id>urn:uuid:605a9e4c-5df3-8995-4cbd-1d9b69dcf27a</id>
<updated>2022-12-22T14:56:00-08:00</updated>
<author><name>Barry Pederson</name>
<email>bp@barryp.org</email>
</author>
<content type="html">&lt;p&gt;Ran in to a confusing error message today:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;mysqldump: Got error: 1049: Unknown database &#039;mydb&#039; when using LOCK TABLES&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I did have a database named &lt;code&gt;mydb&lt;/code&gt; and then deleted it the other day.  Later when doing
some scripted mysqldumps of other databases, I got that message.  Why in the world was it trying
to lock a database I knew to be gone?&lt;/p&gt;
&lt;p&gt;Turns out one of my other dbs was referencing the deleted db in a VIEW.  Hope that helps&lt;/p&gt;</content>
</entry>
<entry>
<title>UFW and LXC/LXD on Ubuntu 22.04</title>
<link href="/blog/entries/ufw-and-lxd-lxd-on-ubuntu-2204"></link>
<id>urn:uuid:ba108f66-11c7-a676-de98-f224eadd4027</id>
<updated>2022-05-26T10:00:00-07:00</updated>
<author><name>Barry Pederson</name>
<email>bp@barryp.org</email>
</author>
<content type="html">&lt;p&gt;I recently setup a new Ubuntu server with LXC containers.  At first it all went great, but then
later when I enabled UFW, things got flaky.  Looking at &lt;code&gt;/var/log/syslog&lt;/code&gt; I saw UFW was blocking
lots of traffic from inside the containers.  &lt;/p&gt;
&lt;p&gt;Also when restarting a container, the container wouldn&#039;t get one of the bridged &lt;code&gt;10.x.x.x&lt;/code&gt; IP addresses.&lt;/p&gt;
&lt;p&gt;After Googling a bit, I found the magic commmands on &lt;a href=&quot;https://discuss.linuxcontainers.org/t/lxd-bridge-doesnt-work-with-ipv4-and-ufw-with-nftables/10034/16&quot;&gt;this discussion&lt;/a&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;ufw allow in on lxdbr0
ufw route allow in on lxdbr0&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In hindsight, I think it would have been better to enable &lt;code&gt;ufw&lt;/code&gt; &lt;em&gt;before&lt;/em&gt; doing anything else with the new install,
that way the problems would have been more obvious right away - rather than it being a &amp;quot;geez, it was working before&amp;quot;
type situation.&lt;/p&gt;</content>
</entry>
</feed>