My wife has a fever. Did she get COVID-19? I hope not! Currently, it’s just a big headache and she’s super tired.
I bought a 1TB card for the Raspberry Pi. I have an old one, a model 1B. A week ago I used an old 16 GiB card with a version of Debian Buster on it, upgraded it to Bullseye, and deleted all the stuff I felt was unnecessary. It took me a very long time. All I really wanted was to have it run `mpd` (a music server).
This is how it went, based on some posts I made on Mastodon:
Trying to get either a very old Raspberry Pi to work, or a Raspberry Pi 4 to work, staring at blank monitors and red lights that light or not, and feeling very much not like a maker.
OK, this old Raspberry Pi seems to be a model 1 B: with 2× USB, HDMI, and 512 MB. Sadly, sudo apt update says the release is not going to be valid over a thousand days. I wonder what this means.
Ah. `apt-get update --allow-releaseinfo-change` appears to be the solution. And now `apt-get dist-upgrade` seems to work as well. I’ll consider this a warmup exercise as it’s all on a 16 GiB SD card which is much too small for what I need: I want to use this Raspberry Pi as an audio player. Ideally it’d have no monitor, just a speaker and a keyboard, and I’d use `cmus` or something like that. And then I’ll complain about a lack of screen reader support or so.
I feel transported back into the nineties, trying to remove all the cruft from this Raspberry Pi. Removing Python 2 + 3, Ruby, Node, Libre Office, GCC, X11, and on and on, before finally updating the `sources.list` and now upgrading to Debian Bullseye. Wheee!
Well… I think I removed one too many libraries. We’ll see. I think I needed to add systemd-logind and systemd-timeservice back or something like that. It’s too late now and I have to sleep. I got `sshd` to work, I installed a key for me to ssh into the Raspberry Pi, I installed `mpd` and `cmus`, I uploaded to MP3 files, I got them to play … but there was no sound. Is there no sound on the Raspberry 1? I think there is because I see the headphone jack. So perhaps I uninstalled some audio library? I removed so much: Python, Ruby, Node, Java, X11 (mpd added x11-common back in), so I’m working from the console, now. I guess it still needs pulseaudio or something? In the old days it was ALSA! Perhaps that’s what I need. But not today. It’s 3am. That’s what I get for sysadmin fiddling after boardgame night… 🤦
Installed pulseaudio, which installed more stuff. Still no audio. Discovered I still had lots of packages in oldstable and ran `sudo apt full-upgrade` which I had forgotten (after `upgrade` and `dist-upgrade`). Still no sound. Discovered that there was another file in `/etc/apt/sources.list.d/` so doing yet another `update` and `upgrade`. I am getting tired of this.
Stuff is still borked. `omxplayer` can’t start because it can’t find `libbrcmGLESv2.so`; `aplayer` plays WAV files on the headset (connected via USB), so doesn’t use what I still hope is the audio out → ALSA uses the USB audio output instead of whatever hardware it ought to have, and omxplayer which should be using the same output is borked; `cmus` also uses the headphones (obviously, as it ends up using ALSA). Me connecting from my laptop using `gmpc` to the `mpd` running can “play” a file but the music cannot be heard anywhere. So what now? I’m going to make myself some dinner. I really just should have bought a new and shiny player for $300. That would have been a better use of my time, that’s what I’m starting to think.
Just as I was about to get up, I think I found the solution: `pacmd list-sinks` lists the sinks, with the USB sink being marked as the default, and `pacmd set-default-sink 2` let me pick the “headphones” sink as the new default. And it works, in as far as aplay uses it, `cmus` also uses it. No idea where `mpd`/`gmpc` sends the audio input to. I think I will just add `cmus` to my `.bashrc` and we’ll see whether I can use it blind. After all, I just want to play many gigabytes of Jazz stuff from the Internet Archive, these days.
And now that I hooked the Raspberry Pi up to the small loudspeaker in the living room, it turns out that `mpd` works just as well. For a while I had `cmus` and `mpd` both playing music. But due to I don’t now what, `ssh` no longer works. So I’ll have to move the little box to a monitor again so I can fix that and upload a few more MP3 files. And then I can go shopping for a larger SD card so that the 75 GiB of The David W. Niven Jazz Collection and the 29 GiB of the 78rpm collection will fit. Plus all the other stuff… 😄
What confused me now: It’s time for bed. I can `ssh` into the Raspberry Pi to `sudo shutdown now` and unplug it. Or just leave it doing nothing? How much is it actually doing? Is the electricity use significant for a Raspberry 1? How would I find out? It depends on load, I’d say? Or can I only find out by measuring it using some tool? What about the heuristic of “touch it” (or the power converter, I guess) and if it’s not warm to the touch it’s not worth considering? Somehow, in the age of global warming (but also in the age of phones and tables being constantly on, more or less) this is either perverse or a misplaced concern and I don’t know where to start.
This time I’m starting with a Debian base system for the Raspberry Pi!
This Web site is built to help you get Debian GNU/Linux easily running if you have a computer of the Raspberry Pi family. – Raspberry Pi Debian images
All right.
I downloaded a tested image, verified the checksum, identified the device for the card reader and flashed the file. Yay! Unplugging and replugging the card gives me two mounted partitions.
I found `sysconf.txt` in one of the partitions and set `hostname` but it seemed to have no effect. I ended up discovering that the Raspberry Pi was `rpi1-20221010` by looking at the list of devices connected to the router. Routers these days have integrated webservers. It’s weird.
I could ping it and I could ssh into the machine because I had set `root_authorized_key`. Strange, that setting did have an effect! `ssh root@rpi1-20221010` was the magic incantation.
Updating and upgrading the system is taking a long time. This machine only has 512 MiB of RAM!
I wondered whether the name `rpi1-20221010` was being used because DHCP wasn’t working correctly and so I installed `dhcpcd` instead of `isc-dhcp-client`, and I removed `isc-dhcp-common`. That didn’t really help but since `isc-dhcp-client` said that it was going to be deprecated I left it as it is. I then installed `avahi-daemon` since I suspected I needed something about Bonjour or zeroconf and that seemed to be it. I’m just not sure what part of it! Now the Raspberry Pi runs `bind9`. I’m not sure this is a great idea. But `ping raspberrypi.local` now works!
I installed `locales` because I was getting errors from `perl` when I connected to the machine via `ssh`:
perl: warning: Setting locale failed.
I ran `dpkg-reconfigure locales` to setup `en_US.UTF-8`.
I installed `rsync` because I want to be able to sync files without transferring them again and again or writing scripts to determine exactly which files need transferring.
And then, of course, I have all the music files to transfer! Oh my. Perhaps if both the Raspberry Pi and the laptop connected directly to the external disc (an old Apple Powerbook, probably with an old version of `rsync`).
While the files are transferring I installed `mpd`. Strangely, it comes disabled, so `systemctl enable mpd` and `systemctl start mpd` was required. Something else was required but I didn’t figure it out. Rebooting the system started or did whatever was required. My client on the phone can connect! When I look at the Library, it takes forever to index the 7.3 GiB of files I added. I dread the indexing when the rest of the files are on the card.
I installed `mpc` in order to test it. `mpc add /var/lib/mpd/music/…` to add a file and `mpc play` to play it showed that it ran into an error. No sound! I wondered whether I’d be happy with just ALSA and decided against it. I installed `pulseaudio` to get “everything” and did a `systemctl restart mpd`. Still nothing. Plugged the headphones in. Rebooting.
After a reboot: `pacmd list-sinks` says: “No PulseAudio daemon running, or not running as session daemon.”
How frustrating. Let’s try `alsa-utils`. OK, `aplay /usr/share/sounds/alsa/Rear_Right.wav` works!
Let’s use ALSA. `alsactl info` gives us the “sound cards” the system knows and the first one has the id “Headphones”.
In `/etc/mpd.conf`, uncomment the following lines:
audio_output { type "alsa" name "Headphones" }
And now it’s working!
Let’s get rid of PulseAudio: `apt remove pulseaudio && apt auto-remove`
Looking back at all of this, I feel both pride in knowing so much, or being able to guess what’s missing, and shame for it all being so complicated. So incredibly complicated. It’s now five hours later. Five hours! I feel like billing somebody $1000.
#RaspberryPi #Administration
The laptop also doesn't mount the card any more.
It looks so small. So neat. Nobody would think it dead.
But dead it is. Smiling in that way only small SD cards can smile, happy at last. No more work. The endless weekend ahead of it.
Good bye, little one.
I found an emergency 4GiB card in the camera's bag. I'll but Debian for Raspberry 1B on it. We'll see how it goes.
Check it:
sha256sum -c 20231109_raspi_1_bookworm.img.xz.sha256
Good.
Looking at the output of `mount` I think the disc is `/dev/sdb`.
Let's write it!
umount /dev/sdb* xzcat 20231109_raspi_1_bookworm.img.xz \ | sudo dd of=/dev/sdb bs=64k oflag=dsync status=progress
And it boots! After a long time: `rpi1-20231109` login!
Login as `root`. No password.
First, the wireless network…
vi /etc/network/interfaces.d/wlan0
Uncomment the lines and provide SSID and password.
(Note: For the Raspberry Pi 4 which has an integrated WLAN, I didn't uncomment the line containing inet6. When I tried it, I got only an IPv6 number, not both an IPv4 and an IPv6 and then `apt updated` and friends wouldn't work.)
Back to the story:
ifup wlan0
Let it run until it says "wlan0: link becomes ready". At this point it starts printing something about "PRC: Lease failed to satisfy." Now you can quit using Ctrl-C.
But then:
iw wlan0 link
This worked.
ip a
This listed stuff! And the `ping` worked.
Thank you, How to Set Up Wi-Fi on Debian (3 ways).
How to Set Up Wi-Fi on Debian (3 ways)
And now:
apt update && apt upgrade
Change the timezone:
dpkg-reconfigure tzdata
Change the hostname, because I'm sentimental:
hostnamectl set-hostname raspberrypi
That alone doesn't seem to be enough. I had to change the name in my router's panel. That is weird.
Finally, the music player daemon and essentials:
apt install mpd sudo alsa-utils rsync locales
So many libraries to install!
I installed `locales` because I was getting warnings from `perl` when I connected to the machine via `ssh`. I ran `dpkg-reconfigure locales` to setup `en_GB.UTF-8` and `de_CH.UTF8`. Only do this if necessary, of course.
Don't forget to modify "/etc/mpd.conf" and add something like this, where "headphones" is what `alsactl info` lists.als
audio_output { type "alsa" name "Headphones" }
The music files should be in "/var/lib/mpd/music/"
I also need a user with sudo permissions.
adduser alex usermod -aG sudo alex
Run `sudo visudo /etc/sudoers.d/alex` and save this line so that I don't have to type the password all the time.
alex ALL=(ALL) NOPASSWD:ALL
Use `rsync` to get some music to the `alex` account, then `mv` those files to "/var/lib/mpd/music/".
Enable and start `mpd`:
systemctl enable mpd systemctl start mpd
From the laptop:
mpc --host raspberrypi add https://ice2.somafm.com/secretagent-128-mp3 mpc --host raspberrypi play
It seems to work!
This time it only took 2½h.
Although I must say, 4 GiB is pretty small, these days. 😅
alex@raspberrypi:~$ df -h Filesystem Size Used Avail Use% Mounted on udev 177M 0 177M 0% /dev tmpfs 44M 512K 43M 2% /run /dev/mmcblk0p2 3.2G 2.6G 345M 89% / tmpfs 216M 0 216M 0% /dev/shm tmpfs 5.0M 12K 5.0M 1% /run/lock /dev/mmcblk0p1 508M 54M 454M 11% /boot/firmware tmpfs 44M 0 44M 0% /run/user/1000
This time, I used the following two files:
20231109_raspi_4_bookworm.img.xz 20231109_raspi_4_bookworm.img.xz.sha256
Verified it:
sha256sum -c 20231109_raspi_4_bookworm.img.xz.sha256
Wrote it:
xzcat 20231109_raspi_4_bookworm.img.xz \ | sudo dd of=/dev/sdb bs=64k oflag=dsync status=progress
Used the Disks program and resized the root partition to use all the free space on the card.
Bring up the network as described above.
I changed the hostname to `drummer`.