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, ...
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, ...
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:
...
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 ...
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=./...
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 ...
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.
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. ...
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-...
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.
...
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
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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,...
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 ...
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 -...
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 ...
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) ...
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 ...
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 (...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
trim × 55ssd × 33
linux × 10
fstrim × 10
filesystems × 6
ext4 × 6
btrfs × 6
sed × 3
partition × 3
lvm × 3
encryption × 3
swap × 3
ffmpeg × 3
ubuntu × 2
mount × 2
audio × 2
hard-disk × 2
mdadm × 2
block-device × 2
cut × 2
cryptsetup × 2
dm-crypt × 2
nvme × 2
samsung × 2
shell-script × 1