TRIM support for linux

I have been using Linux since the late 90's. At the time the only available harddisks were of rotating matter. My first own solid state disk came with a ThinkPad T400 around 2011. This particular laptop is still operating until today. Last 5 years I have been using it. Some parts of the memory have been pushed into RAM, or also called a RAMdisk:

user@t400 ~ % grep tmpfs /etc/fstab
tmpfs           /var/tmp/portage        tmpfs           size=6G,mode=0777       0 0
tmpfs           /tmp                    tmpfs           nodev,nosuid,size=4G    0 0

This has been done to push expensive I/O operations outside of the SSD. It works over here that way until today.

Some days ago I have been searching for a new SSD for a new machine, read articles about technical solutions used on solid state disks. Particularly I have been looking for a I/O throughput, bus bandwidth, NAND and TRIM support. While reading about TRIM I realised Linux support for TRIM has grown more and more over the years. Solid state disks arrived at mainstream. They are almost everywhere today.

However my own settings for /etc/fstab are still like at beginning of the millennium. Apart from the file systems that I have been changing over the years:

  • ext2
  • ext3
  • ext4
  • XFS

Nothing big has changed. The SSD special support has to be configured in Linux.

At first we need to find out if the used disk supports TRIM at all:

# hdparm -I /dev/sda | grep TRIM
*    Data Set Management TRIM supported (limit 8 blocks)

Here are some benchmarks that have been done BEFORE enabling TRIM support in Linux:

Test 1 using cached read timings

# hdparm -tT /dev/sda

/dev/sda:
  Timing cached reads:   15996 MB in  2.00 seconds = 8003.84 MB/sec
  Timing buffered disk reads: 1850 MB in  3.00 seconds = 616.22 MB/sec

Test 2 using O_DIRECT to bypass page cache for timings

# hdparm -tT --direct /dev/sda

/dev/sda:
  Timing O_DIRECT cached reads:   1220 MB in  2.00 seconds = 609.16 MB/sec
  Timing O_DIRECT disk reads: 1530 MB in  3.00 seconds = 509.91 MB/sec

This is a benchmark after adding the discard option to each partition.

Test 1:

# hdparm -tT /dev/sda

/dev/sda:
 Timing cached reads:   16730 MB in  2.00 seconds = 8371.31 MB/sec
 Timing buffered disk reads: 2240 MB in  3.00 seconds = 746.05 MB/sec

Test 2: # hdparm -tT --direct /dev/sda

/dev/sda:
 Timing O_DIRECT cached reads:   1032 MB in  2.00 seconds = 515.73 MB/sec
 Timing O_DIRECT disk reads: 2164 MB in  3.00 seconds = 720.86 MB/sec

There is a slight improvement in every section. And 25% improvement while looking at the O_DIRECT disk reads, More than 630 MB more throughput only by enabling the discard option per partition.

The 3-rd benchmark has been made after changing the noatime option in /etc/fstab to relatime.

Test 1:

# hdparm -tT /dev/sda

/dev/sda:
 Timing cached reads:   16310 MB in  2.00 seconds = 8161.46 MB/sec
 Timing buffered disk reads: 2338 MB in  3.00 seconds = 778.97 MB/sec

Test 2: # hdparm -tT --direct /dev/sda

/dev/sda:
 Timing O_DIRECT cached reads:   1222 MB in  2.00 seconds = 610.47 MB/sec
 Timing O_DIRECT disk reads: 2186 MB in  3.00 seconds = 728.60 MB/sec

Those settings bring I/O improvements to running disks. Initally while creating partitions check its proper aligment with systemtools like fdisk or gparted

References:

Display modules information

To display specific linux module information in verbose mode use following command:

user % modinfo -p i915

modeset:Use kernel modesetting [KMS] (0=disable, 1=on, -1=force vga console preference [default]) (int) panel_ignore_lid:Override lid status (0=autodetect, 1=autodetect disabled [default], -1=force lid closed, -2=force lid open) (int) semaphores:Use semaphores for inter-ring sync (default: -1 (use per-chip defaults)) (int) enable_rc6:Enable power-saving render C-state 6. Different stages can be selected via bitmask values (0 = disable; 1 = enable rc6; 2 = enable deep rc6; 4 = enable deepest rc6). For example, 3 would enable rc6 and deep rc6, and 7 would enable everything. default: -1 (use per-chip default) (int) enable_fbc:Enable frame buffer compression for power savings (default: -1 (use per-chip default)) (int) lvds_channel_mode:Specify LVDS channel mode (0=probe BIOS [default], 1=single-channel, 2=dual-channel) (int) lvds_use_ssc:Use Spread Spectrum Clock with panels [LVDS/eDP] (default: auto from VBT) (int) vbt_sdvo_panel_type:Override/Ignore selection of SDVO panel mode in the VBT (-2=ignore, -1=auto [default], index in VBT BIOS table) (int) reset:Attempt GPU resets (default: true) (bool) enable_hangcheck:Periodically check GPU activity for detecting hangs. WARNING: Disabling this can cause system wide hangs. (default: true) (bool) enable_ppgtt:Override PPGTT usage. (-1=auto [default], 0=disabled, 1=aliasing, 2=full) (int) enable_execlists:Override execlists usage. (-1=auto [default], 0=disabled, 1=enabled) (int) enable_psr:Enable PSR (default: false) (int) preliminary_hw_support:Enable preliminary hardware support. (int) disable_power_well:Disable display power wells when possible (-1=auto [default], 0=power wells always on, 1=power wells disabled when possible) (int) enable_ips:Enable IPS (default: true) (int) fastboot:Try to skip unnecessary mode sets at boot time (default: false) (bool) prefault_disable:Disable page prefaulting for pread/pwrite/reloc (default:false). For developers only. (bool) load_detect_test:Force-enable the VGA load detect code for testing (default:false). For developers only. (bool) invert_brightness:Invert backlight brightness (-1 force normal, 0 machine defaults, 1 force inversion), please report PCI device ID, subsystem vendor and subsystem device ID to dri-devel@lists.freedesktop.org, if your machine needs it. It will then be included in an upcoming module version. (int) disable_display:Disable display (default: false) (bool) disable_vtd_wa:Disable all VT-d workarounds (default: false) (bool) enable_cmd_parser:Enable command parsing (1=enabled [default], 0=disabled) (int) use_mmio_flip:use MMIO flips (-1=never, 0=driver discretion [default], 1=always) (int) mmio_debug:Enable the MMIO debug code for the first N failures (default: off). This may negatively affect performance. (int) verbose_state_checks:Enable verbose logs (ie. WARN_ON()) in case of unexpected hw state conditions. (bool) nuclear_pageflip:Force atomic modeset functionality; asynchronous mode is not yet supported. (default: false). (bool) edp_vswing:Ignore/Override vswing pre-emph table selection from VBT (0=use value from vbt [default], 1=low power swing(200mV),2=default swing(400mV)) (int) enable_guc_submission:Enable GuC submission (default:false) (bool) guc_log_level:GuC firmware logging level (-1:disabled (default), 0-3:enabled) (int)

ViM column mode edit

Occasionally there is a need to edit in column mode to apply a certain string to f.e. 100 lines at one time. In the past I have been using Crimson Editor, later Emerald Editor while working with Windows. While working with OSX I have been using TextMate for that purpose.

Now while using Linux my editor of choice is ViM .To use ViM(Vi) column mode edit use following commands.

  • Ctrl + v column mode edit command
  • Select the columns, rows (h,j,k,l)
  • Shift + i to go into insert mode in column mode
  • Type in desired text. At the time of typing only ONE row is changed, showed
  • Press the Esc key to apply the changes to the selected column

Et voila!