JORDAN.YELLOZ.me

A few days ago at about 11 AM local time, my hard disk drive for my desktop computer seems to have suffered a mechanical failure. The logs were no longer written to disk afterward (and dmesg showed disk errors) and there was an unwelcoming clicking noise coming out of it when I attained physical access to my computer. When I was sshed into it during the daytime, lots of crazy stuff was happening because it couldn’t write to the disk.

I once claimed that I never had disk failures before but I realized that that is actually not a fact after digging though my life’s memory. The Postsario had one, a 14GB (or 1.4GB?) hard drive I had on my Performa 6400 felt a minor one which made it unable to recover from a spin down and having one crazy file that couldn’t be deleted.

In this case there was no actual data corruption. I did have initial difficulties in the recovery possibly due to random access issues related to the mechanical failure. I just used ddrescue (or dd_rescue ) to copy the entire partition and it went through with no errors. I just mounted the file as a loopback filesystem and copied everything I needed and it worked.

In the past I had used ReiserFS 3 due to its fast creation of small files which is good for building software and the fact that its creator killed his wife. This time, I decided to buy 2 1TB drives and combine them into a RAID 1 array using btrfs. I happened to spend some time trying it out a few weeks ago using some disk images to see how it works. I was reasonably satisfied although the behavior when the volume fills up is embarrassingly terrible. Fortunately, I don’t think I’ll approach the 1TB level before they fix that issue. Another issue I had was booting from a multi-device volume. I tried and tried things such as root=/dev/sda3 rootfstype=btrfs rootflags=device=/dev/sda3,device=/dev/sdb3 which were never successful.

Obviously there is the btrfsctl utility that you may need to automatically find btrfs volumes but that doesn’t get run until afterward. I had to do the ugly thing and use an initramfs with some statically compiled btrfsctl which does way more than I want because I have an almost monolithic kernel and can historically boot right into my disk. One place where Gentoo Linux lacks is the genkernel tool for making initramfs archives. It was an absolute mess to inject my stuff in there to get btrfs working. All I really needed was a busybox, btrfs-progs, and maybe my nouveau kernel module for the framebuffer console and instead I have all this needless “scanning” until I can switch into my real operating system. Ubuntu, (and I guess Debian) has (have) much better tools for this where users can make their own custom scripts and programs to insert into the initramfs or do some minor customizations to the resultant archive.

Update: I was actually able to just build busybox and btrfs-progs statically, copy in my few kernel modules, and just make an init script that sets up everything and I have my framebuffer console and everything before any output is presented or my root filesystem’s init gets started. That is definitely an improvement. It’s surprisingly not that hard to set up after a bit of reading and testing on QEMU.

Here’s a quick script that does what I need to stick the contents of a list of directories in a cpio archive and then add all of your current system’s kernel modules if they’re installed. This assumes your source directories will add up to a valid initramfs that boots correctly.

Posted on

Attachments:

  • cheapinitramfs (932 Bytes; text/x-shellscript; charset=us-ascii; view | download)

Revisions: