In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
It is believed that many inexperienced people have no idea about how to use fdisk to expand partition capacity in centos. Therefore, this paper summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.
Expand disk space
The hard disk space is 20g. If you use vSphere Client to increase the disk size, you need to add another 10G space.
After the expansion, restart the system and use fdisk-l to check again, you will find that the hard disk space has become larger.
[root@linuxprobe] # fdisk-lDisk / dev/sda: 32.2 GB, 32212254720 bytes255 heads, 63 sectors/track 3916 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x0005210c Device Boot Start End Blocks Id System/dev/sda1 * 1 26 204800 83 LinuxPartition 1 does not end on cylinder boundary./dev/sda2 26 1301 10240000 83 Linux/dev/sda3 1497 1572864 82 Linux swap / Solaris/dev/sda4 1497 2611 8952832 83 Linux [root@linuxprobe ~] # df-hTFilesystem Type Size Used Avail Use% Mounted on/dev/sda2 ext4 9.7G 1.5G 7.7G 16% / tmpfs tmpfs 939M 0939m 0% / dev/shm/dev/sda1 ext4 194M 34M 151M 19% / boot/dev/sda4 ext4 8.5G 148m 7.9G 2% / data
Recreate the partition and adjust the partition information
The main purpose of this experiment is to expand the partition / dev/sda4. If it is a production environment, please make a backup and save it to other partitions in advance, although expanding the partition size will not lead to data loss. For security reasons, please make a backup in advance.
First, some data are simulated:
[root@linuxprobe data] # mkdir test [root@linuxprobe data] # echo "we are Linuxer" > linuxprobe [root@linuxprobe data] # lltotal 24Murray Rukyu. 1 root root 15 May 23 21:59 linuxprobedrwx-. 2 root root 16384 May 23 15:07 lost+founddrwxr-xr-x. 2 root root 4096 May 23 21:51 test [root@linuxprobe ~] # umount / dev/sda4 # Unmount disk Partition
If prompted that the disk is busy, use fuser to find out the program that will be using the disk and end it.
Fuser-m-v / datafuser-m-v-I-k / data
Use the fdisk tool to delete the / dev/sda4 partition first, and then create a new partition. Note that the starting column number should be the same as the original (which is a key step to ensure that the data is not lost), and the end column number defaults to enter using all disks.
[root@linuxprobe ~] # fdisk / dev/sdaWARNING: DOS-compatible mode is deprecated. It's strongly recommended to switch off the mode (command 'c') and change display units to sectors (command 'u') .Command (m for help): P # View partition table information Disk / dev/sda: 32.2 GB, 32212254720 bytes255 heads, 63 sectors/track 3916 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x0005210c Device Boot Start End Blocks Id System/dev/sda1 * 1 26 204800 83 LinuxPartition 1 does not end on cylinder boundary./dev/sda2 26 1301 10240000 83 Linux/dev/sda3 1497 1572864 82 Linux swap / Solaris/dev/sda4 1497 2611 8952832 83 LinuxCommand (m for help): d # delete partition Partition number (1-4): 4 # delete the fourth Command (m for help): P # view partition information again / dev/sda4 has been deleted Disk / dev/sda: 32.2 GB, 32212254720 bytes255 heads, 63 sectors/track 3916 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x0005210c Device Boot Start End Blocks Id System/dev/sda1 * 1 26 204800 83 LinuxPartition 1 does not end on cylinder boundary./dev/sda2 26 1301 10240000 83 Linux/dev/sda3 1497 1572864 82 Linux swap / SolarisCommand (m for help): n # create new partition Command action e extended p primary partition (1-4) p # create primary partition Selected partition 4First cylinder (1497-3916) Default 1497): # by comparison It is exactly the same as the previous disk pillar. By default, Using default value 1497Last cylinder, + cylinders or + size {K MagneM default G} (1497-3916, default 3916): Using default value 3916 # directly defaults to Command (m for help): P # to view partition table information Disk / dev/sda: 32.2 GB, 32212254720 bytes255 heads, 63 sectors/track 3916 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x0005210c Device Boot Start End Blocks Id System/dev/sda1 * 1 26 204800 83 LinuxPartition 1 does not end on cylinder boundary./dev/sda2 26 1301 10240000 83 Linux/dev/sda3 1497 1572864 82 Linux swap / Solaris/dev/sda4 1497 3916 19436582 83 LinuxCommand (m for help): wp # Save and exit If the creation is incorrect, The partition table has been altered calling ioctl () to re-read partition table.WARNING: Re-reading the partition table failed with error 16: Device or resource busy.The kernel still uses the old table. The new table will be used atthe next reboot or after you run partprobe (8) or kpartx (8) Syncing disks.
After recreating the partition, you need to restart it.
[root@linuxprobe ~] # init 6 [root@linuxprobe ~] # e2fsck-f / dev/sda4 # check the partition information [root@linuxprobe ~] # resize2fs-p / dev/sda4 # resize the partition
Remount, view partition size, data
[root@linuxprobe ~] # mount / dev/sda4 / data [root@linuxprobe ~] # df-hT [root@linuxprobe ~] # cat / data/linuxprobewe are Linuxer
After reading the above, have you mastered how to use fdisk to expand partition capacity in centos? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!
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.