Difference between revisions of "Hard Disk Drive"
Plittlefield (talk | contribs) |
|||
Line 101: | Line 101: | ||
[https://www.bugaco.com/calculators/seagate_date_code.php Seagate date code calculator] | [https://www.bugaco.com/calculators/seagate_date_code.php Seagate date code calculator] | ||
+ | |||
+ | == Reduce Reserved Space To Increase Available Space == | ||
+ | |||
+ | Format the drive with 1% reserved space instead of the usual 5% ... | ||
+ | |||
+ | sudo mkfs.ext4 -m 1 /dev/xxxxx | ||
== Find Hard Drive Serial '''Windows''' == | == Find Hard Drive Serial '''Windows''' == |
Latest revision as of 10:18, 14 September 2024
Solid State Drive SSD
Improve Performance
Long Boot Time
Fix Long Boot Time Delay
Disable fstrim ...
sudo -i rm /var/lib/systemd/timers/stamp-fstrim.timer systemctl stop fstrim.service fstrim.timer systemctl disable fstrim.service fstrim.timer systemctl mask fstrim.service fstrim.timer shutdown -r
https://askubuntu.com/questions/1165128/fstrim-is-causing-high-boot-time
Encryption
Standard With Passphrase
How to encrypt an external backup drive in Linux.
Switch to root user...
sudo -i
Wipe hard drive...
wipe2fs -a /dev/sdX
Install software...
apt-get install cryptsetup
Encrypt drive...
cryptsetup --verbose --verify-passphrase luksFormat /dev/sdX
Unlock drive...
cryptsetup --verbose luksOpen /dev/sdX securebackup
Format drive...
mkfs -t ext4 -m 1 -O dir_index,filetype,sparse_super /dev/mapper/securebackup
Create directory to mount drive...
mkdir /mnt/usb
Mount drive...
mount -v /dev/mapper/securebackup /mnt/usb/
Backup files...
rsync -av /home /mnt/usb/
Unmount drive...
umount /mnt/usb
Lock drive...
cryptsetup luksClose securebackup
Optional With Key File
Create key file to unlock automatically...
sudo dd if=/dev/urandom of=/root/keyfile bs=1024 count=4 cryptsetup --verbose luksAddKey /dev/sdX /root/keyfile
Unlock drive using key file...
cryptsetup --verbose --key-file /root/keyfile luksOpen /dev/sdX securebackup
Mount drive...
mount -v /dev/mapper/securebackup /mnt/usb/
Backup files...
rsync -av /home /mnt/usb/
Unmount drive...
umount /mnt/usb
Lock drive...
cryptsetup luksClose securebackup
https://www.wikihow.com/Encrypt-an-External-Hard-Drive-on-Linux
Seagate
Reduce Reserved Space To Increase Available Space
Format the drive with 1% reserved space instead of the usual 5% ...
sudo mkfs.ext4 -m 1 /dev/xxxxx
Find Hard Drive Serial Windows
Open Powershell
wmic path win32_physicalmedia get SerialNumber
ZALMAN Clever Hard Disk Drive External Case
Through Virtual Driver technology, and touch pad with screen, you can this to mount your hard drive as a CDROM or USB drive.
Windows Monitoring Software
Current build of Windows GUI for smartmontools here.
Daily builds can be found here.
Western Digital WD Warranty Check
http://wdsupport.wdc.com/warranty/serialinput.asp?custtype=end&requesttype=warranty&lang=en
Western Digital WD Support Area Product Registered
https://westerndigital.secure.force.com/ind/ID_ProductsRegistered
Stop Spinning USB Hard Disk Drive
Make sure it is not mounted, then run the following command...
sdparm --readonly --command=stop /dev/sdX
USB 3 Details
[48207.031486] usb 9-1: new SuperSpeed USB device number 2 using xhci_hcd
Checking For Bad Sectors
badblocks -s /dev/sdX1
- Man: http://linux.die.net/man/8/badblocks
- ArchWiki: https://wiki.archlinux.org/index.php/Badblocks
- Wikipedia: http://en.wikipedia.org/wiki/Badblocks
Western Digital WD Idle Timer Load Cycle Count
http://www.jzab.de/content/wdidle-bootcd
or
http://www.ultimatebootcd.com/download.html
WDIDLE3 /D
or
http://idle3-tools.sourceforge.net/
thinkpad ~ # smartctl --device=sat --all /dev/sda |grep 'Load_Cycle_Count' 193 Load_Cycle_Count 0x0032 105 105 000 Old_age Always - 286710
thinkpad ~ # emerge -q sys-apps/idle3-tools >>> Verifying ebuild manifests >>> Emerging (1 of 1) sys-apps/idle3-tools-0.9.1 >>> Installing (1 of 1) sys-apps/idle3-tools-0.9.1 >>> Recording sys-apps/idle3-tools in "world" favorites file... thinkpad ~ # idle3ctl -g /dev/sda Idle3 timer set to 40 (0x28) thinkpad ~ # idle3ctl -d /dev/sda Idle3 timer disabled Please power cycle your drive off and on for the new setting to be taken into account. A reboot will not be enough!
Identify Drives
ls -la /dev/disk/by-id
Self-Monitoring, Analysis and Reporting Technology System (S.M.A.R.T.)
Linux uses SmartMonTools to access the SMART information.
smartctl 5.43 2012-06-30 r3573 [x86_64-linux-3.3.8-gentoo] (local build) Copyright (C) 2002-12 by Bruce Allen, http://smartmontools.sourceforge.net
The examples below use /dev/sda as the first internal hard disk drive, and /dev/sdb as the external usb drive.
Scan For Devices
smartctl --scan
Device Driver
smartctl --device=test /dev/sda /dev/sda: Device of type 'scsi' [SCSI] detected /dev/sda [SAT]: Device open changed type from 'scsi' to 'sat' /dev/sda [SAT]: Device of type 'sat' [ATA] opened
So, we use the sat driver for this device.
Turn SMART Feature ON
smartctl --device=sat --smart=on /dev/sda
Information
smartctl --device=sat --all /dev/sda
Health Check
smartctl --device=sat --health /dev/sda
Tests - Internal Drives
Self-Test: Short (internal SATA)
smartctl --device=sat --test=short /dev/sda
Self-Test: Medium (internal SATA)
smartctl --device=sat --test=conveyance /dev/sda
Self-Test: Long (internal SATA)
smartctl --device=sat --test=long /dev/sda
Tests - USB External Drives
Self-Test: Short
smartctl --device=sat,16 --test=short /dev/sdb
Self-Test: Medium
smartctl --device=sat,16 --test=conveyance /dev/sdb
Self-Test: Long
smartctl --device=sat,16 --test=long /dev/sdb
The last long test on an external USB drive may need to be combined with this series of commands to stop the kernel from sleeping the drive:-
while true; do dd if=/dev/sdX iflag=direct count=1 of=/dev/null; sleep 60s; done
Tests Stop
smartctl --device=sat --abort /dev/sda
Show Test Logs
Terminal:~$ sudo smartctl --device=sat --log=selftest /dev/sdX The output should look like the following: smartctl 6.2 2013-07-26 r3841 [x86_64-linux-3.16.0-31-generic] (local build) Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org === START OF READ SMART DATA SECTION === SMART Self-test log structure revision number 1 Num Test_Description Status Remaining LifeTime(hours) LBA_of_first_error # 1 Extended offline Completed without error 00% 62071 - # 2 Short offline Completed without error 00% 57922 - # 3 Short offline Completed without error 00% 51265 -
Show Hard Drive Details and Test Logs
Terminal:~$ sudo smartctl -i --device=sat --log=selftest /dev/sdX The output should look like the following: smartctl 6.2 2013-07-26 r3841 [x86_64-linux-3.13.0-38-generic] (local build) Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org === START OF INFORMATION SECTION === Model Family: Western Digital Caviar SE Serial ATA Device Model: WDC WD800JD-60JRA0 Serial Number: WD-WMAMD2064823 Firmware Version: 05.01C05 User Capacity: 80,026,361,856 bytes [80.0 GB] Sector Size: 512 bytes logical/physical Device is: In smartctl database [for details use: -P show] ATA Version is: ATA/ATAPI-7 (minor revision not indicated) Local Time is: Tue Oct 14 13:06:35 2014 BST SMART support is: Available - device has SMART capability. SMART support is: Enabled === START OF READ SMART DATA SECTION === SMART Self-test log structure revision number 1 Num Test_Description Status Remaining LifeTime(hours) LBA_of_first_error # 1 Extended offline Completed without error 00% 62071 - # 2 Short offline Completed without error 00% 57922 - # 3 Short offline Completed without error 00% 51265 -
Daily, Weekly, Monthly Checks In CRON
# hard disk drive checks @daily /usr/sbin/smartctl --device=sat --all /dev/sda && /usr/sbin/smartctl --device=sat --all /dev/sdb && /usr/sbin/smartctl --device=sat --all /dev/sdc @weekly /usr/sbin/smartctl --device=sat --test=short /dev/sda && /usr/sbin/smartctl --device=sat --test=short /dev/sdb && /usr/sbin/smartctl --device=sat --test=short /dev/sdc @monthly /usr/sbin/smartctl --device=sat --test=long /dev/sda && /usr/sbin/smartctl --device=sat --test=long /dev/sdb && /usr/sbin/smartctl --device=sat --test=long /dev/sdc
How To Stop A Hard Disk Drive From Power Management Sleep During SMART Tests
while true; do dd if=/dev/sdX iflag=direct count=1 of=/dev/null; sleep 60s; done
Mac OS X / MacOS
./smartctl --help smartctl 6.5 2016-05-07 r4318 [Darwin 16.6.0 x86_64] (local build) Copyright (C) 2002-16, Bruce Allen, Christian Franke, www.smartmontools.org
Usage: smartctl [options] device
Show Information Options
-h, --help, --usage Display this help and exit -V, --version, --copyright, --license Print license, copyright, and version information and exit -i, --info Show identity information for device --identify[=[w][nvb]] Show words and bits from IDENTIFY DEVICE data (ATA) -g NAME, --get=NAME Get device setting: all, aam, apm, lookahead, security, wcache, rcache, wcreorder -a, --all Show all SMART information for device -x, --xall Show all information for device --scan Scan for devices --scan-open Scan for devices and try to open each device
SMARTCTL Run-Time Behaviour Options
-q TYPE, --quietmode=TYPE (ATA) Set smartctl quiet mode to one of: errorsonly, silent, noserial -d TYPE, --device=TYPE Specify device type to one of: ata, scsi, nvme[,NSID], sat[,auto][,N][+TYPE], usbcypress[,X], usbjmicron[,p][,x][,N], usbprolific, usbsunplus, auto, test -T TYPE, --tolerance=TYPE (ATA) Tolerance: normal, conservative, permissive, verypermissive -b TYPE, --badsum=TYPE (ATA) Set action on bad checksum to one of: warn, exit, ignore -r TYPE, --report=TYPE Report transactions (see man page) -n MODE, --nocheck=MODE (ATA) No check if: never, sleep, standby, idle (see man page)
Device Feature Enable/Disable Commands
-s VALUE, --smart=VALUE Enable/disable SMART on device (on/off) -o VALUE, --offlineauto=VALUE (ATA) Enable/disable automatic offline testing on device (on/off) -S VALUE, --saveauto=VALUE (ATA) Enable/disable Attribute autosave on device (on/off) -s NAME[,VALUE], --set=NAME[,VALUE] Enable/disable/change device setting: aam,[N|off], apm,[N|off], lookahead,[on|off], security-freeze, standby,[N|off|now], wcache,[on|off], rcache,[on|off], wcreorder,[on|off]
Read and Display Options
-H, --health Show device SMART health status -c, --capabilities (ATA, NVMe) Show device SMART capabilities -A, --attributes Show device SMART vendor-specific Attributes and values -f FORMAT, --format=FORMAT (ATA) Set output format for attributes: old, brief, hex[,id|val] -l TYPE, --log=TYPE Show device log. TYPE: error, selftest, selective, directory[,g|s], xerror[,N][,error], xselftest[,N][,selftest], background, sasphy[,reset], sataphy[,reset], scttemp[sts,hist], scttempint,N[,p], scterc[,N,M], devstat[,N], ssd, gplog,N[,RANGE], smartlog,N[,RANGE], nvmelog,N,SIZE -v N,OPTION , --vendorattribute=N,OPTION (ATA) Set display OPTION for vendor Attribute N (see man page) -F TYPE, --firmwarebug=TYPE (ATA) Use firmware bug workaround: none, nologdir, samsung, samsung2, samsung3, xerrorlba, swapid -P TYPE, --presets=TYPE (ATA) Drive-specific presets: use, ignore, show, showall -B [+]FILE, --drivedb=[+]FILE (ATA) Read and replace [add] drive database from FILE [default is +/usr/local/etc/smart_drivedb.h and then /usr/local/share/smartmontools/drivedb.h]
Device Self-Test Options
-t TEST, --test=TEST Run test. TEST: offline, short, long, conveyance, force, vendor,N, select,M-N, pending,N, afterselect,[on|off] -C, --captive Do test in captive mode (along with -t) -X, --abort Abort any non-captive test on device
SMARTCTL Examples
smartctl -a disk0 (Prints all SMART information) smartctl -t long /dev/disk0 (Executes extended disk self-test) smartctl --smart=on --saveauto=on /dev/rdisk0 (Enables SMART on first disk) smartctl --attributes --log=selftest --quietmode=errorsonly /dev/disk0 (Prints Self-Test & Attribute errors) smartctl -a IOService:/MacRISC2PE/pci@f4000000/AppleMacRiscPCI/ata-6@D/AppleKauaiATA/ATADeviceNub@0/IOATABlockStorageDriver/IOATABlockStorageDevice (You can use IOService: ...) smartctl -c IODeviceTree:/pci@f4000000/ata-6@D/@0:0 (... Or IODeviceTree:)