Linux howto : Sansa Clip+ a brilliant little flac/ogg/mp3 player

I was looking to replace my 2GB Samsung ogg/mp3 player so bought one of these Sansa Clip+ 8GB on Amazon a while back for under £40 with 8GB flash memory and another £10 for a 8GB MicroSDHC card.  Big attractions were high degree of confidence it would work well with Linux systems, it price, size, flac and ogg support and it had good reviews.  Here are some plusses I discovered while I've been using it:

* supports playlist creation and editing off-player (in rhythmbox and plain text editing, I use vi)

* upgrading the firmware works from Linux

* if you mess up, things are recoverable with Linux [1]
Here are some extra tips and hints:
My Linux system is stock Ubuntu, fully updated Lucid 10.04 LTS
1.  How to write a device label on a Sansa Clip+
Set the label to something you like so it's easy to remember in scripts etc and looks nice on your desktop when USB connected , its a FAT fileeystem so use "mlabel -i <DEVICE>", a quick "df -h" will show you what this is if you're not certain.  Mine was /dev/sdc

* to show the label, if any : mlabel -i /dev/sdc -s ::

* to write a new label called "SANSA_CLIP" : mlabel -i /dev/sdc ::SANSA_CLIP

if you now safely remove the device and reconnect Ubuntu (at least) will now mount the Sansa Clip+ on /media/SANSA_CLIP or whatever you called it.  I would have called mine SANSA_CLIP+ but I tried that and the "+" symbol is not supported and I didn't like the default alternative SANSA_CLIPP
2. How to upgrade the firmware on a Sansa Clip+
The above link describes it.  Here's the short version of what I did.  Downloaded the latest firmware, it's a zip file which contained two files "clppa.bin" and clpp_data.dat".  I copied both over with rsync to  the root ("/") directory of the Sansa Clip+ (for me this was mounted as /media/SANSA_CLIP).  Then after safely removing the device, powering it down, connecting power, then powering it said it was upgrading the firmware on the screen, then done. When I reconnected the Sansa Clip+ to my Ubuntu desktop the filesystem showed that the upgrade had remove the two files I'd added.  The version in the info settings was updated appropriately, my version was 01.02.15
3. How to recover if only part of the space is available on a Sansa Clip+
This happened to me after I upgraded the firmware and only about half the 8GB space was usable, said "df -h" and when I filled up, prematurely to my mind, the MUSIC folder with 4.5GBs of flac, ogg and mp3s.  Something was clearly wrong since the filesytem seemed bare otherwise, empty dirs and reasonably sized system files.  I checked to see the partition state, whilst mounted (read-only operation so ok), with "fdisk -l /dev/sdc".  This showed wierd unmounted sub-partitions (sdc1, sdc2, etc) with improper cylinder boundaries.  So I checked up online and found that if I could get into the OS as usual, there was an internal "format" function in "System Settings" which formatted the drive (not the OS, that was ok) and corrected the size problem.  Now "df -h" showed 7.9GB of free space as expected
4. How to raise the system volume on a Sansa Clip+
If you're starting from scratch no problem, you select as the region "Rest of the World" and the "System Settings -> Volume" option will be immediately visible and you can return to it at any time.  If not then, "System Settings -> Reset Factory Settings" will get you that screen.
5. How to hard reset the Sansa Clip+
The only documented way is to hold down the power button for 15+ seconds.  It always worked for me (over 20 times now).  The little hole on the back of the Sansa Clip+ does not have a hard/factory reset button lurking behind it, but a microphone!  (best avoid damaging it - I learnt the hard way ;-) but not tested voice recording since so might still be ok!).
6. How to stop a Sansa Clip+ from hanging on boot at the "Refreshing your media" step
I tried every combination I could think of to get it to work: from powering it up disconencted from everything, connected to my desktop, connected to a pure power USB connection.  I waited overnight and realised it would never take that long however many media files I put on there. The only thing that fixed it was powering it off, connecting it to my desktop, then manually deleting my music files (I used trusty old "rm" in the MUSIC dir)
7. How to add music to a Sansa Clip+ with Linux

It depends on how you want to keep your music in sync - I wanted the option of maybe using simple scripts (I'd write in bash and use rsync mainly) so realised it will be a lot easier if I kept the files in one folder and not sub-folders, which also helps playlists (see 8.)   I found that when I dragged tunes within rhythmbox onto the Sansa Clip+ they'd be immediately visible as expected within rhythmbox but would physically be in unexpected folders like AUDIOBOOKS on the filesystem of the Sansa Clip+.  The ultra-reliable, controllable way for me to copy files over is to use "rsync". Here's the command I use to sync over music file in my ~/Music/SYNCED folder on my desktop to the Sansa Clip+ and the screenshot shows what it looks like running...

rsync -av ~/Music/SYNCED/  /media/SANSA_CLIP/MUSIC/

If you were intending to use rsync you'd need to check your from and to folders matched your preferences
8. How to make playlists on a Sansa Clip+ with Linux
There may be other apps out there, but I use rhythmbox normally (also great for wireless DAAP music sharing to any device that supports including my Android phone and Samsung TV).  I found this was the best way to create the playlist in the first place and to effectively GUI edit them by opening the playlist in rhythmbox and adding, subtracting and ordering the music files in the playlist.  To understand what was going I checked out what the playlist I had made was composed of and found out it was a text file (file extension "m3u") located in the Sansa Clip+ MUSIC dir, the text containing an ordered list of names and paths of the music I'd selected.  It was then just an easy matter of firing up "vi" to edit and make whatever copies of this playlist and adapt it as needed.  It was easier and quicker when auto-creating playlists by having accurate ID3 tags and filenames without spaces in them (I use either "_" or "-" depending).



Notes:

[1] just don't reformat the partitions using Linux tools unless you really know what you are doing (likely using the usual mkfs filesystem tools). Best off using Windows if you don't.