{"id":193,"date":"2020-08-30T10:23:08","date_gmt":"2020-08-30T10:23:08","guid":{"rendered":"http:\/\/sijnstra.name\/blog\/?p=193"},"modified":"2020-08-30T12:20:52","modified_gmt":"2020-08-30T12:20:52","slug":"deleting-and-purging-an-index-on-a-synology-diskstation-nas","status":"publish","type":"post","link":"http:\/\/sijnstra.name\/blog\/2020\/08\/30\/deleting-and-purging-an-index-on-a-synology-diskstation-nas\/","title":{"rendered":"Deleting and purging an index on a Synology DiskStation NAS"},"content":{"rendered":"\n<p>I was trying to set up my Synology DiskStation (DSM 6.2.3 as of writing) as a media player. I was happy to discover that there is a built in application for the DiskStation you can load up from the Package Centre called &#8220;Audio Station&#8221;, with matching apps on the Android and iPhone. I installed it, created a new account with read-only file access to my music files in a particular directory, and only application access to the Audio Station applicaiton.<\/p>\n\n\n\n<p>All looked great until the Indexer started trawling the entire disk volume. This means that all sorts of things that were just audio files were now listed as music tracks, and if you have the same track in multiple formats, suddenly you have 2 copies of the same track in the app. As you can imagine, this makes playlists and shuffles really annoying to say the least.<\/p>\n\n\n\n<p>So I went in to the &#8220;Indexing Service&#8221; on the control panel, and after trying multiple combinations of renaming, changing settings, deleting directories from the index and selecting where I wanted indexed, it became clear that the NAS doesn&#8217;t like removing things from the index, at least not with the amount of time I was willing to wait. I will also note at this point that searching for help on removing references from the index is problematic at best- there are a few articles on the index retaining deleted files or moved files at both locations.<\/p>\n\n\n\n<p>At this point I left the indexer settings at my desired result &#8211; one specific directory tree on one volume for audio files only.<\/p>\n\n\n\n<p>Next step? Dropping the old database seemed the way to go. This wasn&#8217;t easy, and I&#8217;m writing this to remind myself of what I had to do, in case I need to do similar for the file or photo applications, or simply need to reset the index again.<\/p>\n\n\n\n<p>Note that each version of the DSM is different in how to achieve the outcome, so these are the next steps I followed.<\/p>\n\n\n\n<p>First you need to stop applications using the index database. I stopped the &#8220;Audio Station&#8221; application by going into the &#8220;Package Centre&#8221; and selecting the application, then chosing &#8220;Stop&#8221; from the dropdown.<\/p>\n\n\n\n<p>Next challenge was stopping the Indexe, which I did from a secure shell promptr:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">super@DSM:\/$ sudo synoservice -stop synoindexd\nsome service depend on service [synoindexd] is still running, use --hard-stop to stop all releated service\nsuper@DSM:\/$ sudo synoservice --hard-stop synoindexd\nwarn: The runkey of service [synoindexd] and its dependency services have been set to \"No\"<\/pre>\n\n\n\n<p>Then I needed to drop the database. The synoindex tool has a lot of features, but they seem to resemble what&#8217;s in the web GUI except there&#8217;s no help listing which directories have been indexed, so you can&#8217;t work out what to delete.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">ssh super@DSM<br>super@DSM's password:<br>Could not chdir to home directory \/var\/services\/homes\/super: No such file or directory<br>super@DSM:\/$ synoindex<br>Usage:<br>synoindex [OPTIONS]<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">Index Options:<br>-h, --help<br>this help text<br>-A dirpath<br>add a dir<br>-a filepath<br>add a file<br>-D dirpath<br>delete a dir<br>-d filepath<br>delete a file<br>-N new_dirpath old_dirpath<br>rename a dir<br>-n new_filepath old_filepath<br>rename a file<br>-R [all|media|photo|music|video|thumb|dirpath]<br>all: reindex all dirpath that registered in each package<br>media: reindex dirpath that registered in MediaIndex package<br>photo: reindex photo dirpath<br>music: reindex music dirpath<br>video: reindex video dirpath<br>thumb: check converted video of each video file<br>dirpath: reindex this specific dirpath<br>-R user:{user_name}<br>reindex personal photo dirpath<br>-R share:{share_name}<br>reindex share dirpath<br>-R [type_music|type_video|type_photo]<br>reindex dirpath that registered with specific type in MediaIndex<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">Package Index Options:<br>-P [MediaIndex|{package_name}] {index_option}<br>index operation only apply on this package<br>-p [MediaIndex|{package_name}] {index_option}<br>index operation apply all packages except for this package<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">File Index Options:<br>-f {index_option}<br>index operation apply on file index<br>-U photo<br>update photo images<\/pre>\n\n\n\n<p>So I tried to login as the database as the database user: postgres. Unfortunately I didn&#8217;t have a password for that account, and I couldn&#8217;t su postgres without the password. So I did the following workaround:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">super@DSM:\/$ sudo \/bin\/bash\nPassword:\nbash-4.3# su -s \/bin\/bash postgres\nbash-4.3$ whoami\npostgres<\/pre>\n\n\n\n<p>If you fail to stop the indexer first, trying to drop the database results in the following:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">bash-4.3$ dropdb mediaserver\ndropdb: database removal failed: ERROR: database \"mediaserver\" is being accessed by other users\nDETAIL: There is 1 other session using the database.<\/pre>\n\n\n\n<p>It does work perfectly though if the indexer is stopped. For reference, at some point I also did this, but it didn&#8217;t help:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">super@DSM:\/$ sudo synoservice -start synoindexd\nsuper@DSM:\/$ synoindex -R all<\/pre>\n\n\n\n<p>What was the last step? Rebooting the DSM. It took a while, but eventually the indexer recreated the database, the database started rebuilding and even though the Audio Station failed the first few times, suggesting the DSM was having issues, however with enough time the Audio Station behaved perfectly as expected. The correct directory became indexed, the information on the &#8220;Indexing Service&#8221; now referred to the correct application having access to the index, and the status was also updated correctly. It also took a bit longer for the Android app to work as expected, but eventually it allowed me to use the music from anywhere.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I was trying to set up my Synology DiskStation (DSM 6.2.3 as of writing) as a media player. I was happy to discover that there is a built in application for the DiskStation you can load up from the Package Centre called &#8220;Audio Station&#8221;, with matching apps on the Android and iPhone. I installed it, &hellip; <\/p>\n<p class=\"link-more\"><a href=\"http:\/\/sijnstra.name\/blog\/2020\/08\/30\/deleting-and-purging-an-index-on-a-synology-diskstation-nas\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Deleting and purging an index on a Synology DiskStation NAS&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[42,43,41],"_links":{"self":[{"href":"http:\/\/sijnstra.name\/blog\/wp-json\/wp\/v2\/posts\/193"}],"collection":[{"href":"http:\/\/sijnstra.name\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/sijnstra.name\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/sijnstra.name\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/sijnstra.name\/blog\/wp-json\/wp\/v2\/comments?post=193"}],"version-history":[{"count":2,"href":"http:\/\/sijnstra.name\/blog\/wp-json\/wp\/v2\/posts\/193\/revisions"}],"predecessor-version":[{"id":196,"href":"http:\/\/sijnstra.name\/blog\/wp-json\/wp\/v2\/posts\/193\/revisions\/196"}],"wp:attachment":[{"href":"http:\/\/sijnstra.name\/blog\/wp-json\/wp\/v2\/media?parent=193"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/sijnstra.name\/blog\/wp-json\/wp\/v2\/categories?post=193"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/sijnstra.name\/blog\/wp-json\/wp\/v2\/tags?post=193"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}