Synology Nas: Run Fsck To Check and Repair a Linux File System

I own a Linux powered Synology dedicated Network Attached Storage (NAS) server for my home office use. How do I run fsck on Synology DiskStation that offers RAID storage using Linux command line options over an ssh session?

This server is powered by Linux operating system and comes with the e2fsck program that can be used to check the ext3/ext4 family of file systems.

Tutorial details
Difficulty level Intermediate
Root privileges Yes
Requirements Synology server
Est. reading time N/A
First, you need to login using ssh interface. The syntax is as follows:

ssh root@nas01
ssh root@nas-server-ip-here

Once logged in you need to stop running services such as smb/nfs/pgsql and so. To see current volumes or mount point type the following command:
Sample outputs:
Filesystem           1K-blocks      Used Available Use% Mounted on
rootfs                 2451064    437412   1911252  19% /
/dev/root              2451064    437412   1911252  19% /
/tmp                    255700       272    255428   1% /tmp
/dev/vg1/volume_1    2879621632 176443652 2703075580   7% /volume1
/dev/vg1/volume_1    2879621632 176443652 2703075580   7% /opt

To see current services accessing the /volume1/ and /opt/, run:
lsof /opt/
lsof /volume1/

Sample outputs:

postgres 5052 admin  cwd    DIR  253,0     4096      18 /volume1/@database/pgsql
postgres 5057 admin  cwd    DIR  253,0     4096      18 /volume1/@database/pgsql
postgres 5057 admin   17u   REG  253,0 16777216 3539006 /volume1/@database/pgsql/pg_xlog/000000010000000000000006
postgres 5058 admin  cwd    DIR  253,0     4096      18 /volume1/@database/pgsql
lsof     8284  root  txt    REG  253,0   125544 4068473 /opt/sbin/lsof
lsof     8285  root  txt    REG  253,0   125544 4068473 /opt/sbin/lsof

You need to stop pgsql service, enter:
/usr/syno/etc/rc.d/ stop
Sample outputs:
Stopping PostgreSQL...
In short, you need to stop services that are running and accessing data shares such as SMB,NFS,pgsql,mysql and so on. You can use web interface to stop these services too. cd to /usr/syno/etc/rc.d/ and stop all file sharing services. Finally, unmount volumes as follows:
umount /volume1/
umount /opt

Verify that /opt and /volume1/ are unmounted:
Sample outputs:

Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/md0               2451064    437408   1911256  19% /
/tmp                    255700       264    255436   0% /tmp

Run fsck on ext4 file system:
fsck.ext4 -v /dev/vg1/volume_1
e2fsck -p -y -f -v /dev/vg1/volume_1
Sample outputs:

e2fsck 1.41.12 (17-May-2010)
1.41.12-2198: is cleanly umounted, 474816/182845440 files, 55587266/731381760 blocks
 (check after next mount)

Reboot the server:

Check out related media

This tutorial is also available in a quick video format:

(Video.01: Synology nas complete fsck using fsck.ext4 command)

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 12 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
12 comments… add one
  • Jorge Oct 5, 2012 @ 11:32

    Good article!

    But I have a problem when I’ve tried to check the file system. The problem is the command “lsof” that isn’t supported in my synology. I have the DSM 4.1

    How can I use the “lsof” command or other to check for services which have any open file?



    • 🐧 nixCraft Oct 5, 2012 @ 12:03

      I’m also using DSM 4.1. The lsof command is not part of DSM and you need to install it. I will cover it up in another article soon.

      • Jorge Oct 5, 2012 @ 13:00

        Ok, thanks

        I’ll wait for your article

      • Tom Jan 9, 2013 @ 16:26

        Hi Vivek – is the article available yet?

  • Mike Feb 27, 2013 @ 7:33

    Good article – Thanks!
    I’m trying to run the check myself… here’s what I’ve found:
    the lsof command is part of the ipkg package which you need to install yoursef.
    instructions here:

    make sure you stop all the services!
    “/usr/syno/etc/rc.d/ stop”, “/usr/syno/etc/rc.d/ stop”, “/usr/syno/etc/rc.d/ stop”, “/usr/syno/etc/rc.d/ stop”.
    from here:

    I didn’t know, but realized that the /dev/vg1/volume_1 is the original mount point for /volume1/ which was confusing… something I had to take note of before running umount.

    you may want to type ‘mount’ to find out which file system you’re using if you don’t already know

    after the unmount my NAS beeps every 3 seconds. it’s annoying and loud. seems to be the last hurdle.

  • Daniel M Mar 6, 2013 @ 23:03

    Thanks for the article! But, unfortunately we don’t have the lsof command on our Synology NAS neither, and the whole article is based on that :(

  • Daniel M Mar 6, 2013 @ 23:32

    Easier way to do it would be this:

    umount /volume1
    fsck.ext4 -pvf /dev/md2

    At least that’s how it worked for me.

    • sdfdf Aug 27, 2013 @ 22:20

      Didn’t need to umount volume1 after the poweroff task – was already unmounted.

    • Jens Sep 24, 2013 @ 20:51

      syno_poweroff_task kills my ssh and/or telnet session (Connection closed by foreign host.) and the web interface, still responds to ping however…

      • Jens Nov 22, 2013 @ 13:03

        I had introduced some problems by using ipkg appareantly, after reinstalling the os this worked.

    • themadmax Nov 22, 2013 @ 11:52

      Great work for me, did not kill ssh connection !

  • Mike Mar 22, 2013 @ 18:04

    I ran into an issue running the e2fsck command – it seems that the p and y flag conflict.

    from the docs:
    Assume an answer of ‘yes’ to all questions; allows e2fsck to be used non-interactively. This option may not be specified at the same time as the -n or -p options.

    I just stick with p.

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum