Kevin Steen's bit o'Web

Home | Articles | Contact

Fast, Safe, Cheap root Filesystem

2016-10-09: How I made my aging computer a bit faster with a £9 USB flash memory stick and RAID1 using the md driver on Debian 8 (Jessie), instead of paying for an expensive SSD drive.

This is not a guide for beginners. Use man <command> to learn about the commands before you run them.


Mirror the root filesystem onto the flash drive. Ensure that /etc/initramfs/modules contains the correct modules, then run update-initramfs -u


  1. Backup all your files.
  2. Use mdadm to setup a mirrored, bootable root filesystem
  3. Ensure the initial RAM filesystem loads the correct drivers.
  4. Enjoy!

Backup all your files.

No, seriously. Backup before you start. Obnam is good. apt-get install obnam

Also, make a copy of /boot/initrd.img... (e.g. to initrd.img.good)


My system was setup with two ide drives (sda and sdb).
Root filesystem on /dev/md0 using components /dev/sda1 and /dev/sdb1.
The flash drive when plugged in became /dev/sdc.
I was using GRUB to boot off sda1 storing its files in /boot/grub/

Mirrored, bootable filesystem

Create a partition on the flash drive which is the same size as the partition containing your root filesystem.(gparted, fdisk)

Add it to the mirror on which your root filesystem is running: mdadm /dev/md0 -a /dev/sdc1 -f /dev/sdb1

Wait for the rebuild to finish
cat /proc/mdstat
mdadm --detail /dev/md0
or run gkrellm to watch the graphs.

Prevent the old mirror component from being resurrected:
mdadm /dev/md0 -r /dev/sdb1
wipefs -a /dev/sdb1

Initial RAM filesystem (initramfs)

Add busybox to your initramfs: apt-get install busybox-static Not having tab-completion in your rescue shell is a pain.

To make sure the flash drive is recognised at boot time, the initramfs has to load all the modules required. Add the following lines to /etc/initramfs/modules in this order:

then run update-initramfs -uv. Look out for error messages and also check that the above-listed modules are included in the generated initramfs. Use lsinitramfs /boot/initrd.img... to check.

You may also need to extend the delay to wait for the root filesystem to become available by adding rootdelay=10 to the kernel commandline.

Edit /etc/default/grub and change the line:
GRUB_CMDLINE_LINUX_DEFAULT="init=/bin/systemd rootdelay=5"
then run update-grub


Check during bootup that all components are being succesfully found by adding break=bottom to the kernel command line. When you get to the shell prompt, use Shift-PgUp to scroll back and view the messages.

Ctrl-Alt-Del to reboot, or Ctrl-d exits the shell and continues the boot.

Also useful:

cat /proc/mdstat
cat /proc/modules
ls /dev/sd*
modprobe -v ehci_hcd
insmod /root/lib/modules/.../kernel/drivers/usb/...

Other break= options are : top, modules, premount, mount, mountroot, bottom, init.

Don't continue the boot if the flash drive isn't detected. My flash drive had only 5MB/s write speed, so syncing took ages. Rather reboot using an initrd which does recognise the flash drive and manually assemble the array: mdadm --assemble /dev/md0 /dev/sdc1
Once booted, re-add the faster disk and re-sync from flash to faster disk.
mdadm /dev/md0 -r /dev/sda1 -a /dev/sda1
(My flash disk could read at 30MB/s.)

Get in touch

If you know which modules in my list are unnecessary, or a better way to do this, please get in touch and let me know.

Last update: 9 Oct 2016