Improve hard disk read and write speed under Linux __linux

Source: Internet
Author: User
Tags ide hard drive

Linux command: Hdparm

Function Description: Display and set the parameters of the hard disk.
Syntax: hdparm [-cfghiiqttvyyz][-a < cache >][-a <0 or 1>][-c][-d <0 or 1>][-k <0 or 1>][-k <0 or 1>][-m & lt; partition number >][-n <0 or 1>][-p][-p < partition number >][-r <0 or 1>][-s < time >][-u <0 or 1>][-w <0 or 1>][-x < transmission mode >][equipment]
Supplemental Note: Hdparm can detect, display and set parameters for IDE or SCSI hard drives.
Parameters
-a< Cache partition > Set the number of blocks that are stored in advance, and if you do not add the < cache partition > option, the current setting is displayed.
-a<0 or 1> to start or turn off the cache when reading files.
-C Sets the IDE32 bit I/O mode.
-C detects the power management mode of the IDE hard disk.
-d<0 or 1> to set the DMA mode for the disk.
-F writes the data of the memory buffer to the hard disk and knows the buffer.
-G shows the magnetic track, head, magnetic area and other parameters of the hard disk.
-h displays Help.
-I displays hardware specification information for the hard drive, which is provided by the hard disk itself at boot time.
-I directly read the hardware specification information provided by the hard disk.
When-k<0 or 1> reset the hard drive, keep the-DMU parameter set.
When-k<0 or 1> reset the hard drive, keep the-APSWXZ parameter set.
-m< number > Set the number of partitions accessed by the hard disk multiple partitions.
-n<0 or 1> ignores errors that occur when the hard disk is written.
-P Sets the hard drive's PIO mode.
-p< number of zones > set the number of partitions within the hard drive cache.
-Q does not display any information on the screen when a subsequent parameter is executed.
-r<0 or 1> set the read/write mode of the hard disk.
-s< time > Set the wait time before the hard drive enters power-saving mode.
-T evaluates the drive's read efficiency.
-T-Pinggu read efficiency for fast drive fetches.
-u<0 or 1> allow other interrupt requests to be executed simultaneously when hard disk access.
-V displays related settings for the hard drive.
-w<0 or 1> sets the write cache for the hard drive.
-x< Transfer Mode > set the transmission mode of the hard drive.
-y enables IDE hard drive into power saving mode.
-y enables IDE hard drive into sleep mode.
-Z turns off the automatic power-saving features of some Seagate hard drives.



32Bit I/O and DMA can also be used under Linux.
1 Use/sbin/hdparm-c1/dev/hda (Hdb,hdc ...) Turn on the 32Bit transfer mode.
[Root@localhost ~]#/sbin/hdparm-c1/dev/hda

/dev/hda:
Setting 32-bit Io_support flag to 1
Io_support = 1 (32-bit)

2 Use command/sbin/hdparm-d1/dev/hda (HDB,HDC ...) Turn on DMA.
[Root@localhost ~]#/sbin/hdparm-d1/dev/hda

/dev/hda:
Setting USING_DMA to 1 (on)
USING_DMA = 1 (ON)


3 finally use/sbin/hdparm-k1/dev/hda to keep the hard drive set after reset.
[Root@localhost ~]#/sbin/hdparm-k1/dev/hda

/dev/hda:
Setting Keep_settings to 1 (on)
Keepsettings = 1 (ON)


In this way, hard drive read and write speed should be improved.


[Root@localhost ~]# hdparm-t/dev/hda

/dev/hda:
Timing buffered disk reads:44 MB in 3.04 seconds = 14.50 Mb/sec


However, the above settings are only valid for the current system and are reset when the system is restarted again.
If you want to turn on DMA every time the system starts, you can add the above command to the/etc/rc.d/rc.local file to implement:

[Root@anima lwg]# echo "/sbin/hdparm-c1-d1-k1/dev/hda" >>/etc/rc.d/rc.local
[Root@anima lwg]#

"Sadie Net-it Technology report" At present many friends have used the large capacity DMA or the UDMA-33 standard hard disk. Under Microsoft's Windows98, the DMA (direct memory access) of the IDE's hard disk can be turned on in the computer's CMOS or operating system to enable DMA or UDMA-33 standard hard drives to improve data transfer rates. However, Linux does not automatically turn on DMA mode on Linux platforms, so the UDMA-33 standard hard drive sensing data transfer in Linux is far from fast in Windows. In fact, the Linux platform can also use software to open DMA mode, the following is the specific way to speed up the hard disk under Linux.

First, before you open DMA mode under Linux, the most important thing is to back up the data on your hard disk. Since DMA mode is turned on, no one can predict whether the hard drive will work properly and whether the data is complete. It is best to back up all the important data under Linux to other hard drives or CD-R and other storage media, please do not back up the data on the same hard drive, and not back up the data to the same hard disk partition.

The second step is to modify some of the device node parameters in the Hdparm directory. However, modifying these parameters must be done as superuser (root) on the Linux system. Ordinary Linux users do not have this privilege to modify the contents of the Hdparm directory. Here is an example of changing the parameters of the hard disk device node, note that different models, different capacity of the hard disk may be listed in the same parameters, but the process and method of modification is generally the same.

#/sbin/hdparm/dev/hda

/dev/hda:

Multcount = 0 (off)

I/O support = 0 (default 16-bit)

UNMASKIRQ = 0 (off)

USING_DMA = 0 (off)

keepsettings = 0 (off)

Nowerr = 0 (off)

readonly = 0 (OFF)

ReadAhead = 8 (ON)

Geometry = 629/240/63, sectors = 9514260, start = 0

#

Note that off means that this parameter does not work, and on indicates that the feature or mode is turned on. The list of parameters above is clearly written, multcount (multiple-sector read) is not open; This hard disk format is 16-bit format; The DMA data transfer mode is not open. Obviously, such parameters do not make the hard drive optimally optimized and do not fully perform the performance of today's high-speed IDE hard drives.

To optimize your hard drive and increase the data transfer rate of your hard drive, you should first understand the implications of these parameters:

C3: The 16-bit format of the hard drive is converted to 32-bit mode.

M16: Changing the Read function of the multi-channel sector of the hard disk,-M16 can make the hard drive read 16 slices of data at a time. But not all hard drives support this feature. Use Hdparm-i/dev/hda to see the maximum number of sectors you can read and write to your hard disk.

D1X34: On a hard drive that supports dma-capable, this parameter can support the data transfer mode of the dual DMA channel.

D1X66: On a hard drive that supports udma-capable, this parameter can support the data transfer mode of the dual DMA channel.

After you understand the role and meaning of the above parameters, please carefully check the label on the hard drive to see if your hard drive supports DMA or UDMA mode, and then optimize your hard drive against these parameters to avoid unforeseen errors.

Optimize the parameters of the hard drive, you can also refer to the following example, note that not all the hard drives are suitable for the optimization parameters, please set the parameters according to the actual situation:

# Hdparm-d1x66-m16-c3/dev/hda

# Hdparm/dev/hda

/dev/hda:

Multcount = (ON)

I/O support = 3 (32-bit w/sync)

UNMASKIRQ = 0 (off)

USING_DMA = 1 (ON)

keepsettings = 0 (off)

Nowerr = 0 (off)

readonly = 0 (OFF)

ReadAhead = 8 (ON)

Geometry = 629/240/63, sectors = 9514260, start = 0

After modifying these parameters, it is sometimes not possible to optimize the hard drive successfully. If you modify this data while the hard drive is still working, the hard drive will go into hibernation. This needs to wait for the hard drive to go off, the hard drive is not in the busy state to optimize the hard drive parameters are easier to succeed.

The hdparm change is a temporary state, and the next time the Linux system starts again hdparm will disappear. If you want to permanently save the modified information, you must write the modified parameters and data to/etc/rc.d/rc.local or/etc/rc.local files, even more than the START process to run early in the program.

Finally, to remind you that if your motherboard's chipset or Linux kernel kernel (such as the kernel kernel version is too old, before version 2.2) if the UDMA mode is not supported, then there is no need to modify the parameters of the hard disk device. Upgrading the motherboard or kernel is a good choice to solve this problem.



Hdparm-tt/dev/hda test hard disk speed
Hdparm-a1/dev/hda open hard drive pre-read feature
Hdparm-c3/dev/hda open hard drive 32-bit
HDPARM-D1/ Dev/hda Turn on DMA
-D and-a parameters most affect IDE hard disk read/write performance

Hdparm-Get/Set hard disk Parameters
Overview
Hdparm [-a [sector]] [-a [0|1]] [-C [chipset mode]] [-c] [-D [0|1]] [-f] [-g] [-i] [k [0|1]] [k [0|1]] [-L [0|1]] [m [Number of sectors]] [-P [0|1|2|3|4|5]] [-p [number of sectors]] [Q] [R [0|1]] [-S [timeout]] [-T] [-T] [-U [0|1]] [-V] [w [0|1]] [-X [transfer mode]] [-y] [-y] [Z] [Device] ...
Description
Hdparm provides a command-line interface for implementing various hard disk control actions that are supported by the built-in Linux ide/st-506 device driver. To implement this functionality requires Linux The core version is 1.2.13 or higher. In the early core, there are some options that may not work correctly. In addition, some options are only supported at the core of the new IDE device drivers, such as the core of the 2.0.10 version or later. If the Hdparm program is using the old core file ( are compiled on a machine that is under the directory Usr/include/linux, these options will not be available.
Options
When a tag is not given,-ACDGKMNRU is assumed to be a value (unless a given device is a SCSI device or an older XT-type Mfm/rll in which case-gr and-ADGR are the default values).
-A
is available for file system advance/ Set the sector area code, which can be used to improve the system performance when reading large files continuously. This is done in advance to read the additional data blocks that are required for the task that is running in anticipation. The default setting in the current core version (2.0.10 version) is 8 sectors (4KB). For most purposes, this value looks good, But in a system where most file-access behavior is random search, setting a smaller value may be better. Of course, many IDE drives also have a standalone built-in read-through feature, which in many cases can mitigate the need for a file system prefetching.
-A
To turn off/turn on IDE drive prefetching (usually by default).
-C
Query/Open (E) IDE

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.