Expand Disk Space
20G of hard disk space, increased disk size using vsphere client, additional 10G space required;
650) this.width=650; "title=" "alt=" fdisk_l-20g "class=" Alignnone wp-image-13918 "src=" Http://www.linuxprobe.com/wp-content/uploads/2016/05/fdisk_l-20G.png "width=" 650 "height=" 308 "style=" padding:0px;margin:10px Auto;vertical-align:middle;border:none;height:auto;/>650) this.width=650; " Title= "" alt= "Vshere_add" class= "Alignnone wp-image-13922" src= "http://www.linuxprobe.com/wp-content/uploads/2016/ 05/vshere_add.png "width=" 650 "height=" 727 "style=" padding:0px;margin:10px auto;vertical-align:middle;border:none; Height:auto; "/>
After the expansion, restart the system, again using Fdisk-l view, you will find that the hard disk space becomes larger;
[[email protected] ~]# 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 1301 1497 1572864 82 Linux swap / Solaris/dev/sda4 1497 2611 8952832 83 Linux[[email protected] ~]# df -hTFilesystem type size used avail use% mounted on/dev/ sda2 ext4 9.7g 1.5g 7.7g 16% /tmpfs tmpfs 939m 0 939M 0% /dev/shm/dev/sda1 ext4 194M 34M 151M 19% /boot/dev/sda4 ext4 8.5g 148m 7.9g 2% /data
650) this.width=650; "title=" "alt=" fdisk_l-30 "class=" Alignnone wp-image-13919 "src=" http://www.linuxprobe.com/ Wp-content/uploads/2016/05/fdisk_l-30.png "width=" 650 "height=" 308 "style=" padding:0px;margin:10px auto; Vertical-align:middle;border:none;height:auto; "/>
Re-create partition, adjust partition information
This experiment is mainly to/dev/sda4 this partition extension, if it is a production environment, please save the backup to other partitions in advance, Although the extended partition size does not result in data loss, for security reasons, please do backup in advance;
First, some data is simulated:
[[email protected] data]# mkdir test[[email protected] data]# echo " We are linuxer " > linuxprobe[[email protected] data]# lltotal 24- Rw-r--r--. 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[[email protected] ~]# umount /dev/sda4 # Unmount the disk partition
If the disk is busy, use Fuser to locate the program that will be using the disk and end it;
Fuser-m-v/datafuser-m-v-i-k/data
[[email protected] ~]# 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 #查看分区表信息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 1301 1497 1572864 82 Linux swap / Solaris/dev/sda4 1497 2611 8952832 83 linuxcommand (M FOR HELP): d #删除分区Partition number (1-4): 4 #删除第四个Command (m for help): p #再次查看分区信息,/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 1301 1497 1572864 82 linux swap / SolarisCommand (m for help): n # Create a new partition Command actioN e extended p primary partition (1-4) p #创建为主分区Selected partition 4First cylinder (1497-3916, default 1497): #经对比, exactly the same as the previous disk column, by default using default value 1497last cylinder, +cylinders or +size{k,m,g} (1497-3916, default 3916): Using default value 3916 #直接默认就可以Command (M FOR HELP): p #查看分区表信息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 1301 1497 1572864 82 linux swap / solaris/ dev/sda4 1497 3916 19436582 83 LinuxCommand (m for help): wp #保存并退出, if the creation is wrong, exit directly do not save 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.
650) this.width=650; "title=" "alt=" fdisk-d "class=" Alignnone wp-image-13920 "src=" http://www.linuxprobe.com/ Wp-content/uploads/2016/05/fdisk-d.png "width=" 650 "height=" 495 "style=" padding:0px;margin:10px auto; Vertical-align:middle;border:none;height:auto; "/>650" this.width=650; "title=" "alt=" Fdisk-p "class=" Alignnone wp-image-13921 "src=" Http://www.linuxprobe.com/wp-content/uploads/2016/05/fdisk-p.png "width=" 650 "height=" 455 " style= "padding:0px;margin:10px auto;vertical-align:middle;border:none;height:auto;"/>
[[Email protected] ~]# init 6[[email protected] ~]# e2fsck-f/dev/sda4 #检查分区信息 [[email protected] ~]# Resiz E2fs-p/dev/sda4 #调整分区大小
Re-mount, view partition size, data
[[email protected] ~]# mount /dev/sda4 /data[[email protected] ~]# df -ht[[email protected] ~]# cat /data/linuxprobewe are linuxer
650) this.width=650; "title=" "alt=" df-ht_19g "class=" Alignnone wp-image-13916 "src=" http://www.linuxprobe.com/ Wp-content/uploads/2016/05/df-ht_19g.png "width=" 650 "height=" 228 "style=" padding:0px;margin:10px auto; Vertical-align:middle;border:none;height:auto; "/>
This article is from the "Shunsheng" blog, make sure to keep this source http://shunsheng.blog.51cto.com/11516694/1783827
Using FDISK to expand partition capacity under Linux CentOS