#19 TRIM of swap devices

open
nobody
None
5
2014-08-22
2010-05-06
R.
No

Attached is a simple script which can TRIM a swap device. It just disables the swap device, TRIM's the whole thing, and re-enables the swap device. It supports encrypted swap devices as well as swap devices on LVM - see also https://sourceforge.net/tracker/?func=detail&aid=2997551&group_id=136732&atid=736684 . Usage is basically the same as for wiper.sh, except that you must always specify the swap device.

Discussion

  • R.
    R.
    2010-05-06

    Script to TRIm a swap device

     
    Attachments
  • Jost
    Jost
    2012-01-03

    Hi there!
    This script does not seem to work any more in Ubuntu 11.10 (64bit).
    from the looks of it my guess would be getting the secsize fails.
    Never had problems with it on previous OS versions with similar setups.

    Is there any way to fix it?

    System Info:
    Ubuntu oneiric 11.10, live-upgraded from a clean 11.04 install
    hdparm 9.37-ubuntu1
    kernel 3.0.0-13-generic
    OCZ Vertex Turbo 60GB drive with firmware 1.6 and/or 1.7
    drive set up as Vertex-partition-LUKS-lvm2-pv-lvm2-vg-lvm2-lv (linear) - swap

    output:
    root@theta:/# ./wipe_swap.sh --verbose --commit /dev/mapper/system-swap
    '/dev/mapper/system-swap'
    '0'
    HDIO_DRIVE_CMD(identify) failed: Inappropriate ioctl for device
    ./wipe_swap.sh: line 102: pgsize / secsize: division by 0 (error token is "secsize")
    ./wipe_swap.sh: line 108: swplen * 1024 / secsize: division by 0 (error token is "secsize")
    swapoff on /dev/mapper/system-swap
    ^C (hangs)