Bad Sectors là những sectors đã bị hỏng, và không thể sử dụng để chứa dữ liệu nữa, nếu dữ liệu của bạn có phần chứa trên bad sectors thì có thể file sẽ bị hỏng vì không truy cập được đến những phần nó nữa, vì vậy cần config để OS không lưu dữ liệu lên những phần nó nữa.
badblocks là một công cụ để check bad sector trên HDD, nó sẽ liệt kê ra một danh sách các sector không thể sử dụng được nữa. badblocks là một phần trong dự án e2fsprogs.
1. Dùng badsector để nhận diện những badblocks và lưu nó vào một file (Quá trình này kéo dài hơi lâu.)
1 2 |
sudo badblocks -v /dev/sdb2 >badblock Checking for bad blocks (read-only test): |
2. Dùng e2fsck để format lại các badblocks đó.
1 |
sudo e2fsck -l badblock /dev/sdb2 |
-l filename
Add the block numbers listed in the file specified by filename to the list of
bad blocks. The format of this file is the same as the one generated by the
badblocks(8) program. Note that the block numbers are based on the blocksize
of the filesystem. Hence, badblocks(8) must be given the blocksize of the
filesystem in order to obtain correct results. As a result, it is much simpler
and safer to use the -c option to e2fsck, since it will assure that the correct
parameters are passed to the badblocks program.
Bây giờ OS sẽ bỏ qua những sectors được badblocks phát hiện ra.