Massively reduce Logitechmediaserver library rescan time (for large collections)

AVForums

Help Support AVForums:

This site may earn a commission from merchant affiliate links, including eBay, Amazon, and others.

Now Playing

AVForums Super Veteran
Joined
May 25, 2010
Messages
1,208
Reaction score
15
Location
South Africa
If you've a LARGE music collection indexed by Logitechmediaserver you'll know that running a rebuild scan after making extensive changes to the underlying tags can be a time consuming exercise and leave you without music for a few hours to a day.  The problem here is that if you don't want edited albums to appear in your new album listing you pretty much have no option but to preserve file modification times when doing the tag editing.  The downside of that is LMS will not rescan the files so any metadata changes you made will remain undetected until you run a Clear library and rescan everything...not exactly an enticing prospect.

I'm in the process of implementing a workaround to reduce scan time and effect large performance improvements (I've got it working manually at present, will share an automated method once I've gotten it going [having to so some heavy reading re Upstart and Linux's init systems]) that resulted in a 70% reduction in rescan time - basically using a ramdisk.

Here's how to do it manually:
Stop LMS, create a ramdisk, copy the LMS cache to the ramdisk and restart LMS.
Code:
sudo service logitechmediaserver stop
sudo mkdir /media/ramdisk
sudo mount -t tmpfs -o size=2048M tmpfs /media/ramdisk/
sudo chown -R squeezeboxserver:nogroup /media/ramdisk
sudo cp -R /var/lib/squeezeboxserver/cache /media/ramdisk/
sudo cp -R /var/lib/squeezeboxserver/cache ~/lmsbackup
sudo rm -R /var/lib/squeezeboxserver/cache
sudo ln -s /media/ramdisk/ /var/lib/squeezeboxserver/cache
sudo service logitechmediaserver start

From hereon out your LMS database is housed in ram in and accessed via /media/ramdisk.  Remember it's volatile - shutdown or lose power and it disappears.  Run the rescan or whatever it is you need to get done - you'll find it's MUCH faster than you've previously experienced (my full library rescan dropped from over 11 hours to just over 3 hours).  When done, stop LMS, reinstate the cache folder, copy the data files from the ramdisk back to physical disk and restart LMS
Code:
sudo service logitechmediaserver stop
sudo unlink /var/lib/squeezeboxserver/cache
sudo mkdir /var/lib/squeezeboxserver/cache
sudo chown -R squeezeboxserver:nogroup /var/lib/squeezeboxserver/cache
sudo cp -R /media/ramdisk/ /var/lib/squeezeboxserver/cache
sudo service logitechmediaserver start

Given I've got a copy for safekeeping I'm pretty much running the LMS db on ramdisk full time.  I'm working on getting some tools configured to rsync the LMS db to ramdisk on startup and back to disk on shutdown, meaning you can run on ramdisk permanently without having to do anything once the initial setup is completed.  Aside from dramatic reductions in scan time, LMS response on searches etc. is pretty damn quick.

As a side note, puddletag now includes a plugin you can use to add two seconds to the last mod time of a file - enough to ensure LMS knows the files have changed and thus rescan them, but without having them appear in your new albums listing.
 

Latest posts

Top