Skip to content

Instantly share code, notes, and snippets.

@davidjb
Last active February 8, 2016 21:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidjb/71f8a0d50621c0369c96 to your computer and use it in GitHub Desktop.
Save davidjb/71f8a0d50621c0369c96 to your computer and use it in GitHub Desktop.
Details on how to recover if an FSCK fails on a ReadyNAS system. Originally from the ReadyNAS forums, since removed.

Rather than RAM (default) or the root partition (/var/ -- far too small!), I used a high-capacity USB drive. Make sure this USB drive has enough free space before starting. You need at least X GB of space if your volume is 8TB like mine was. So, I'm guessing that this is why the fsck fails in the first place - at least, this is what my logs indicated when it said "Error storing directory block information (inode=90885846, block=0, num=6983948): Memory allocation failed"

  1. Get root access to your NAS. I had already enabled root ssh before things went haywire because after the volume failed, FrontView would not load.
  2. Attach a high-capacity storage device to the NAS via USB. Wait while the ReadyNAS loads the drive.
  3. Download and compile the latest e2fsckprogs from the internet:

    wget
    cd
    ./configure
    make
  4. Configure e2fsck to use a cache:

    mkdir /USB/USB_HDD/e2fsck #Configure yours accordingly
    echo "[scratch_files]
    directory = /USB/USB_HDD/e2fsck" > /etc/e2fsck.conf
  5. Configure a new swap file (I picked 4GB but you might need more) -- This probably isn't necessary:

    cd /USB/USB_HDD
    dd if=/dev/zero of=./swapfile1 bs=1024 count=4194304
    mkswap ./swapfile1
    swapon ./swapfile1
  6. XXX Turn off journaling for performance. Make sure you have a UPS if you do this or some other protection from power loss.

    tune2fs -O ^has_journal /dev/c/c #for performance

  7. Check the filesystem. I had a superblock failure for my check, so if you do, then you may need to use mke2fs -n /dev/c/c to find superblock backup locations which you can try sequentially as an argument to fsck -b [block]. The following command will likely fail with a 'Memory allocation failed' error after some time during the check so it needs to be re-run until all problems are fixed:

    /opt/e2fsckprogs/e2fsprogs-1.42.7/e2fsck/e2fsck -b 98304 -C 0 -y -v /dev/c/c
  8. XXX Turn back on journaling for protection

    tune2fs -O has_journal /dev/c/c #turn this back on

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment