~> fidks /dev/sda Welcome to fdisk (util-linux 2.23.2).
Changes will remain in memory only, until you decide to write them. Be careful before using the write command.
Command (m for help): p
Disk /dev/sda: 103.1 GB, 103079215104 bytes, 201326592 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos Disk identifier: 0x000a8e23
Device Boot Start End Blocks Id System /dev/sda1 * 2048 2099199 1048576 83 Linux /dev/sda2 2099200 50331647 24116224 8e Linux LVM
Command (m for help): d Partition number (1,2, default 2): 2 Partition 2 is deleted
Command (m for help): n Partition type: p primary (1 primary, 0 extended, 3 free) e extended Select (default p): Using default response p Partition number (2-4, default 2): First sector (2099200-201326591, default 2099200): Using default value 2099200 Last sector, +sectors or +size{K,M,G} (2099200-201326591, default 201326591): Using default value 201326591 Partition 2 of type Linux and of size 95 GiB is set
Command (m for help): w 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 at the next reboot or after you run partprobe(8) or kpartx(8) Syncing disks.
~> partprobe
现在就可以看到 /dev/sda2 的大小已经变化了:
1 2 3 4 5 6 7 8
~> lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0096G 0 disk ├─sda1 8:101G 0 part /boot └─sda2 8:2095G 0 part ├─centos-root 253:0020.6G 0 lvm / └─centos-swap 253:102.4G 0 lvm [SWAP] sr0 11:01906M 0 rom
~> vgdisplay --- Volume group --- VG Name centos System ID Format lvm2 Metadata Areas 1 Metadata Sequence No 4 VG Access read/write VG Status resizable MAX LV 0 Cur LV 2 Open LV 2 Max PV 0 Cur PV 1 Act PV 1 VG Size <95.00 GiB PE Size 4.00 MiB Total PE 24319 Alloc PE / Size 5887 / <23.00 GiB Free PE / Size 18432 / 72.00 GiB VG UUID TpbtuH-AjTZ-PU3v-UN31-FvfX-kSLv-xLiJG7