In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "how to resize Linux disk partitions". In daily operation, I believe many people have doubts about how to resize Linux disk partitions. The editor consulted all kinds of data and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the doubts of "how to resize Linux disk partitions". Next, please follow the editor to study!
In the process of using linux, sometimes some partition space is insufficient and some partition space is excessive because of improper partition when installing the system. For example, when I installed the system, I gave the / usr/local allocator 5G of space, but after a period of use, I found that the / usr/local only used 1G at most. This resizes / usr/local to 1G. Set aside 4 G for other use. This paper summarizes the method of resizing the file system without breaking the fast file system data. The method of "demolishing the east wall and mending the west wall" is adopted here. Of course, if you have unpartitioned free space on your disk, you don't have to reduce the space in a partition.
Preparatory work
(1) backup
First, group the files in the partition you want to change. Manipulation of the disk may result in data loss. It is best to save important data to another partition before starting work.
(2) to obtain relevant information.
1. Run $df to view file system information. Write down the mount point and device file for the partition you want to adjust.
This step is to see which device file in / usr/local corresponds to / dev/. This paper takes / dev/hda7 as an example.
2, run # sudo fdisk / dev/sda. Enter fdisk and press p to view disk partition information. Write down the starting column number and the ending column number of / dev/sda8. Let them be start, end. And write down how many bytes a "Unit" contains.
Note that file system size and disk partition size are not the same: at least they have different units of measurement. In the file system, generally use KB, MB, GB as the unit. In fdisk, however, it is calculated by the "unit" value of the disk, that is, the number of bytes contained in a cylinder. After we run # fdisk / dev/sda, the fdisk displays the following message:
Disk / dev/sda: 163.9 GB, 163928604672 bytes
255 heads, 63 sectors/track, 19929 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
(3) calculate the termination cylinder number
E.g: the original / usr/local size is 5000 MB, the starting cylinder number is 2550, and the ending cylinder number is 3157. So now I'm going to change its size to 1000MB, and I should calculate the termination cylinder number ([3.2] = 4):
Termination cylinder number = 2550 + [(1000 * 1024 * 1024) / 8225280] = 2678
Use fdisk to delete the original partition (data from the previous partition will not be lost!). Then create a new partition, the only difference between the new partition and the old partition is that the partition size is different, which is shown in their different termination column numbers.
Increase partition size: the terminating cylinder number is set to the last cylinder number of free space. Reduce partition size: the termination cylinder number is calculated.
Begin to adjust
Before starting the adjustment, it is best to take a piece of paper to write down the following information about the partition to be adjusted:
Resize before and after resizing. Which directory it is mounted in, corresponding to which device in / dev/. Start and end cylinder.
E.g: before adjustment: 5G, after adjustment: 1G, mount point: / usr/local, corresponding to / dev/hda7. The starting and ending cylinders are 2550 and 3157 respectively.
1, uninstall the partition
It is best to uninstall when runlevel = 1.
# umount / dev/
2. Check file system consistency
# fsck-n / dev/
3. If it is an ext3 system, you need to delete the log.
# tune2fs-O ^ has_journal / dev/
Note: after taking out the log, the ext3 system cannot be mounted. Use the
# tune2fs-j / dev/ rebuild log.
4. Resize the file system
# resize_reiserfs-s 1000m / dev/hda7
After you have resized the file system, use the following command to conduct a comprehensive check of the file system:
# reiserfsck-check-fix-fixable / dev/hda7
5. Enter fdisk and resize the partition.
# fdisk / dev/hda
Since the kernel still uses the old partition table, restart and then proceed to the following steps.
Through the above steps, we have completed the hard disk partition resizing operation, and then come back to the problem of resizing the file system. Because the hard disk partition is planned according to the cylinder, it is difficult for us to adjust the file system size exactly equal to the hard disk partition size in one step in the resize_reiserfs step. So it is common to adjust the hard disk partition to be a little larger than the file system, and then synchronize with the following command (of course, you can ignore the following steps if you don't care about the existence of some space in the hard disk partition):
# umount / home/
# resize_reiserfs / dev/hda6
In this way, / usr/local is resized to 1G, leaving 4G free disk space.
At this point, the study on "how to resize Linux disk partitions" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.