147 votes
Accepted

Trim audio file using start and stop times

ffmpeg seems to have a new option -to in the documentation: -to position (input/output) Stop writing the output or reading the input at position. position must be a time duration specification, ...
Miati's user avatar
  • 3,150
25 votes
Accepted

How do I trim bytes from the beginning and end of a file?

You can combine GNU tail and head: tail -c +26 file | head -c -2 will output the contents of file starting at byte 26, and stopping two bytes (minus two -2) before the end. (-c operates on bytes, ...
Stephen Kitt's user avatar
18 votes
Accepted

How can I tell if a Linux block device is trimmable or not?

You can check the device’s maximum discard sizes, e.g. $ cat /sys/block/X/queue/discard_max_hw_bytes (replacing X as appropriate). If this shows a value greater than 0, the device supports discards: ...
Stephen Kitt's user avatar
17 votes

How do I check TRIM?

Try lsblk -D TRIM/discard is available, if the DISC-MAX column is not 0B Example (SSD/trim available) [root@foo bar]# lsblk -D NAME DISC-ALN DISC-GRAN DISC-MAX DISC-ZERO sda 0 4K ...
beck's user avatar
  • 171
12 votes

How do I trim bytes from the beginning and end of a file?

dd will do both for you in a single command. Set the block size to 1 byte, skip the 25 first bytes, count to the size of file minus skip and end bytes. 100 byte file file.img dd if=./file.img of=./...
jc__'s user avatar
  • 2,605
11 votes
Accepted

Is mounting with "discard" needed for TRIM?

If the filesystem is mounted with discard, then deleting files will automatically cause the TRIM command to be issued. This often has a negative performance impact, so it's generally better not to use ...
forest's user avatar
  • 2,655
10 votes
Accepted

Do Linux swap partitions support trimming?

Yes, as it is visible the manual of the swapon command, it has a discard option. It would be meaningless if the linux swap wouldn't support it. Of course the underlying device should support trimming.
peterh's user avatar
  • 9,733
9 votes

How can I tell if a Linux block device is trimmable or not?

Utilize the hdparm command, which lets you perform low level commands on a disk device. The option hdparm -I /dev/sda (or insert block device instead of sda), will query the drive for information. ...
dcom-launch's user avatar
8 votes
Accepted

How does the filesystem (ext4) "store" TRIM information?

I don't know if ext4 actually stores it anywhere. Other filesystems certainly don't. ext4 avoids what it already trimmed in the current session only - while it's still mounted. Once you reboot or re-...
frostschutz's user avatar
  • 48.9k
7 votes

independently verify that TRIM indeed works on SSD

Your logic is not incorrect. But it is only valid if some conditions are satisfied. The TRIM command, as specified in the ATA command set, may or may not zero the sectors it is issued against. ...
fra-san's user avatar
  • 10.2k
7 votes

Trim an audio file into multiple segments using `ffmpeg` with a single command

If the segments are non-overlapping, you can use the segment muxer. ffmpeg -i input.mp3 -vn -c copy -f segment -segment_times 0,8,22 output%d.mp3
Gyan's user avatar
  • 1,020
7 votes

SSD: how often should I do fstrim?

man fstrim in Ubuntu 16.04 has Running fstrim frequently, or even using mount -o discard, might nega‐ tively affect the lifetime of poor-quality SSD devices. For most desk‐ top and server systems ...
reducing activity's user avatar
7 votes
Accepted

Why fstrim appears not to trim data blocks on btrfs (+ecrypts)?

It is a common misunderstanding to worry about the sizes reported by fstrim. It really doesn't mean anything. Just ignore it. fstrim just issues the appropriate ioctl, everything else is the ...
frostschutz's user avatar
  • 48.9k
6 votes
Accepted

trim and fade in/out video and audio with avconv (or different tool)

I finally found the time to try the answer suggested by @Mario G., but it seemed extremely cumbersome. I need to do this many dozens of times. I read the documentation of ffmpeg and found it much more ...
Philippos's user avatar
  • 13.4k
6 votes
Accepted

jpegtran - losslessly crop left portion of image

jpegtran can't losslessly cut at any finer increment than the Minimum Coded Unit size, which varies depending on the channel and the chroma sampling mode. It's going to be 8×8, 16×8, or 16×16. This ...
Warren Young's user avatar
6 votes

How do I check if my ssd supports fstrim?

You may also try lsblk --discard Non-zero values under DISC-GRAN and DISC-MAX indicate trim support. $ lsblk --discard NAME DISC-ALN DISC-GRAN DISC-MAX DISC-ZERO nvme0n1 0 ...
sc608's user avatar
  • 161
4 votes
Accepted

Group items from column using awk

$ awk -F"/" '!seen[$1]++ {print $1}' findint.txt Eth1 Eth101 Eth103 Gi0 To get the output all in one comma-separated line, you could set the output separator ORS to , however you'd need to make a ...
steeldriver's user avatar
4 votes

How can I tell if a Linux block device is trimmable or not?

To check if the device supports trim/discard one can also use linux lsblk utility. If the device's discard limits like granularity and max_sectors is non-zero, then the discard/trim support is enabled,...
GauriK's user avatar
  • 41
3 votes
Accepted

fstrim does not trim swap

So apparently because swap is not considered as a normal filesystem, it will not be trimmed when fstrim is run manually. But it appears that the Linux kernel does the trimming for the swap when it is ...
teagut's user avatar
  • 91
3 votes
Accepted

Trim an audio file into multiple segments using `ffmpeg` with a single command

Sure, just give it more output files: ffmpeg -i input.mp3 -ss S -to E -c copy output1.mp3 -ss S -to E -c copy output2.mp3 … Options after the input file actually pertain to the output file (so the -...
derobert's user avatar
  • 110k
3 votes

jpegtran - losslessly crop left portion of image

In case someone runs into this and are willing to cut at multiples of 16 pixels, the format for cutting 16 pixels from all sides is this: jpegtran -perfect -crop 1368x1368+16+16 -outfile crop.jpg ...
passerby51's user avatar
3 votes
Accepted

Disable allow-discards on encrypted partition

It turned out, LUK2 can permanently store metadata in the header. It is possible to enable allow-discards and store in the partition itself (without any further configuration -e.g., kernel parameters) ...
BiagioF's user avatar
  • 151
3 votes

FSTRIM for USB-SSD boot drive

Generally, TRIM is not available over USB. What USB enclosure are you using? Some of them claim to allow TRIM (if they support UASP (USB Attached SCSI Protocol), and some of them even have an eSATA ...
ubfan1's user avatar
  • 131
2 votes
Accepted

How do I check TRIM?

as @meuh pointed out in the comment, I need to run the test on my EXT4 partition, while I tried it on my /tmp SOLVED! PS: following the test result, I can confirm that the drive on my XPS 9343 (...
mattia.b89's user avatar
  • 3,238
2 votes
Accepted

Enabling Synchronous TRIM Only

I found the solution. I tried fstrim with explicit statements of the partitions as a weekly cronjob shortly after I posted the answer but didn't know whether it was safe. Furthermore, I didn't know ...
UTF-8's user avatar
  • 3,237
2 votes

Should the 'discard' option be used for mounting a swap file?

Some of the questions/suggestions left by the other answer can be answered by reading the documentation below. I don't believe discard is recommended on filesystems. It is recommended to run fstrim ...
sourcejedi's user avatar
  • 50.2k
2 votes

Should the 'discard' option be used for mounting a swap file?

I would say no. 1: The swap space does not use the same concept of free space as filesystem 2: what matter is that you always keep at least 25% free space on your SSD (this value was given to me by ...
Benoit-Pierre DEMAINE's user avatar
2 votes

How do I trim bytes from the beginning and end of a file?

With ksh93: { head -c "$n"; } < file <#((n = EOF - 25 - 2 , 25)) Or to do it in-place: { head -c "$n"; } < file <#((n = EOF - 25 - 2 , 25)) 1<>; file If you have /opt/ast/bin ...
Stéphane Chazelas's user avatar
2 votes

independently verify that TRIM indeed works on SSD

Does the SSD have a built-in hardware encryption layer? If it has one, then the TRIMmed blocks may be all-zeroes (or possibly all-ones) at the raw hardware level, but since the computer sees them ...
telcoM's user avatar
  • 95.8k
2 votes

Boot Error -> ipmi:dmi : Invalid offset : 0

This is absolutely kernel-related. So that, even kernels provided in the iso by the distribution officially may cause this (in my case it was 4.13 with all *buntus I tried that day, though it was the ...
Emin's user avatar
  • 21

Only top scored, non community-wiki answers of a minimum length are eligible