Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use fdisk to expand disk space

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces how to use fdisk to expand disk space related knowledge, the content is detailed and easy to understand, the operation is simple and fast, has a certain reference value, I believe you will have something to gain after reading this article on how to use fdisk to expand disk space, let's take a look at it.

Fdisk is used to manage the linux disk, partition, format and other operations, fdisk command is used to observe the physical use of the hard disk, can also partition the hard disk. It uses a traditional question-and-answer interface rather than an interactive cfdisk interface like DOS fdisk, so it is inconvenient to use, but its functions are not compromised at all.

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 Adjust partition information

This experiment mainly extends 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 cause data loss, for security reasons, please make a backup in advance. First, simulate some data:

[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 on "how to use fdisk to expand disk space" is introduced here, thank you for reading! I believe you all have a certain understanding of "how to use fdisk to expand disk space". If you want to learn more, you are welcome to follow 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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report