Delete @eaDir on Synology

@eaDir Indexing

There are numerous sites that explain how to delete the irritating @eaDir directories on Synology NAS devices.  This directory is used by the indexing service.  And there are ways to disable this.  However this post is just a quick reminder on how to delete the directories or some other file or directory before copying files to another directory or device.

I tend to avoid doing any command starting from the root directory.  I prefer to limit commands to a specific directory.  And it is always a good idea to test out new commands first to ensure no drastic mistakes are made.  Instead of deleting a file echo a command first to a log file and review it.

Using xargs

find /volume1/music/flac -type d -name "@eaDir" -print0 |xargs -0 rm -rf

The '-print0' flag separates the full file name with a null character instead of a new line character.  This is useful if the path has spaces or other odd characters.

The '-0' flag in the xargs command tells xargs that items are separated by null characters.

Using -exec

find /volume1/music/mp3 -depth -type d -name "@eaDir" -exec rm -rf {} \;

The '-depth' flag will process each directory's contents before the directory itself.  You can use the '-delete' flag instead.  Either flag will prevent the find command from reporting that a directory doesn't exist after you remove it.  Otherwise the command will work without that flag but you will see "false" alerts about missing directories.



It is far easier to simply create a batch file to copy files from a Windows box to a Synology NAS device.  The examples below show some quick options I most often use.  This website is mainly for my own personal use anyway.  For more information on robocopy refer to the MS Command Line Reference guide.  Note, this URL is subject to change.  This example does not take the place of a proper backup and restore policy.

This is useful for quick one time backups before making changes.  Or to copy photographs from a SD card and only copy the new files.  Perhaps copying RAW files to one directory and JPEGS to another directory.  I mainly use robocopy to mirror directories and this allows me to run the command and come back a few hours later and rerun if necessary.  The examples below are using CIFS mounted NAS directories.

Basic Usage of Robocopy

There are numerous options.  This only highlights the flags I most often use.  The basic command is as follows.

robocopy  <Source>  <Destination>  [<File>[ ...]]  [<Options>]

File is optional.  But it can be used for multiple file types or to only copy one file type.

*.CR2 *.JPG  (Copy both raw and jpegs)
*.mp3  (Only copy MP3 files)

My commonly used options:

/copy:DAT  (File Properties to copy = D data / A attributes / T timestamps)
/MIR  (Mirrors a directory tree (equivalent to /e (copy sub-dirs and empty dirs) && /purge (deletes destination files and dirs no longer in source))

/v  (Increases verbosity of logging - shows skipped files)

/MT:16  (Number of threads between 1 and 128  - Default is 8)

/TEE  (Write the status output to the console window as well as to the log file.)

/LOG:%USERPROFILE%\Desktop\robo.txt  (Log file for review.  Adjust path as necessary.  Don't forget the colon after log.)

/XF <Filename>[ ...]  (Exclude file that matches specified name or paths.  Wildcards are acceptable.  Add multiple files in space delineated list.  Use double quotes for names with spaces.)

/XD <Directory>[ ...]  (Exclude directories that match the specified names and paths.  Wildcards may be used.  Add multiple paths in a space delineated list.  Use double quotes for names with spaces.)

Robocopy Examples

Here are some examples.  I am using the caret (^) to extend a long command over multiple lines and make it more readable.

Copy ALL of iTunes to Synology:

robocopy %USERPROFILE%\Music\iTunes ^
X:\iTunes-5-31-2016 ^
/copy:DAT ^
/MIR ^
/V ^
/MT:16 ^

Copy JPEG Locally

This example will copy all of the JPEGs from one directory to another.  This is useful if you have RAW and JPEGs images in one directory and you want to split them.

robocopy %USERPROFILE%\Pictures\GreatWhiteNorth ^
%USERPROFILE%\Desktop\GreatWhiteNorth ^
*.jpg ^
/copy:DAT ^
/MIR ^
/V ^
/MT:16 ^
/TEE ^




Using rsync to Copy Files to USB Drives

UNIX commands tend to have different flags on different versions of the OS.  A quick review of the MAN page or running 'command --help' may be helpful.  This post is just a quick reference of the command I most often use on my Synology NAS device.

Here is a quick usage of rsync:
rsync  [OPTION]  SRC  DEST

My Options for RSYNC

Here are the flags I most commonly use.

-a, --archive   (archive mode; equals -rlptgoD)

-r = recurse into directories
-l = copy symlinks as symlinks
-p = preserve permissions
-t = preserve modification times
-g = preserve group
-o = preserve owner (super-user only)
-D = preserve device files (--devices) (super-user only) && preserve special files (--specials)

--delete = delete extraneous files from destination dirs

--exlude='@eaDir' --exclude='Thumbs.db'  (Don't include @eaDir or Thumbs.db which are synology and windows items I don't care about.)

--log-file=/volumeUSB1/usbshare/rsync.log (Optional log file for review.  Synology rsync doesn't seem to do very good logging compared to other OS'es even with increased verbosity enabled.)

Example Command - Local to USB

The command below will copy files from '/volume1/video/BBC' (Local Synology Volume) to '/volumeUSB1/usbshare/BBC' (USB Drive BBC Folder).

rsync -a \
--delete \
--log-file=/volumeUSB1/usbshare/rsync.log \
--exclude='@eaDir' \
--exclude='Thumbs.db' \
/volume1/video/BBC/* \
/volumeUSB1/usbshare/BBC &

DSM Mount NTFS USB Drive

Mounting External USB Drive

The disk should mount automatically.  However, it seems I needed to manually mount my first NTFS formatted drive.  As root or via sudo run the following commands.

For more information on identifying the USB drive refer to the Synology documentation on external devices.

NOTE:  As of DSM 6.0 these commands no longer work for me.  The USB drives are automatically mounted.  But I cannot unmount and remount the drive from the command line.  A DSM patch may fix this.  Or there may be another command I need to find.  I have tried to reformat a drive and it still doesn't work.

  • fdisk -l  (Lowercase L)  This will identify the drive.
fdisk -l
fdisk -l
  • In this example my USB drive is /dev/sdq1
  • Mount it with the following:
    • mount -t ntfs /dev/sdq1 /volumeUSB1/usbshare

To unmount the drive run the following command:

  • umount /volumeUSB1/usbshare