<?xml version="1.0" encoding="utf-8" ?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title>Fun with ones and zeros - linux</title>
<subtitle>Barry&#039;s notes on computer software and hardware</subtitle>
<link href="/blog/tags/linux"></link>
<updated>2026-04-29T10:52:52-07:00</updated>
<id>urn:uuid:57ef58bb-776d-4925-e118-49addf32217e</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>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>
<entry>
<title>RancherOS/ISOLinux/Syslinux on FreeBSD bhyve</title>
<link href="/blog/entries/rancheros-isolinux-syslinux-on-freebsd-bhyve"></link>
<id>urn:uuid:a217b258-34e7-9643-172a-e8e7ccbdd3e5</id>
<updated>2018-10-05T07:35:00-07:00</updated>
<author><name>Barry Pederson</name>
<email>bp@barryp.org</email>
</author>
<content type="html">&lt;p&gt;After messing with Docker on my laptop, I thought it would be interesting to setup a VM on my FreeBSD server to
run  &lt;a href=&quot;https://rancher.com/rancher-os/&quot;&gt;RancherOS&lt;/a&gt;.  I&#039;ve been using &lt;a href=&quot;https://www.freshports.org/sysutils/vm-bhyve&quot;&gt;vm-bhyve&lt;/a&gt; to manage the VMs, and have been running Ubuntu
without much problem, so I figured another Linux distro would be fine ... but ended up opening a whole can of worms
and while I did get it running eventually, I learned more about grub and booting on bhyve than I really wanted.&lt;br /&gt;
I thought I&#039;d jot down some notes here for future reference.&lt;/p&gt;
&lt;p&gt;To start with, bhyve is not a general hypervisor that can boot any PC-compatible disk or CD image you throw at it,
the way something like KVM, VMWare, or Parallels can.  It doesn&#039;t start a VM in 16-bit mode and go through an
old-school BIOS boot sequence where it reads a Master Boot Record and executes whatever&#039;s there.   It knows how
to load a FreeBSD kernel, and with &lt;a href=&quot;https://www.freshports.org/sysutils/grub2-bhyve&quot;&gt;grub2-bhyve&lt;/a&gt; it can boot disks and CDs that use Grub2 - such as Ubuntu.  &lt;/p&gt;
&lt;p&gt;Unfortunately, RancherOS doesn&#039;t use grub, instead it uses &lt;a href=&quot;https://www.syslinux.org&quot;&gt;Syslinux/ISOLinux&lt;/a&gt; on their ISO images and
harddisk installations.  When bhyve boots using the grub loader, it doesn&#039;t find any grub menu on the disk, and just
drops you into a grub command prompt.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;GNU GRUB  version 2.00

Minimal BASH-like line editing is supported. For the first word, TAB
lists possible command completions. Anywhere else TAB lists possible
device or file completions.

grub&amp;gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Fortunately, the grub commandline is like a mini-os, with lots of abilities to look around the disks, and it
turns out manually boot things like RancherOS.  &lt;/p&gt;
&lt;p&gt;The first command to run is:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;set pager=1&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;so that future commands don&#039;t just scroll off the screen.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;help&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;displays a list of commands, &lt;code&gt;help &amp;lt;command&amp;gt;&lt;/code&gt; gives a short explanation. &lt;code&gt;ls&lt;/code&gt; lets you start poking around, in this
case giving:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(cd0) (cd0,msdos1) (host)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now we&#039;re getting somewhere.  Trying &lt;code&gt;ls (cd0)&lt;/code&gt; gives&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Device cd0: Filesystem type iso9660 - Label `RancherOS&#039; - Last modification time 2018-09-19 03:09:12 Wednesday, UUID 2018-09-19-03-09-12-00 - Total size 176128 sectors&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;ls -l (cd0)/&lt;/code&gt; gives &lt;/p&gt;
&lt;pre&gt;&lt;code&gt;DIR          20180919030909 boot/
DIR          20180919030912 rancheros/&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;OK, a boot directory, getting closer. &lt;code&gt;ls -l (cd0)/boot&lt;/code&gt; gives&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;170          20180919030909 global.cfg
66978212     20180919030909 initrd-v1.4.1
DIR          20180919030909 isolinux/
1373         20180919030909 linux-current.cfg
12734        20180919030909 rancher.png
5523216      20180919030909 vmlinuz-4.14.67-rancher2&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;There we go, isolinux, but no grub files, no wonder it doesn&#039;t boot.  After lots and lots of messing around learning
grub, I was able to get an initial boot of the CD image from the grub&amp;gt; prompt with:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;linux (cd0)/boot/vmlinuz-4.14.67-rancher2
initrd (cd0)/boot/initrd-v1.4.1
boot&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And it started!  After lots of Linux boot output  I was rewarded with:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;                ,        , ______                 _                 _____ _____TM
   ,------------|&#039;------&#039;| | ___ \               | |               /  _  /  ___|
  / .           &#039;-&#039;    |-  | |_/ /__ _ _ __   ___| |__   ___ _ __  | | | \ &#039;--.
  \/|             |    |   |    // _&#039; | &#039;_ \ / __| &#039;_ \ / _ \ &#039;__&#039; | | | |&#039;--. \
    |   .________.&#039;----&#039;   | |\ \ (_| | | | | (__| | | |  __/ |    | \_/ /\__/ /
    |   |        |   |     \_| \_\__,_|_| |_|\___|_| |_|\___|_|     \___/\____/
    \___/        \___/     Linux 4.14.67-rancher2

    RancherOS #1 SMP Thu Sep 13 15:37:04 UTC 2018 rancher ttyS0
    docker-sys: 172.18.42.1 eth0: 10.66.0.48 lo: 127.0.0.1
rancher login:&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Very cool, but what&#039;s the login?  Userid is &lt;code&gt;rancher&lt;/code&gt;, but there is no default password.  According to the rancher
docs, the ISO image is supposed to auto-login.  Now what?&lt;/p&gt;
&lt;p&gt;After rebooting and getting back to the grub&amp;gt; prompt, and digging around more, I found that
&lt;code&gt;cat (cd0)/boot/global.cfg&lt;/code&gt; showed:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;APPEND rancher.autologin=tty1 rancher.autologin=ttyS0 rancher.autologin=ttyS1 rancher.autologin=ttyS1 console=tty1 console=ttyS0 console=ttyS1 printk.devkmsg=on panic=10&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Ah, LInux command parameters including autologin stuff. To apply them it ended up being (again at the grub&amp;gt; prompt):&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;linux (cd0)/boot/vmlinuz-4.14.67-rancher2 rancher.autologin=tty1 rancher.autologin=ttyS0 rancher.autologin=ttyS1 rancher.autologin=ttyS1 console=tty1 console=ttyS0 console=ttyS1 printk.devkmsg=on panic=10
initrd (cd0)/boot/initrd-v1.4.1
boot&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;(that commandline could probably be simplified since we can see from the banner that our VM console is ttyS0, so we
probably don&#039;t need the params relating to tty1 or ttyS1)
This time I got the cattle banner from above, and a beautiful:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Autologin default
[rancher@rancher ~]$&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;A simple &lt;code&gt;sudo -s&lt;/code&gt; (not requiring a password) gives root access.  At that point you can do whatever, including
installing onto a harddisk.   &lt;/p&gt;
&lt;p&gt;To get a RancherOS harddisk installation to boot, you&#039;d have to go through similar steps with grub in exploring around
the (hd0,1) disk to find the kernel, initrd, and kernel params.  The grub commands for booting can be saved permanently
in the vm-bhyve config for this machine with &lt;code&gt;grub_runX&lt;/code&gt; lines like:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;grub_run0=&quot;linux (hd0,1)/boot/vmlinuz-4.14.67-rancher2 rancher.autologin=ttyS0 printk.devkmsg=on rancher.state.dev=LABEL=RANCHER_STATE rancher.state.wait panic=10 console=tty0&quot;
grub_run1=&quot;initrd (hd0,1)/boot/initrd-v1.4.1&quot;
grub_run2=&quot;boot&quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;So the full vm-bhyve config file looks like (in case you&#039;re wondering - I hate it when people give snippets of code
but don&#039;t show where it should go exactly):&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;loader=&quot;grub&quot;
grub_run0=&quot;linux (hd0,1)/boot/vmlinuz-4.14.67-rancher2 rancher.autologin=ttyS0 printk.devkmsg=on rancher.state.dev=LABEL=RANCHER_STATE rancher.state.wait panic=10 console=tty0&quot;
grub_run1=&quot;initrd (hd0,1)/boot/initrd-v1.4.1&quot;
grub_run2=&quot;boot&quot;
cpu=2
memory=2048M
network0_type=&quot;virtio-net&quot;
network0_switch=&quot;public&quot;
disk0_type=&quot;virtio-blk&quot;
disk0_name=&quot;disk0&quot;
disk0_dev=&quot;sparse-zvol&quot;
uuid=&quot;7f9fc9e5-c835-11e8-a327-e03f49af0c7d&quot;
network0_mac=&quot;58:9c:fc:05:2a:04&quot;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;With that, my VM now boots without manual intervention, even though the virtual disk doesn&#039;t use grub.&lt;/p&gt;</content>
</entry>
<entry>
<title>Winbind failure do to incorrect time</title>
<link href="/blog/entries/winbind-failure"></link>
<id>urn:uuid:4accc925-c421-25c5-9e18-0ed7c06a12ba</id>
<updated>2015-07-08T09:51:00-07:00</updated>
<author><name>Barry Pederson</name>
<email>bp@barryp.org</email>
</author>
<content type="html">&lt;p&gt;I had the weirdest thing suddenly start happening last night that took several hours to finally figure out was a time-related issue.&lt;/p&gt;
&lt;p&gt;I&#039;ve got an Ubuntu box that uses &lt;code&gt;pam_winbind&lt;/code&gt; to allow for logging into a machine using an Active Directory account.&lt;br /&gt;
Normally I connect with an SSH key, but once in when doing &lt;code&gt;sudo -s&lt;/code&gt; I enter an AD password to become root.  Last night
that &lt;code&gt;sudo -s&lt;/code&gt; suddenly stopped working.  &lt;/p&gt;
&lt;p&gt;Luckily I had another non-AD account that I could connect with, and sudo worked for that, so I could become root and poke around.  The logs showed:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;sudo: pam_unix(sudo:auth): authentication failure; logname=barry.pederson uid=14283 euid=0 tty=/dev/pts/0 ruser=barry.pederson rhost=  user=barry.pederson
sudo: pam_unix(sudo:auth): conversation failed
sudo: pam_unix(sudo:auth): auth could not identify password for [barry.pederson]&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;That was weird, I could log into other things though that used the same AD account, so I knew the password was right and the account wasn&#039;t locked out.  &lt;/p&gt;
&lt;p&gt;I hoped by the next morning, some cache thing would expire and I&#039;d be back in business, but no dice.  &lt;/p&gt;
&lt;p&gt;Poking around some more I found if I disabled my SSH keys, I couldn&#039;t log in at all, so it was really a &lt;code&gt;pam_winbind&lt;/code&gt; issue, not  a &lt;code&gt;sudo&lt;/code&gt; one.  The logs for a SSH password login attempt were a bit more informative:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=xxx.yyy.zzz  user=barry.pederson
pam_winbind(sshd:auth): getting password (0x00000388)
pam_winbind(sshd:auth): pam_get_item returned a password
pam_winbind(sshd:auth): request wbcLogonUser failed: WBC_ERR_AUTH_ERROR, PAM error: PAM_AUTH_ERR (7), NTSTATUS: NT_STATUS_LOGON_FAILURE, Error message was: Logon failure
pam_winbind(sshd:auth): user &#039;barry.pederson&#039; denied access (incorrect password or invalid membership)
Failed password for barry.pederson from x.x.x.x port 50655 ssh2&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;WTF?  I know the password&#039;s right, I&#039;ve been typing it all morning into other systems.  I even tried &lt;code&gt;wbinfo --authenticate barry.pederson&lt;/code&gt; on this box and it accepted my passwords.&lt;/p&gt;
&lt;p&gt;Much time was spent Googling, trying various tweaks to &lt;code&gt;smb.conf&lt;/code&gt;, etc.  Finally, I don&#039;t remember why, I thought to check the date with &lt;code&gt;ntpdate -d my.ad.server&lt;/code&gt; and it came back with &lt;code&gt;offset -338.308573 sec&lt;/code&gt;.  Holy crap, that&#039;s more than 5 minutes!  Even though ntpd is running.  &lt;/p&gt;
&lt;p&gt;Anyhow, once the clock was fixed to be closer to the AD server, logins and sudo started working again.&lt;/p&gt;</content>
</entry>
</feed>