In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article is about how to carry out orangepi linux hard disk automatic hibernation, the editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article.
In order to extend the service life of the hard disk, when the hard disk is not in use, it is necessary to let the hard disk hibernate. At present, there are some software that can do this automatically, such as hdparm, hd-idle and sdparm. Which one to use depends on the USB to SATA controller and the hard disk itself. Of course, what we are talking about here are mechanical hard drives, but solid state drives have not been studied.
Note: do not let the mechanical hard disk sleep and wake up frequently, which will put a heavy load on the motor and bearings and aggravate the wear and tear of the hard disk. The minimum dormancy time recommended by general manufacturers is 3-5 minutes.
First check the hard disk device name, which is usually / dev/sda,dev/sdb and so on.
Sudo blkid
For example, output
/ dev/mmcblk0p1: SEC_TYPE= "msdos" LABEL= "boot" UUID= "15CD-3B79" TYPE= "vfat"
/ dev/mmcblk0p2: UUID= "13d368bf-6dbf-4751-8ba1-88bed06bef77" TYPE= "ext4"
Dev/sda1: UUID= "7e623443-f19a-4564-8e60-e9d2170ac32a" TYPE= "ext4"
Dev/sdb1: LABEL= "COLORSPACE" UUID= "F8E6-4FDB" TYPE= "vfat"
/ dev/sdb2: UUID= "3007-F316" TYPE= "exfat"
The hard disk device is named / dev/sdb, and the hard disk has two partitions
Install and configure hdparm
First test whether hdparm is supported.
Install hdparm
Sudo apt-get install hdparm-y
Make sure your hard drive supports hdparm
Sudo hdparm-y / dev/sdb
If you output the following result, it indicates support
/ dev/sdb:issuing standby command
If you see output similar to the following, it is not supported. You can skip to hd-idle or sdparm
/ dev/sda:issuing standby command
SG_IO: bad/missing sense data, sb []: 70 00 05 00 00 00 0a 00 00 00 20 00 00 00
Check whether the hard disk supports write caching
Sudo hdparm-I / dev/sdb | grep 'Write cache'
If you see * (asterisk), support it.
* Write cache
If you do not see * (asterisk), it is not supported.
Write cache
Edit configuration file
Sudo vim / etc/hdparm.conf
The spindown_time value is multiplied by 5 to get the total time (in seconds). For example, if you want to configure hibernation for 10 minutes, spindown_time = 10 * 60 / 5 = 120
Add at the end of the file
/ dev/sdb {
Write_cache = on
Spindown_time = 120
}
If write caching is not supported, remove write_cache = on.
Restart the hdparm service
Sudo service hdparm restart
For more hdparm configuration, please refer to this (http://www.linux-magazine.com/Online/Features/Tune-Your-Hard-Disk-with-hdparm)
Install and configure hd-idle
If your hard drive does not support hdparm, or if you just want to try hd-idle, you can delete hdparm
Sudo apt-get remove hdparm-y
Hd-idle uses a special system file to detect disk activity, without which hd-idle cannot be used. Input
Cat / proc/diskstats
You should see the following output, and if prompted that a file or directory cannot be found, hd-idle is not supported.
8 16 sdb 5604 130363 146538 16780 1814 51838 429152 763380 0 18230 780150
8 17 sdb1 5075 130363 139418 15370 80 8 10 0 8680 15370
8 18 sdb2 512 0 6984 1290 1805 51838 429144 763360 0 9770 764650
Self-compilation of hd-idle
Sudo apt-get install build-essential fakeroot debhelper-y
Get the source code
Wget http://sourceforge.net/projects/hd-idle/files/hd-idle-1.05.tgz
Unzip it into the directory
Tar-xvf hd-idle-1.05.tgz & & cd hd-idle
Compilation and installation
Dpkg-buildpackage-rfakeroot
Sudo dpkg-I.. / hd-idle_*.deb
Continue to check if the hard drive supports hd-idle
Sudo hd-idle-I 0-a sda-I 300-d
You should see output like this
Probing sda: reads: 13418, writes: 594344
Probing sdb: reads: 146538, writes: 429152
Press Ctrl+C to stop hd-idle
Edit configuration file
Sudo vim / etc/default/hd-idle
Change the following to enable hd-idle
START_HD_IDLE=true
Adjust idle time to 10 minutes (60 seconds * 10)
HD_IDLE_OPTS= "- a sda-I 600-l / var/log/hd-idle.log"
Restart the service
Sudo service hd-idle restart
If hd-idle doesn't support it, you can try sdparm.
Install and configure sdparm
Delete hdparm and hd-idle first
Sudo apt-get remove hdparm-y
Sudo dpkg-r hd-idle
Install sdparm
Sudo apt-get install sdparm-y
Test whether sdparm is supported, stop all hard disk operations, enter
Sydo sdparm-flexible-command=stop / dev/sdb
You should see the following output
/ dev/sdb: SANHO IUSBPORT 0
If you need to hibernate the hard drive every 10 minutes, you can use the following crontab command
Sudo crontab-l | {cat; echo "/ 10 * sdparm-- command=stop / dev/sda";} | sudo crontab-
After the above twists and turns, you can finally rest assured that you don't have to worry about the hard drive turning 24 hours a day.
The above is how to carry out orangepi linux hard disk automatic hibernation, the editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.