@Fox_exe - Фантастическая работа, спасибо. Fantastic work, thank you. Ваш английский хорошо.
I am an amateur photographer and some days I used to try to upload 200 photos at a time to the My Cloud, and the ensuing scans would make it go off line. Not good for a Network Attached Storage device to disappear from the network. Now, with a clean install of Debian, for the first time, it works properly.
Removing thumbnails produced by the WD “firmware”
As I’m sure most of you know, the default WD software scans ALL the data on your drive. It makes up to four thumbnails of every video and picture it finds (regardless of whether or not the containing directories were marked as containing media files), and stashes them in hidden directories called .wdmc. It will have done this even on web pages downloaded in html format to a private share - and bear in mind that some web sites can use around 20 images to render a single page. And yes, the WD wastes its resources and your disk space making these jpg and jpeg thumbnails (which are only used by their software). An install of clean Debian (or any other install enabled by Fox_exe) leaves these files in with your data.
I wrote a script (initially for WD) to identify these but I never heard from them again on the subject. Here is a modified version of it, and this allows you to remove them all if you wish - or just locate them from the files created. It is pretty slow, taking around 7 minutes to finish searching and calculating disk usage on my system which has about 700GB in use with the results shown in the screenshot.
If this is usefule to anyone, good. It is supplied “as is,” and I accept no responsibility for any errors, loss of data, divorce or death of your dog should you choose to run it. The assumption is made that there is nothing else, important or otherwise, in the .wdmc directories. These will be irretrievably deleted by this script if you select the “y” option at the end. Yes, this could all be done on one line with the find command, but as I’d already writtent the bulk of this for WD I thought maybe someone may find it useful.
#!/bin/bash
# Script to find and remove the .wdmc directories and thumbnails created by WD on the My Cloud NAS
# KM 2014-07-05. V0.2 Added basic instructions
root="/nfs/shares/"
abort() { echo -e "\nAborted. Files \"wdmc_dirs\" \"totaldirs\" \"jpgs\" and \"jpegs\" NOT deleted.\nThey are located in $(pwd).\n";exit 1; }
fmt() { printf "%'d\n" $1; }
w() { echo ", please wait."; }
[[$EUID -ne 0]] && { echo "This script must be run by root. Aborted.";exit 1; }
cd "$root" || { echo -e "\n\nDirectory not found. Please ensure you are running the script on the My Cloud and, if necessary, change the cd command on line 4 of the script to match the mount point of your Data volume.\n";exit 1; }
clear;echo -e "This script searches for the \".wdmc\" directories and\nthe thumbnails created by the WD. If any are found you\nwill be shown how many, and the disk space they occupy.\nYou will then be given the opportuntiy to remove them.\n\nYou need to run it as root on the NAS server via SSH.\n\nYOU NEEDTO CHANGE LINE 4 OF THIS SCRIPT TO MATCH THE\nMOUNT POINT OF YOUR DATA. If you haven't done this yet,\ndo it now and run the script again.\n\nThis script is supplied strictly \"as is.\"\n";read -p "Press the Enter key to start, <CTRL-C> to abort."
clear;echo -n "Searching for \".wdmc\" directories";w
>wdmc_dirs
find "$root" -type d -name ".wdmc" >wdmc_dirs
dirs=$(wc -l<wdmc_dirs)
[[! -s wdmc_dirs]] && { echo "No directories named \".wdmc\" found."; rm wdmc_dirs;exit 0; }
echo "Found $(fmt $dirs) directories."
echo -ne "\nLooking for subdirectories";w
>totaldirs
while read line; do find "$line" -type d -mindepth 1 >>totaldirs; done<wdmc_dirs
totaldirs=$(wc -l<totaldirs)
echo "The .wdmc directories contain $(fmt $[$totaldirs-$dirs]) subdirectories, making a total of $(fmt $totaldirs)."
echo -ne "\nLooking for jpg thumbnails";w
>jpgs
while read line; do find "$line" -type f -name "*.jpg" >>jpgs; done<wdmc_dirs
jpgs=$(wc -l<jpgs)
echo "The directories contain $(fmt $jpgs) jpg files."
echo -ne "\nLooking for jpeg thumbnails";w
>jpegs
while read line; do find "$line" -type f -name "*.jpeg" >>jpegs; done<wdmc_dirs
jpegs=$(wc -l<jpegs)
echo -e "The directories contain $(fmt $jpegs) jpeg files.\n\nA total of $(fmt $[$jpegs+$jpgs]) thumbnails found.\n"
echo -n "Calculating space that would be freed";w
subt=0
while read line; do size=$(du -ac "${line}" | tail -1 | cut -f 1); subt=$[${size}+${subt}]; done<wdmc_dirs
echo -e "Done. Disk space used is $(fmt $[${subt}/1024])KB.\n"
read -rp "Do you want to remove these directories and all their contents [y/n]?" ans
[[$ans =~ (y|Y)]] || abort
read -r -p "Are you sure? [y/n] " ans
[[$ans =~ (y|Y)]] || abort
echo -n "Deleting $jpg files";w
while read line; do rm -r "$line"; done<wdmc_dirs
rm wdmc_dirs totaldirs jpgs jpegs
echo "Done"