Setting up a GitHub repo for an existing local git repo

Let’s say you have a repo at ~/my-git-repo and you want to create a new repo on GitHub to push it to. Here’s how you do it.

  1. Create a repo on GitHub – let’s call it my-new-git-repo. Don’t let GitHub create anything for it.
  2. On your local machine, add a “remote” to the repo. git remote add origin https://github.com/myuser/my-new-git-repo.git
  3. Push, as in git push

That was easy! I think I got myself into trouble before by letting GitHub create a README and so on.

Posted Wednesday, January 11, 2023

Self-signed certificate in lighttpd

Is this what you want to do? Understand the implications of self-signed certificates, and passwordless keys too probably.

Create the certificate

Create a key:

openssl genrsa -des3 -out testing.key 2048

This creates a key with a password. Lighttpd will ask you for the password when it starts - this is usually not what you want.

Create a key without a password:

openssl genrsa -des3 -out testing.key 2048

Create a certificate signing request:

openssl req -new -key testing.key -out testing.csr

Create a certificate:

openssl x509 -req -days 365 -in testing.csr -signkey testing.key -out testing.crt

Create a .pem file

cat testing.key testing.crt > certificate.pem

Set up lighttpd

Copy the .pem and .crt files over to /etc/lighttpd/.

These are the essential directives - implement them as you wish.

$SERVER["socket"] == ":443" {
   ssl.engine = "enable"
   ssl.pemfile = "/etc/lighttpd/certificate.pem"
   ssl.ca-file = "/etc/lighttpd/testing.crt"
   server.name = "something"
}

Posted Thursday, August 26, 2021

Replacing a disk in a BTRFS RAID1 configuration

When your hard drive starts making the clicking sound of death, it’s time to act.

  1. Get a new hard drive.
  2. Run a BTRFS scrub, using btrfs scrub status -d /home to show which drive had the errors (and also to ensure that any errors were corrected on the good disk)
  3. Work out which hard drive is at fault. I had the following information:
    • /dev/mapper/home2 from BTRFS - this one had errors during a scrub, too.
    • ata2 from the kernel message log - the ATA interface kept getting reset.
    • /dev/sdb from GSmartControl - this was the drive with reallocated sectors.
    • Verify using blkid that the UUID for /dev/sdb was the same as the UUID for home2 in /etc/crypttab.
  4. Locate the physical drive. I was able to do this by following SATA cables to the various drives in the system and figuring out the ATA IDs for each SATA port.
  5. Put the new drive into the DVD drive position. (This is probably easier than having to replace a physically removed drive).
  6. Partition the new drive. Ensure you use the same tools, or at least end up with exactly the same partition table. That bit me.
  7. Set up crypto on the new drive
  8. Open the encrypted partition with a different name (e.g. home3). You can end up using the original name, but not while the original drive is mounted.
  9. Add the new drive to the BTRFS RAID array by replacing the old one.
    • Execute btrfs filesystem show /home and find the devid.
    • btrfs replace start <devid> /dev/mapper/home3 /home
    • btrfs replace status /home and watch it progress.
  10. While that’s going, write a blog entry and also update /etc/crypttab and /etc/fstab to use the new drive. Probably should use the nofail mount option in case you make a mistake, so the system still boots into a nice environment.
  11. When it’s all done, remove the old drive.

Posted Friday, June 18, 2021

NetworkManager problems

Just recently, probably after a system upgrade, my work laptop stopped configuring the WiFi interface properly. Manual settings worked, but DHCP and name resolution were broken more often than not. Having to manually running dhcpcd was not impressing me.

I came across these bugs in the Arch bugtracker that were informative.

I don’t know if the machine has gone crazy or if something recently changed in the NetworkManager / systemd worlds. I have disabled systemd-resolved since I don’t see why systemd should be replacing name resolution, so that might be causing trouble. The following fixes it.

First, add this to /etc/NetworkManager/NetworkManager.conf:

[main]
systemd-resolved=false

This adding the following to /etc/NetworkManager/conf.d/dhcp-client.conf may also be required, although the lack of it isn’t currently causing me problems:

[main]
dhcp=dhcpcd

Finally, enable dhcpcd:

% sudo systemctl enable dhcpcd
% sydo systemctl start dhcpcd

Posted Tuesday, January 7, 2020

Raspberry Pi video output

I’m in the process of setting up a Raspberry Pi as a media PC. The GUI configuration panel doesn’t contain a setting for the pixel format — I want to use the whole 8 bits and get proper blacks and whites — and /boot/config.txt wasn’t helping either, as Raspbian Noobs hasn’t put all the possible variables in there. It’s documented here. The variable in question is hdmi_pixel_encoding.

Posted Sunday, November 24, 2019

Blog contents