General Storage Topics¶
Ext4¶
Ext4 allows a maximum block size of just 4096 bytes. The primary improvement over ext3 is extent allocation, which stores the start and end block numbers for each contiguous run of blocks, thus significantly reducing the number of indirect blocks for larger files (ref). As a result, ext4 cannot be simply "upgraded" from ext3 and requires a reformat to enable the new allocation scheme.
Reserved blocks¶
Reserved blocks is a feature for the ext family that allows only the superuser to write data when space is low. As most system writes something during boot time, this allows such systems to boot normally and give admins a chance to clean up stuff, before the entire system is no longer responsive.
The default value is 5% of the total filesystem size. This can be specified at format time with mke2fs -m <percentage>, or later changed with tune2fs -m <percentage>.
Mount options¶
errors=remount-ro: On errors, remount the filesystem read-only. This allows the system to operate at a degraded state, to make time for manual intervention. If this option is not specified, the value stored in the filesystem superblock is used. It defaults tocontinueand can be changed withtune2fs -e remount-ro.discard: Whether to issue discard/TRIM to the block device when blocks are freed. The default mount option can be enabled withtune2fs -o discard. Note that this is usually not required as your distro most likely already providesfstrim.timerthat runsfstrimweekly, but some may find it useful when writes are frequent.
Discard over USB¶
Identify device:
$ find /sys/ -name provisioning_mode -exec grep -H . {} + | sort
/sys/devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/usb2/2-2/2-2:1.0/host0/target0:0:0/0:0:0:0/scsi_disk/0:0:0:0/provisioning_mode:full
If the provisioning mode shows "full", change it to "unmap" and you're good to go!
echo unmap > /sys/devices/platform/scb/fd500000.pcie/pci0000:00/0000:00:00.0/0000:01:00.0/usb2/2-2/2-2:1.0/host0/target0:0:0/0:0:0:0/scsi_disk/0:0:0:0/provisioning_mode
Now you can run blkdiscard on (partitions of) that device, or fstrim on a mounted filesystem from that device.
Source: Gentoo Wiki