In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-12 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Today, the editor will share with you the relevant knowledge points about how to resize the linux file system. The content is detailed and the logic is clear. I believe most people still know too much about this knowledge, so share this article for your reference. I hope you can get something after reading this article.
(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) obtaining 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:
The copy code is as follows:
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, 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 in the case of runlevel=1.
The copy code is as follows:
# umount/dev/
2. Check file system consistency
The copy code is as follows:
# fsck-n/dev/
3. If it is an ext3 system, delete the log.
The copy code is as follows:
# tune2fs- o ^ has _ journal/dev/
Note: after taking out the log, the ext3 system cannot be mounted. Use the
# tune2fs-j/dev/ rebuilds log.
4. Resize the file system
The copy code is as follows:
# resize_reiserfs-s1000m/dev/hda7
After you have resized the file system, use the following command to conduct a comprehensive check of the file system:
The copy code is as follows:
# reiserfsck--check--fix-fixable/dev/hda7
5. Enter fdisk and resize the partition
The copy code is as follows:
# 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):
The copy code is as follows:
# umount/home/
# resize_reiserfs/dev/hda6
In this way, / usr/local is resized to 1g, leaving 4g of free disk space.
These are all the contents of the article "how to resize the linux file system". Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.
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.