Saya memiliki drive (kartu SD) dengan beberapa partisi ext4 tetapi juga beberapa ruang yang tidak terisi. The fstrim
utilitas hanya dapat bekerja dalam filesystem. Sebelum saya menemukan kembali roda dan menulis satu, apakah ada utilitas lain yang dapat TRIM ruang yang tidak terisi (atau yang dapat TRIM rentang yang ditentukan secara eksplisit)?
Saya dapat memverifikasi bahwa sebagian besar ruang yang tidak terisi pada perangkat saat ini tidak diketahui bebas oleh pengontrol, seperti yang saya amati bahwa, pada kartu khusus ini, dibaca ruang yang dipangkas mengembalikan 0, tetapi pemindaian perangkat menunjukkan banyak data sampah yang tersisa.
Sunting: Saya mengalami masalah saat menggunakan hdparm
. Contoh di bawah ini membuang sektor pertama, tetapi saya melihat hasil yang sama terlepas dari rentang yang saya tentukan. fstrim
tidak memiliki masalah pada perangkat:
root@ubuntu:~# hdparm --please-destroy-my-drive --trim-sector-ranges 0:1 --verbose /dev/mmcblk0
/dev/mmcblk0:
trimming 1 sectors from 1 ranges
outgoing cdb: 85 0d 06 00 01 00 01 00 00 00 00 00 00 40 06 00
outgoing_data:
00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
ioctl(fd,SG_IO): Invalid argument
FAILED: Invalid argument
Saya sedang menyelidiki lebih lanjut tetapi apakah ada yang punya wawasan?
blkdiscard
sepertinya tidak tersedia di repositori paket standar saya (Ubuntu 12.04, sepertinya tidak ada di sana util-linux
).
hdparm
bekerja untuk saya karena suatu alasan, tetapi saya mengambil sumber util-linux dari github.com/karelzak/util-linux/tree/stable/v2.23 , membuatnya ( ./autogen.sh ; ./configure ; make blkdiscard
) dan bekerja dengan baik. Masih bingung tentang hdparm
tetapi blkdiscard
melakukan apa yang saya inginkan. Bonus: Tidak perlu membuat sistem file sementara terlebih dahulu, Anda dapat menggunakan sfdisk -l
untuk mengetahui ruang antara partisi dan blkdiscard
memangkasnya.
blkdiscard
bisa bekerja dengan opsi offset / panjang. Jadi partisi sementara yang saya sarankan bahkan tidak perlu. Bagus!
blkdiscard
pada mereka yang memotong seluruh perangkat.