Optimizing Linux System Hard Disks to Solve Disk Fragmentation

  
On Windows systems, disk fragmentation is a common problem, and if you do not pay attention, system performance may be eroded. Linux uses the second extended file system (ext2), which handles file storage in a completely different way. Linux does not have the kind of problems found in Windows systems, which makes many people think that disk fragmentation is not a problem at all. However, this is not true. All file systems tend to be fragmented over time. The Linux file system has reduced fragmentation, but it has not been eliminated. Since it does not happen often, it may not be a problem at all for a single-user workstation. However, in a busy server, over time, file fragmentation will degrade hard drive performance, and hard drive performance can only be noticed when reading or writing data from the hard disk. The following are some specific measures to optimize the performance of the Linux system hard disk. First, clean up the disk
This method looks very simple: clean the disk drive, delete the unwanted files, and clear all files that need to be saved but will not be used. If possible, clear the extra directories and reduce the number of subdirectories. These suggestions seem obvious, but you will be surprised to find that there is really a lot of garbage on each disk. Freeing up disk space can help the system work better. Second, defragmenting disk
The disk defragmentation program on Linux systems is different from the disk defragmentation program in Windows 98 or Windows NT systems. Windows 98 introduces the FAT 32 file system, although running Windows 98 does not have to be converted to a FAT 32 file system. Windows can be set to use FAT or an enhanced file system called NTFS. All of these file systems handle file storage in essentially the same way. The best way to defragment your disk in Linux is to do a full backup, reformat the partition, and then restore the files from the backup. When files are stored, they are written to contiguous blocks and they are not fragmented. This is a big job, and may be unnecessary for program partitions that are not changed often like /usr, but it can work wonders on the /home partition of a multi-user system. It takes roughly the same amount of time as the Windows NT server disk defragmentation. If hard drive performance is still unsatisfactory, there are many other steps to consider, but any hardware solution that includes upgrading or purchasing a new device can be expensive. Three, upgrade from IDE to SCSI
If your hard drive is an IDE drive, you can get better overall performance by upgrading to SCSI drive. Because the IDE controller must access the CPU, CPU and disk intensive operations can become very slow. The SCSI controller does not need to be read and written by the CPU. When the IDE drive is reading or writing, the user may complain that the system is slow because the CPU cycle is occupied by the IDE driver. Get Faster Controllers and Disk Drives Standard SCSI controllers can't read and write data faster than standard IDE controllers, but some very fast "UltraWide" SCSI controllers can make a real leap in read and write speeds. //This article from the computer software and hardware application network www.45it.com reproduced please note that EIDE and UDMA controller is very fast IDE controller. The new UDMA controller is able to approach the speed of the SCSI controller. The top speed of the UDMA controller is the burst speed, but the speed of sustained transmission is significantly slower. The IDE controller includes UDMA, which is embedded in the drive itself. There is no need to buy a controller, just buy a drive, it contains the controller, you can get UDMA performance. One aspect that disk drives often overlook is the speed of the disk itself. The speed of the disk is given in rpm, which represents how many times per minute. The larger the rpm, the faster the disk speed. If you have a budget for this, most server system vendors can offer 7500rpm or even 10000rpm SCSI disks. Standard SCSI and IDE disks provide 5400 rpm speed. Fourth, use multiple controllers
IDE and SCSI disks can be linked. The IDE chain includes up to two devices, and the standard SCSI chain includes up to seven devices. If there are two or more SCSI disks in the system, it is likely to be linked to the same controller. This is sufficient for most operations, especially when the computer is treated 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, a good controller is expensive.
V. Adjusting Hard Disk Parameters
The Hdparm tool can be used to adjust the performance of IDE hard disks. It is designed with UDMA drivers in mind. By default, Linux is the safest to use, but setting up access to the IDE drive is the slowest. The default mode does not take advantage of the fastest possible performance of UDMA. Using the Hdparm tool, you can significantly improve performance by activating the following features: ◆ 32-bit support The default setting is 16 bits; ◆ Multi-part access The default setting is one-part transfer per interrupt. Note: Make sure you have a full backup of your system before using Hdparm. Use Hdparm to change the IDE parameters. If an error occurs, it may cause loss of all data on the drive. Hdparm can provide a lot of information about the hard drive. Open a terminal window, enter the following command to get the information of the first IDE drive in the system (change the device name to get information about other IDE drives): hdparm -v /dev/had The above command shows the information obtained from the drive when the system starts. , including whether the drive operates in 16-bit or 32-bit mode (I/O Support), whether it is multi-part access (Multcount). The -i parameter can be used to display more detailed information about the disk drive. Hdparm can also test drive transfer rates. Enter the command to test the first IDE drive in the system: hdparm -Tt /dev/hda This test measures the speed of direct read and cache reads by the drive. The result is an optimized "best case" number. To change the drive settings, activate the 32-bit transfer, enter the following command: hdparm -c3 /dev/hda -c3 The parameter activates 32-bit support, which can be canceled with -c0. The -c1 parameter also activates 32-bit support and uses less memory overhead, but it does not work on many drives. Most new IDE drives support multipart transfers, but Linux defaults to single-part transfers. Note: This setting is on some drives, and activating multipart transfers can cause a complete crash of the file system. Most of this problem occurs on older drives. Enter the following command to activate the multipart transfer: hdparm -m16 /dev/hda The -m16 parameter activates the 16-part transfer. With the exception of Western Digital drives, most drives are best set to 16 or 32. Western Digital's drive buffer is small, and performance will drop significantly when set to greater than 8 parts. For Western Digital drives, setting to 4 is the most appropriate. Activating multipart access can reduce CPU load by 30% to 50% while increasing the data transfer rate to 50%. Multi-part transfer can be canceled with the -m0 parameter. Hdparm also has a number of options for setting up a hard drive, which is not detailed here. VI. Using Software RAID
Redundant arrays of RAID inexpensive drives can also improve disk drive performance and capacity. Linux supports software RAID and hardware RAID. Software RAID is embedded in the Linux kernel and costs far 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 in the system. Hardware RAID can be expensive, but the resulting performance improvements match. The basic idea of ​​RAID is to combine multiple small, inexpensive disk drives into a single disk drive array that provides the same level of performance as a single large drive in a large computer. A RAID drive array is like a single drive for a computer, and it can also use parallel processing. Disk reads and writes are performed simultaneously on the parallel data path of the RAID disk array. IBM initiated a study at the University of California to get an initial definition of the RAID level. There are now six defined RAID levels as shown below. RAID 0: Level 0 is just a data band. In level 0, the 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 the failure of any disk in the array will cause all data to be lost. RAID 1: Level 1 is a full disk image. Create and support two copies of the data on a separate disk. Level 1 arrays are faster and slower to write than a single drive, but if either drive is wrong, there is no data loss. This is the most expensive RAID level because each disk requires a second disk to mirror it. This level provides the best data security. RAID 2: Level 2 is envisioned for drives without embedded error detection. Because all SCSI drives support inline error detection, this level is obsolete and basically useless. Linux does not use this level. RAID 3: Level 3 is a tape strip with parity disks. Storing parity information onto a separate drive allows recovery of errors on any single drive. Linux does not support this level. RAID 4: Level 4 is a large strip with a parity disk. Parity information means that any disk failure data can be recovered. Level 4 arrays have very good read performance and slow write speeds because the 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 the disk write speed. It costs the same amount of megabytes as level 4, improves high-speed random performance under high-level 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
It is sometimes obvious to improve performance by adjusting system kernel parameters. Be careful if you decide to do this, because changes to the system kernel may optimize the system and may cause the system to crash. Note: Do not change the kernel parameters on a system that is in use because of the danger of a system crash. Therefore, testing must be performed on a system that no one uses. Set up a test machine and test the system to make sure everything works. Tweak memory performance
In Linux, you can use Tweak system memory. If you encounter an out of memory error or if the system is for a network, you can adjust the memory allocation settings. Memory is generally allocated in 4 kilobytes per page. Adjusting the "blank page" setting can result in significant performance improvements. Open a terminal window and enter the following command to see the current settings of the system: cat /proc/sys/vm/freepages This will get three numbers, like this: 128 256 384 These are the smallest blank pages, blank pages low and blank pages High setting. 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 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 height setting, the swap (using disk space allocation to the swap file) begins. The intensive exchange begins when the blank page low setting is reached. Increasing the blank page height setting can sometimes improve overall performance. For example, try increasing the high setting to 1MB. You can adjust this setting with the echo command. Using the sample settings, enter this command to increase the blank page height setting to 1MB: echo "128 256 1024" > /proc/sys/vm/freepages Note: Test this setting when the system is not already in use to ensure that any adjustments are made. Monitor system performance. This will determine which setting is best for the system.
Copyright © Windows knowledge All Rights Reserved