Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the seven practical tips for optimizing the hard disk of Linux system?

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article will explain in detail what are the seven practical tips for optimizing Linux system hard disks. The quality of the article is high, so Xiaobian shares it with you as a reference. I hope you have a certain understanding of relevant knowledge after reading this article.

Disk fragmentation is a common problem in Windows systems, and system performance can be eroded if care is not taken. Linux uses a second extended file system (ext2), which handles file storage in a completely different way. Linux doesn't have the kind of problems found in Windows systems, which leads many people to think disk fragmentation isn't a problem at all. However, this is not true…Disk fragmentation is a common problem in Windows systems, and system performance can be eroded if care is not taken. Linux uses a second extended file system (ext2), which handles file storage in a completely different way. Linux doesn't have the kind of problems found in Windows systems, which leads many people to think disk fragmentation isn't a problem at all. However, this is incorrect.

All file systems tend to fragment over time. Linux file systems reduce fragmentation but do not eliminate it. Since it doesn't come up very often, it might not be a problem at all for a single-user workstation. On busy servers, however, file fragmentation degrades hard drive performance over time, which is only noticeable when data is read from or written to the hard drive. Here are some specific measures to optimize Linux system hard drive performance.

1. Clean the disk

This approach seems simple: clean the disk drive, delete unwanted files, and purge all files that need to be saved but will not be used. If possible, purge redundant directories and reduce the number of subdirectories. These suggestions may seem obvious, but you'd be surprised how much garbage actually accumulates on each disk. Freeing up disk space can help the system work better.

Second, defragment disk

Disk defragmenters on Linux systems are different from those on Windows 98 or Windows NT systems. Windows 98 introduced the FAT 32 file system, although running Windows 98 did not have to convert to the FAT 32 file system. Windows can be configured to use FAT or an enhanced file system called NTFS. All of these file systems handle file storage in essentially the same way.

The Linux*** method of defragmenting a disk is to make a full backup, reformat the partition, and then restore the files from the backup. When files are stored, they are written in contiguous blocks and they are not fragmented. This is a big job and may not be necessary for a program partition like/usr that doesn't change very often, but it can work wonders in the/home partition of a multiuser system. It takes roughly the same amount of time as Windows NT Server disk defragmentation.

If hard drive performance is still unsatisfactory, there are many other steps to consider, but any hardware solution that involves upgrading or buying a new device can be expensive.

Upgrade from IDE to SCSI

If your hard drive is an IDE drive, you can get better overall performance by upgrading to a SCSI drive. Because IDE controllers must access the CPU, CPU and disk intensive operations can become very slow. SCSI controllers do not handle reads and writes through the CPU. When the IDE drive is reading or writing, users may complain about the slowness of the system because CPU cycles are taken up by the IDE drive.

Get faster controllers and disk drives

Standard SCSI controllers can't read or write data faster than standard IDE controllers, but some very fast "UltraWide"SCSI controllers can make a real jump in read and write speeds.

EIDE and UDMA controllers are very fast IDE controllers. The new UDMA controller is capable of approaching the speed of SCSI controllers. The maximum speed of the UDMA controller is burst speed, but the sustained transfer speed is significantly slower. The IDE controller includes UDMA, which is embedded in the drive itself. No need to buy a controller, just buy a drive, it contains the controller, you can get UDMA performance.

One aspect of disk drives that is often overlooked is the speed of the disk itself. The speed of the disk is given in rpm, which represents how many revolutions per minute. The higher the rpm, the faster the disk speed. If you have the budget, most server system vendors offer SCSI disks at 7500rpm or even 10000rpm. Standard SCSI and IDE disks offer speeds of 5400rpm.

4. Use of multiple controllers

IDE and SCSI disks can be linked. IDE chains consist of up to two devices and standard SCSI chains consist of up to seven devices. If there are two or more SCSI disks in the system, they are most likely linked to the same controller. This is sufficient for most operations, especially when the computer is used as a single-user workstation. But if you have a server, you can improve performance by providing a controller for each SCSI drive. Of course, good controllers are expensive.

5. Adjust hard disk parameters

The IDE hard drive performance can be tuned using the hdparm tool, which is designed with UDMA drives in mind. By default, Linux is the safest to use, but setting access to IDE drives is the slowest. Default mode does not take advantage of the fastest performance possible with UDMA.

Using the hdparm tool, you can significantly improve performance by activating the following features:

◆ 32-bit support Default setting is 16-bit;

The default setting for multipart access is a single part transfer per interrupt.

Note: before using hdparm, make sure you have made a complete backup of your system. Using hdparm to change IDE parameters may cause loss of all data on the drive if an error occurs.

Hdparm can provide a lot of information about hard drives. Open a terminal window and enter the following command to get information about *** IDE drives in the system (change the device name to get information about other IDE drives):

hdparm -v /dev/had

The above command displays information obtained from the drive when the system boots, including whether the drive is operating in 16-bit or 32-bit mode (I/O Support) and whether it is multi-part access (Multcount). More detailed information about disk drives can be displayed using the-i parameter.

Hdparm can also test drive transfer rates. Enter the command to test *** IDE drives in the system:

hdparm -Tt /dev/hda

This test measures the speed of drive direct reads and cache reads. The result is an optimized "*** cases" number. To change the driver settings to enable 32-bit transfer, enter the following command:

hdparm -c3 /dev/hda

The-c3 parameter enables 32-bit support, which can be disabled using-c0. - The c1 parameter also activates 32-bit support and uses less memory overhead, but it doesn't work on many drives.

Most new IDE drives support multipart transfers, but Linux defaults to single-part transfers. Note: With this setting on some drives, activating multipart transfers can cause a complete crash of the file system. This problem mostly occurs on older drives. Enter the following command to activate multipart transfer:

hdparm -m16 /dev/hda

- The m16 parameter activates the 16-part transmission. Except for Western Digital's drives, most drives set to 16 or 32 segments are most appropriate. Western Digital's drive buffer is small, and performance drops significantly when set to more than 8 segments. For Western Digital drives, a 4-part setting is most appropriate.

Activating multi-part access reduces CPU load by 30% to 50% while increasing data transfer rates by 50%. Use the-m0 parameter to cancel multipart transfers.

Hdparm also has a number of options to configure the hard drive, which are not detailed here.

VI. Use of software RAID

Redundant arrays of inexpensive RAID drives can also improve disk drive performance and capacity. Linux supports both software RAID and hardware RAID. Software RAID is embedded in the Linux kernel and costs much less than hardware RAID. The only cost of software RAID is to purchase disks in the system, but software RAID does not enhance the performance of hardware RAID. Hardware RAID uses specially designed hardware to control multiple disks of a system. Hardware RAID may be expensive, but the performance improvements obtained match it. The basic idea behind RAID is to combine multiple small, inexpensive disk drives into an array of disk drives that provides the same level of performance as a single large drive in a large computer. A RAID drive array acts like a single drive to a computer, and it can also use parallel processing. Disk reads and writes occur simultaneously on parallel data paths of RAID disk arrays.

IBM sponsored a study at the University of California to arrive at an initial definition of RAID levels. There are now six defined RAID levels, as shown below.

RAID 0: Level 0 is only a stripe. At level 0, data is split into more than one drive, resulting in higher data throughput. This is the fastest and most efficient form of RAID. However, there is no data mirroring at this level, so failure of any disk in the array will cause loss of all data.

RAID 1: Level 1 is full disk mirroring. Create and support two copies of data on separate disks. A Level 1 array reads faster and writes slower than a single drive, but there is no data loss if either drive fails. This is the most expensive RAID level because each disk requires a second disk to do its mirroring. This level provides *** data security.

RAID 2: Level 2 is intended for drives without embedded error detection. Because all SCSI drives support embedded error detection, this level is obsolete and largely useless. Linux does not use this level.

RAID 3: Level 3 is a disk stripe with parity disks. Storing parity information on a separate drive allows recovery from errors on any single drive. Linux does not support this level.

RAID 4: Level 4 is a large stripe with one parity disk. Parity information means that any failed disk data can be recovered. Level 4 arrays have very good read performance and slower write speeds because parity data must be updated each time.

RAID 5: Level 5 is similar to Level 4, but it distributes parity information across multiple drives. This increases disk write speed. It costs the same per megabyte as Level 4, improves high-speed random performance with high levels of data protection, and is the most widely used RAID system.

Software RAID is level 0, which makes multiple hard disks look like one disk, but much faster than any single disk because the drives are accessed in parallel. Software RAID can use IDE or SCSI controllers, or any combination of disks.

VII. Configuring Kernel Parameters

Improving performance by tuning system kernel parameters is sometimes obvious. Be careful if you decide to do this, because kernel changes can optimize the system or cause it to crash.

Note: Do not change kernel parameters on an active system because there is a risk of system crash. Therefore, testing must be done on a system that no one uses. Set up a test machine to test the system and make sure everything works correctly.

Tweak Memory Performance

In Linux, you can Tweak system memory. If you encounter an out-of-memory error or if your system is for networking, you can adjust the memory allocation settings.

Memory is generally allocated at 4 kilobytes per page. Adjusting the Blank Pages setting can result in significant performance improvements. Open a terminal window and enter the following command to view the current settings of the system:

cat /proc/sys/vm/freepages

This will result in three numbers, like this:

128 256 384

These are the Minimum Blank Page, Blank Page Low, and Blank Page High settings. These values are determined at startup. The minimum setting is twice the amount of memory in the system; the low setting is 4 times the amount of memory; the high setting is 6 times the amount of system memory; the free memory cannot be less than the minimum number of blank pages.

If the number of blank pages is lower than the blank page high setting, swap (using disk space allocated to swap files) begins. When the blank page low setting is reached, intensive swapping begins.

Increasing the white space height setting can sometimes improve overall performance. For example, try increasing the height setting to 1MB. You can adjust this setting with the echo command. Using the sample settings, enter this command to increase the white space height setting to 1MB:

echo "128 256 1024" > /proc/sys/vm/freepages

Note: Test this setting while the system is not in use to ensure that system performance is monitored while any adjustments are made.

Seven practical tips on optimizing Linux system hard disk are shared here, I hope the above content can be of some help to everyone, you can learn more knowledge. If you think the article is good, you can share it so that more people can see it.

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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report