Pages

Thursday, 4 July 2013

Simple Hard Disk Utilities In Linux


We Can Use the following Commands to Monitor Storage/HardDisk

badblocks
Use the ‘badblocks’ command to run the block scan
badblocks -sv PartitionName/HDD

dmesg

Filesystems can still become corrupted through software bugs or hardware failures. In some cases, where accessing particular files results in I/O errors, the cause is usually hardware. You can confirm this by checking the output of the ‘dmesg’ command for ‘I/O’ messages
dmesg | grep blocks

e2fsck

For ext2 and ext3 Filesystems, use ‘e2fsck’. The ‘-y’ option tells ‘e2fsck’ to take all available measures to correct the Filesystem
e2fsck -v -y PartitionName/HDD

fsck
Before running this, Unmount the partition/HDD.
fsck -l bad-blocks PartitionName/HDD 

Exit Codes
0 – No errors
1 – Filesystem errors corrected
2 – System should be rebooted
4 – Filesystem errors left uncorrected
8 – Operational error
16 – Usage or syntax error
32 – Fsck canceled by user request
128 – Shared-library error

Importent Options:
Check All Filesystems in One Run using Option -A
Global check by adding -R
Check Only a Specific Filesystem Type using Option -t
Don’t execute Fsck on Mounted Filesystem using Option -M
Skip the Display Title using Option -T
Avoid Repair, but Report Problems to Stdout using Option -n
Automatically Repair the Damaged Portions using Option -a
fsck -a -AR
fsck -AR -y
fsck -AR -t ext2 -y
fsck -M Partition 
fsck -n Partition

hdparm : 
Get/set SATA/IDE device parameters
hdparm -I /dev/sda    ## Request  identification  info  directly from the drive.
hdparm -tT /dev/sda  ##Speed Test read write


lshw
To display all disks and storage controllers in the system
lshw -class disk -class storage

sdparm
To list common mode parameters of a disk, enter
sdparm /dev/sda

blockdev
Call block device ioctls
blockdev --getsz /dev/sda

udisks
udisks --show-info /dev/sda

smartctl
Failing hard Disk detailed report
smartctl -a /dev/hda
smartctl -s on -a /dev/hda
smartctl -i /dev/sda
smartctl -H /dev/sda

smartctl --attributes --log=selftest /dev/sda
smartctl -l selftest /dev/sda
smartctl -c /dev/sda
smartctl -t long /dev/sda

smartctl -s on -o on -S on /dev/sda
smartctl -d TYPE -i /dev/sda
where TYPE is usually one of ata, scsi, or sat (for serial ata).
-s on: This turns on S.M.A.R.T. support or does nothing if it’s already enabled.
-o on: This turns on offline data collection. Offline data collection periodically updates certain S.M.A.R.T. attributes. Theoretically this could have a performance impact. However, from the smartctl man page:
Normally, the disk will suspend offline testing while disk accesses are taking place, and then automatically resume it when the disk would otherwise be idle, so  in  practice  it has little effect.
-S on: This enables “autosave of device vendor-specific Attributes”.


To get the Partition/HDD details, can use
parted /dev/sda 'print'
fdisk -l
tune2fs -l Partition 
dumpe2fs Partition

palimpsest is also can use. Its a GUI tool

No comments:

Post a Comment