fsck from initramfs console with 'f' key not working

My ubuntu laptop is dropping to initramfs console due to file system errors. I need to do 'fsck' manually. But the letter 'f' is not working in my keyboard. Right now I can't get a new keyboard. Is there any shell tricks through which I can somehow run the fsck command?


  1. If you are running full bash (including printf), you can do

    "$(printf '\146')sck"
    

    Well, d’oh; that doesn't work if you can’t type the f in printf.

  2. Since your question focuses on the initramfs console, I assume that you have some way of operating when the system is fully up and running; perhaps by copy and paste.  Do

    type -a printf
    

    to find the binary executable for printf.  (It is probably in /bin and/or /usr/bin.)  Then do

    ln -s /bin/printf /bin/printt
    

    as root, using the appropriate directory.  Then, in the initramfs console, do

    "$(printt '\146')sck"
    

    (which uses the link you just created).  You can use a different name if you prefer; e.g., p or pt.

    You may need to repeat this every time you get a distribution update.  It might be better to put the link into a directory that is in your PATH in the initramfs console, but that is not overwritten by distribution updates (e.g., something with "local" in its name).

  3. Alternatively, do

    "$(echo -e '\0146')sck"
    

    You may need to experiment with this to get a variation that works (because echo is not as standardized as printf is).  For example, /usr/bin/echo might work better than the builtin echo, and you might not need the leading zero.