Archive for July, 2016

Linux SSD TRIM Trivia

Sunday, July 31st, 2016

Enabling SSD TRIM support on Linux can be interesting due to the many storage layers involved. TRIM must be enabled by enabling the relevant discard option at least at the following levels (if they exist in a configuration):

  • mdraid (manually in the case of RAID4/5/6)
  • dm-crypt
  • LVM

Additionally, the filesystem must either be configured with the discard to issue TRIM commands automatically after filesystem operations that clear blocks, or a scheduled fstrim must be performed during a maintenance window. With frequently LVM operations, discard-everything may be a better choice.

But generally, if a device supports queued TRIM and the implementation is not broken in the SSD firmware, then enabling at the filesystem level as well should be a reasonable approach.

To set up a new SSD in Linux, generally Debian’s SSD Optimization wiki is a good place to start.

Here are some questions about interesting TRIM scenarios that I determined the answers to.

Linux hybrid mdraid, mixing SSD and HDD devices

Can a hybrid RAID be trimmed by the filesystem running on top of it? The long and short answer to this question is: actually, this works fine. The TRIM command is sent only to hardware devices which advertise support for it, so it won’t be sent to the HDD. If trimming the filesystem causes errors, check for TRIM support in other intermediate layers (LVM, dm-crypt, mdraid).

Linux software RAID4/5/6

The raid456 driver cannot apparently automatically query the underlying storage layers to determine whether the device zeroes data blocks that have been discarded, and failing to do this is considered unsafe.

So one must check manually the SSD devices using lsblk -D for this feature, which is blacklisted for some buggy hardware:

valhalla:~# lsblk -D
sda                          0      512B       2G         1
??sda1                       0      512B       2G         1
??sda2                       0      512B       2G         1
? ??md0                      0      512B       2G         1
??sda3                       0      512B       2G         1

If the RAID underlying devices (check /proc/mdstat) all have ones in the DISC-ZERO column, it is safe to enable the module parameter:

parm:           devices_handle_discard_safely:Set to Y if all devices in each array reliably return zeroes on reads from discarded regions (bool)

Which is done by adding raid456.devices_handle_discard_safely=1 to one’s kernel command line in the bootloader configuration.

TRIMming all free space on a disk

Once everything is all set up, one may want to TRIM any unused space in case it was previously written to for whatever reason. This is easy to do as long as an LVM physical volume exists over the entire disk. Simply create a logical volume that uses up all the free space, then delete that volume:

lvcreate -l100%FREE -n blkdiscard SSD-VG
lvremove SSD-VG/blkdiscard

Repair Black Box ServSwitch EC Series KVM IP Switch

Sunday, July 31st, 2016


I repaired a broken Black Box KV9316A 16-port KVM-over-IP switch through replacing electrolytic capacitors and an internal battery. The short story is that a manufacturer of several internal logic boards used cheap “TRec” electrolytic capacitors which failed with high ESR, and the manufacturer of the power supply unit used a cheap “SWC” electrolytic capacitor which failed open, causing a voltage drop under load. The long story follows.


My Samsung Galaxy S5 smartphone charges too slow, how can I make it faster?

Thursday, July 28th, 2016

I noticed lately that as a heavy smartphone user, the charging rate of my Galaxy S5 running the Android v6 Marshmallow firmware was barely outpacing drain rate.  Sometimes even an overnight charge would not be enough to bring it back to a full charge.  After installing the free app Ampere, I realized that regardless of what the phone was connected to (wall charger, USB2, USB3 ports), it was charging at only the 500mA rate that is the maximum allowed for computer USB 1.1/2.0 ports.  So I did some investigation and this is how I found that I was able to increase the rate to 2.0A on both my Galaxy S5 and my wife’s Google Nexus 5, dramatically reducing charge time over most of the battery’s capacity range.


Repair APC Back-UPS XS 1500 that doesn’t charge or turn on

Saturday, July 23rd, 2016

Here is a quick guide to repairing this UPS that suddenly won’t charge or turn on (mine would ‘chirp’ and do nothing).  I will assume that you have checked the battery voltage and that it is good (26 volts or more for 2 batteries connected in a pack in series).

July 2023 update: Several 10uF 35V SMD capacitors failed with high ESR and one failed open circuit (C49). Several 4.7uF 25V SMD capacitors also now have high ESR. Based on this observation, I would recommend simply replacing all the SMD capacitors rather than fixing “only what’s broken”.

The problem more likely than not is the five 22uF 16V SMD electrolytic capacitors.  There are four near the middle of the mainboard and one near the LED at the edge.  The first thing I did, as usual when dealing with a spontaneous electronics failure, was to go over all the capacitors.  When I tested the 22uF capacitors with an ESR meter, they read anywhere from tens of ohms to infinite resistance.  I went over the rest of the SMD capacitors and they generally read from 1 to 5 ohms.  So the 22uF caps were the outliers.  Corroborating this theory were posts on forums about other similar small business models, Back-UPS RS 1500, Back-UPS RS 800, and APC Back-UPS RS 800 overload problem with no load: Solved indicating that the 22uF SMD capacitors were frequently at fault.


Notes on repairing a blown OCZ ModXStream Pro PC power supply

Saturday, July 2nd, 2016

A little while ago, this power supply that I purchased in 2011 blew up and in doing so, tripped the building breaker it was connected to through the APC Smart-UPS 1000 it was connected to.  With a little work, I was able to repair it.

There were some mistakes in the design, resulting in what appears to be planned obsolescence judging from the recent barrage of customer reviews complaining about failures, but this series of OCZ power supplies (including 500W, 600W and 700W units) are of reasonable quality (using presumably authentic Teapo capacitors, with the exception of the questionable main filter capacitor) and should last quite a few more years.

This repair diary including partial schematic and this message board thread give the basic background on the failure mode and repair.  If your model is one which has an internal fuse like mine, you are probably in luck as the blown fuse prevented further damage.  Otherwise, you have more components to check and likely more work to do.