Replacing a disk in a BTRFS RAID1 configuration
When your hard drive starts making the clicking sound of death, it’s time to act.
- Get a new hard drive.
- Run a BTRFS scrub, using
btrfs scrub status -d /hometo show which drive had the errors (and also to ensure that any errors were corrected on the good disk)
- Work out which hard drive is at fault. I had the following information:
/dev/mapper/home2from BTRFS - this one had errors during a scrub, too.
ata2from the kernel message log - the ATA interface kept getting reset.
/dev/sdbfrom GSmartControl - this was the drive with reallocated sectors.
- Verify using
blkidthat the UUID for /dev/sdb was the same as the UUID for home2 in
- 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.
- Put the new drive into the DVD drive position. (This is probably easier than having to replace a physically removed drive).
- Partition the new drive. Ensure you use the same tools, or at least end up with exactly the same partition table. That bit me.
- Set up crypto on the new drive
- 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.
- Add the new drive to the BTRFS RAID array by replacing the old one.
btrfs filesystem show /homeand find the devid.
btrfs replace start <devid> /dev/mapper/home3 /home
btrfs replace status /homeand watch it progress.
- While that’s going, write a blog entry and also update
/etc/fstabto use the new drive. Probably should use the
nofailmount option in case you make a mistake, so the system still boots into a nice environment.
- When it’s all done, remove the old drive.
Posted Friday, June 18, 2021
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 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
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:
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
Posted Sunday, November 24, 2019
Record my desktop with ffmpeg
It seems that desktop recording is quite the pest. Not that I’ve tried much, but I also haven’t really found a “go-to” piece of software for X11 that just does it. So the last time I wanted to record my screen, I decided to have a go with just plain command-line tools.
It turns out that this is also ridiculously easy.
ffmpeg -f x11grab -s 500x300 -r 25 -i :0.0 foo.mp4
The -s option tells ffmpeg the pixel size of the region you want to grab; -r is the frame rate, -i is your X screen, and the video is written to foo.mp4.
If you don’t want to start the screen capture in the top-left, just use something like
-i :0.0+100,200 to specify where to start and the resolution to capture.
The ffmpeg website has more info.
Posted Tuesday, February 19, 2019
Find and replace in geany
The other day I wanted to do a find-and-replace in geany using a regex in the find. I wanted to turn something like this
Field name: value
Field name: value plus some more
Since geany supports regex searching, I decided it was time to find out how to do regex replacements too. The way it works, is that you put parentheses around each match that you want to be able to use in the replacement string, and then reference these replacements using backslash-number. So the find string becomes
^Field name: (.*)
and the replacement string becomes
Field name: \1 plus some more
That was too easy.
Posted Monday, February 18, 2019