A good helper for LVM hard disk management in Unix systems (1)

Source: Internet
Author: User

What is the biggest headache for us when deploying Unix OS to plan partitions? I am afraid that the disk space is allocated. For example, at the beginning, only a few colleagues may need to use this unix computer. Therefore, only a small amount of space is planned for the home directory. However, as the number of users increases, the space in the home directory is gradually exhausted. What should I do now? If the LVM mechanism is not used to manage the hard disk space, even if there is still space in the hard disk, the System Engineers cannot immediately merge the remaining space with the home directory currently used. Instead, you need to first copy the current data in the Home directory to another space, then merge the current directory with the remaining space on the hard disk, and format it into an available file system. Finally, copy the data to the new Home directory. It can be seen that similar operations are troublesome and can easily cause damage to the original data.

It is simpler to increase the capacity of swap partitions. You can format the available space in the existing hard disk into a Swap file system and mount it to the existing swap space. However, although the previously attached swap space does not need to be formatted, the execution efficiency of the subsequently added swap space is not as good as that of the original swap partition. To this end, the method of planting to increase the Swap space is also a last resort.

Is there any other solution in the Unix operating system? In order to allow Unix operating systems to manage hard disk space more flexibly, experts have proposed LVM (logical volume manager) solutions. With this solution, System Engineers can conveniently expand the size of the original partition without formatting the original partition. For example, you can reduce the size of a partition and save the space to other required partitions. As shown in, LVM can help the system administrator solve the following problems:

1. Adjust the Unix directory size at will.

For example, due to the increase in the number of users, the/home directory space cannot meet the current needs. For this reason, System Engineers need to allocate the space not in the hard disk to the/home directory. If logical volume management is used, the size of the original/home directory can be expanded without formatting the original/home directory partition. Suppose we still have 20 GB of space in Hard Disk 1. Now the system engineer needs to allocate 10 Gb of capacity to the/home directory. Without re-formatting the original/home directory partition, you only need to use two simple commands to complete this function.

The first command is lvextend.

This command is mainly used to expand the size of the logical volume. As shown in, if you use LVM management, you can create one or more hard disks as logical volume groups. Each partition in the Unix system is the extended logical volume under the logical volume group. To expand the space of the/home directory, System Engineers only need to increase the size of the extended logical volume in the partition where the home directory is located. To achieve this, you only need to use the lvextend command. For example, lvextend-L + 10240/home. When using this command, you need to pay attention to a problem, that is, the units used are M rather than G. Therefore, if you need to increase the space by 10 Gb, you need to use 10240. This is mainly because the traditional partition commands are all in M units. Therefore, M is still used in the design of this solution. This is more or less troublesome for System Engineers to maintain hard disks. When using this command, pay attention to this detail.

Second command: resize_reiserfs

At this time, the system engineer can use the lvdisplay command to view the size of the extended logical volume group in the home directory, and find that the capacity has indeed increased. However, if you use the df command to view the size of the home partition, you will find that it is still the original space and has not changed. This is mainly because the newly created space cannot be used directly. This is mainly because the newly created space file system is not compatible with the original format of the Home directory. To use the newly added space, System Engineers also need to use the resize_reiserfs command to format the newly added space so that the home directory can use the newly added space.

Note: You can use the preceding two commands to expand the partition size of the Home directory. During this process, I did not back up the files in the original home directory, nor re-formatted the partitions in the Home directory. That is to say, the HOME directory partition can be managed as an extended logical volume, and its space can be dynamically adjusted. That is, you can adjust the partition dynamically without formatting the original partition. But for the sake of system file security, if the system engineer uses this management method for the first time, it is better to back up the original file first. To avoid accidental file damage due to misoperations.

Ii. Restrictions on LVM usage.

Although LVM provides a shortcut to hard disk management. However, there are still some restrictions on use during use. For example, when deploying an LVM solution in a Unix operating system, pay attention to the deployment of the/boot partition. If the/boot partition is deployed on the logical volume manager, the Unix operating system cannot be started normally. This is mainly because some files need to be read when the operating system starts. However, none of the boot management programs used by the Unix operating system can read the file system in the logical volume. Therefore, if you deploy the/boot directory that stores the startup information of the operating system in the logical volume, the Unix operating system cannot be started normally. As shown in, I did not deploy the/boot partition in the logical volume when deploying the hard disk partition. Instead, the disk is divided into independent areas for/boot partitioning. Fortunately, this partition is often used to store some necessary information when the system is started, so it requires less space. Therefore, when adopting the LVM solution, System Engineers should deploy/boot partitions in independent partitions. That is, you can divide an independent partition on the hard disk for/boot.


Related Article

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.