Article Title: optimize ubuntu from the beginning. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source. When installing the Linux system, you should consider how to make the linux system get the best performance. Linux is also designed to be well scalable. For example, in a Linux system, we can organize disk partitions as we like. Some friends like one/and one swap, in fact, this is not a very scientific choice. I have summarized some experiences after multiple reinstalls and shared it with my friends. If there is anything wrong, please make criticism.
The first part is to install linux on a computer with only one hard disk.
I mentioned in the preliminary article on Optimization on the forum that linux also has disk fragments. Therefore, to reduce the fragmentation, we should place directories with frequently changed content in separate partitions. An Optimized Partitioning policy can improve the Linux system performance, reduce disk fragments, and improve disk I/O capabilities. From the perspective of convenient data backup, because many backup tools are highly efficient in backing up the entire partition, we should use several main directories in Linux as separate file systems, allocate a zone for each of them.
Here is a brief introduction to several important directories. These directories can be mounted selectively in special partitions of Hard Disk Partitions installed in ubuntu.
Files in the/usr file system that do not change, such as libraries and programs.
/Var file system contains the file that will change.
/Home file system contains the user's home directory, that is, all the actual data on the system.
/Tmp temporary file.
/Usr/local this is the/usr directory provided to general users. It is best to install the software here.
/Srv after some services start, put the required data here.
/Opt some large programs installed here for ease of management.
/Root directory.
My suggestion is that all the above directories are separately partitioned on the hard disk. If you want to ask why, I can give an example.
For example, we can install LumaQQ under/opt. If we need to reinstall the system, we can choose not to format/opt and ~ /. The lumaqq folder is backed up, so when we reinstall the system and mount/opt again, we only need to put the. lumaqq folder in ~ Run the following command to configure java:
| Code: |
| Sudo ln-s/opt/LumaQQ/lumaqq/usr/bin/lumaqq |
You can use lumaqq again, and a series of lumaqq-related settings such as chat records will not disappear, avoiding downloading and installation troubles.
From the perspective of disk fragments,/tmp,/var, And/home are the most active partitions. If we put them directly under the root directory, it will inevitably cause processing trouble, at that time, disk fragments will affect the performance of the entire disk.
Therefore, we recommend that you separately partition and mount all the preceding directories.
It is also a coincidence when partitioning. According to the characteristics of the disk, we know that the more we rely on the external cylinder of the disk, the faster the rotation, and each time we rotate, disk read/write headers can cover a large number of areas, which means that external cylinders can provide better performance. Therefore, when partitioning, we should consider placing partitions with a High Access frequency that has a relatively large impact on system performance on the disk's off-site. The best solution should be:
/Boot-> swap->/home->/var->/tmp->/srv->/opt->/usr/local->/
Of course, there is no need to stick to this rule and make large-scale modifications to the hard disk, which can be adjusted according to the existing partitions.
In addition, do not use all the space after dividing the above partitions. Leave a few empty partitions for backup, for example, the last partition of my hard disk is a backup partition of up to 30 GB, which stores various files I downloaded online and some of my own things. Besides this partition, I also have a 10 Gb partition, which does not store anything, just to sort out disk fragments.
Part 2 install linux on multiple hard disks
Here we mainly adopt RAID.
First of all, the best case is to use hardware RAID, which has the strongest performance, and there is no complicated part. If you have set it on the bios of the motherboard, everything is OK.
When we use software RAID, we 'd better have two or more hard disk partitions of the same size, and the hard disk speed and cache performance should also be the same, in this way, we can get the best performance of software RAID.
The specific method is described here. During installation, two or more partitions of the same size are divided into hard disk partitions, and the file format is RAID. Select the software RAID settings, create the MD device, and then perform a new partition on the created MD device. The principle is the same as that in the first part.
Of course, in reality, it is very likely that our hardware does not provide an environment where we can display RAID. At this time, we still have the last method, that is, the swap partition, we know that virtual memory is very important, so we can separate the swap areas on the two hard disks, and then use the techniques that give them the same priority to enhance system performance.
In the/etc/fstab file, write the row with the swap partition, and write the options part as follows:
In this way, the two swaps can run simultaneously, and the system performance should be improved.
Part 3 optimized the installation of the IDE Hard Disk
Here we will talk about the use of hdparm. Some features of hdparm can be completed by compiling the kernel. jaquar00 on the Forum said this. Of course, I think it is more convenient to use this software, the usage is as follows:
First test:
| Code: |
| Sudo hdparm-tT device (usually/dev/hda. If there are two hard disks, the second one is/dev/hdab) |
And then set:
| Code: |
Sudo hdparm [-icdmXTt] -I this parameter provides some information that is obtained by the system driver to determine the performance of the hard disk. It is not necessarily accurate, but it can provide us with some help. -C: Set the 32-bit access mode. This 32-bit access mode refers to the transmission mode between the hardware and the pc interface, and the video disk is running according to 16-bit -D: Set whether to enable DMA mode-d1 start-d0 close -M: sets the synchronous reading mode for multiple sector. In general, setting this mode can reduce the efficiency of data loss due to disk reading. The value 16/32 is optimized. For details, see MaxMultSect in the information obtained by-I. -X sets the UtraDMA mode. Generally, you can add 64 to the UDMA mode value. However, the current computer performance is generally strong. Please refer to your computer configuration here. 33 MHz DMA mode 0 ~ 2 (X64 ~ X66) 66 MHz DMA mode 3 ~ 4 (X67 ~ X68) 100 MHz DMA mode 5 (X69) If UATA 100 or above is displayed on your hard disk, X69 may be good. -T test the access efficiency of the temporary storage area. -T test the actual access efficiency of the album.
|
After reading the above parameters, I will use an example to illustrate how to set them. On my computer, I did this:
| Code: |
| Sudo hdparm-X69-d1-u1-m16-c3/dev/hda |
Test again. If the effect is improved, run the following command to save the file:
| Code: |
| Sudo hdparm-k1 Device |
Jaquar00 friends on the Forum helped me supplement it
| Code: |
| Lspci-v | grep 'ide' |
This command queries the methods supported by your hard disk, but it is very strange that it cannot be seen on my computer. It is all unknow, but it may be helpful to other friends.
[1] [2] Next page