Check disk: Difference between revisions

From Bitpost wiki
No edit summary
No edit summary
Line 14: Line 14:
You can do more.  Boot to a live mode to test root partitions.
You can do more.  Boot to a live mode to test root partitions.


This is a tested way to check a PARTITION for bad blocks, and repair:
== NUKING AND REFORMATTING AND TESTING A DRIVE ==
su -
 
e2fsck -c /dev/sda5
This can be done for new drives, or old drives that need a complete refresh.
 
=== DIRECT NUKE TEST ===
 
badblocks is an old program that destructively scans an entire drive (like dd) looking for bad blocks, by writing data to them all (which MAY cause firmware to improve things...?).  You have to use -b param to get it to work with larger drives.  THIS IS DESTRUCTIVE:
badblocks is an old program that destructively scans an entire drive (like dd) looking for bad blocks, by writing data to them all (which MAY cause firmware to improve things...?).  You have to use -b param to get it to work with larger drives.  THIS IS DESTRUCTIVE:
  sudo badblocks -t random -w -svv -b 4096 /dev/sda
  sudo badblocks -t random -w -svv -b 4096 /dev/sda
e2fsck should be preferred according to [man badblocks], but if you can't get a partition written you will need badblocks.
e2fsck should be preferred according to [man badblocks] (see next test).  But if you can't get a partition written you will need badblocks. OR IF YOU ARE IN A HURRY.  :-)
 
=== TEST VIA CREATING A PARTITION ===
 
* plug it into the SSD usb mounter
* sudo fdisk /dev/sda
* p
* d # to remove any existing partition
* n # to create new one, use defaults to make /dev/sda1
* w
* sudo mkfs.ext4 /dev/sda1
* sudo mount -t ext4 -o rw /dev/sda1 /mnt/sda1 # ensure it mounts
* sudo umount /mnt/sda1
* sudo e2fsck -c -c /dev/sda1 # non-destructive read/write, takes 8 hours on 8TB drive

Revision as of 19:37, 20 March 2025

See what you have. Use gparted, or these...

# basics
df
# NICE, this shows ALL DRIVES and where they are mounted!
sudo lsblk
# This is nice too, shows "data" for a raw drive, or type for a formatted one.  Nice to know!
sudo file -s /dev/xvdf

Most drive health maintenance is done internally by S.M.A.R.T.

# install smartctl tools
smartctl -c /dev/sdf # to peek at available tests and how long they typically take to run
smartctl -t short /dev/sdf
watch -n 3 smartctl -l selftest /dev/sdf # until success, takes about 1 minute
# if you're feeling ambitious, rerun with [-t long]

You can do more. Boot to a live mode to test root partitions.

NUKING AND REFORMATTING AND TESTING A DRIVE

This can be done for new drives, or old drives that need a complete refresh.

DIRECT NUKE TEST

badblocks is an old program that destructively scans an entire drive (like dd) looking for bad blocks, by writing data to them all (which MAY cause firmware to improve things...?). You have to use -b param to get it to work with larger drives. THIS IS DESTRUCTIVE:

sudo badblocks -t random -w -svv -b 4096 /dev/sda

e2fsck should be preferred according to [man badblocks] (see next test). But if you can't get a partition written you will need badblocks. OR IF YOU ARE IN A HURRY.  :-)

TEST VIA CREATING A PARTITION

  • plug it into the SSD usb mounter
  • sudo fdisk /dev/sda
  • p
  • d # to remove any existing partition
  • n # to create new one, use defaults to make /dev/sda1
  • w
  • sudo mkfs.ext4 /dev/sda1
  • sudo mount -t ext4 -o rw /dev/sda1 /mnt/sda1 # ensure it mounts
  • sudo umount /mnt/sda1
  • sudo e2fsck -c -c /dev/sda1 # non-destructive read/write, takes 8 hours on 8TB drive