### 第一行 Disk /dev/sda: 107.4 GB 与实际 df -好现实内容不符,说明增加磁盘成功
[root@localhost ~]# fdisk -l
Disk /dev/sda: 107.4 GB, 107374182400 bytes, 209715200 sectors ---与上面(df -h)不符,说明新增成功 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: 0x0004148c
Device Boot Start End Blocks Id System /dev/sda1 * 2048 1026047 512000 83 Linux /dev/sda2 1026048 41943039 20458496 8e Linux LVM /dev/sda3 41943040 52428799 5242880 8e Linux LVM
[root@localhost ~]# fdisk /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): m ---------#帮助命令 Command action a toggle a bootable flag b edit bsd disklabel c toggle the dos compatibility flag d delete a partition g create a new empty GPT partition table G create an IRIX (SGI) partition table l list known partition types m print this menu n add a new partition o create a new empty DOS partition table p print the partition table q quit without saving changes s create a new empty Sun disklabel t change a partition's system id u change display/entry units v verify the partition table w write table to disk and exit x extra functionality (experts only)
Command (m for help): n -----------#创建新分区 Partition type: p primary (3 primary, 0 extended, 1 free) e extended Select (default e): p -------#选择主分区 Selected partition 4 First sector (52428800-209715199, default 52428800): ---#回车使用默认 Using default value 52428800 Last sector, +sectors or +size{K,M,G} (52428800-209715199, default 209715199): ---#回车使用默认 Using default value 209715199 Partition 4 of type Linux and of size 75 GiB is set
Command (m for help): t --------------#修改分区类型 Partition number (1-4, default 4): ----------#回车使用默认值 Hex code (type L to list all codes): 8e -----#说明: 8e 是lvm磁盘类型 Changed type of partition 'Linux' to 'Linux LVM'
Command (m for help): p ------#打印分区表
Disk /dev/sda: 107.4 GB, 107374182400 bytes, 209715200 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: 0x0004148c
Device Boot Start End Blocks Id System /dev/sda1 * 2048 1026047 512000 83 Linux /dev/sda2 1026048 41943039 20458496 8e Linux LVM /dev/sda3 41943040 52428799 5242880 8e Linux LVM /dev/sda4 52428800 209715199 78643200 8e Linux LVM
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.
Disk /dev/sda: 107.4 GB, 107374182400 bytes, 209715200 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: 0x0004148c
Device Boot Start End Blocks Id System /dev/sda1 * 2048 1026047 512000 83 Linux /dev/sda2 1026048 41943039 20458496 8e Linux LVM /dev/sda3 41943040 52428799 5242880 8e Linux LVM /dev/sda4 52428800 209715199 78643200 8e Linux LVM ----#这里多出一块,说明保存成功
[root@localhost ~]# pvdisplay --- Physical volume --- PV Name /dev/sda2 VG Name centos PV Size 19.51 GiB / not usable 3.00 MiB Allocatable yes (but full) PE Size 4.00 MiB Total PE 4994 Free PE 0 Allocated PE 4994 PV UUID 7q1DBZ-n5ZX-1OPX-IN9w-SdAp-qekM-BfpVbc --- Physical volume --- PV Name /dev/sda3 VG Name centos PV Size 5.00 GiB / not usable 4.00 MiB Allocatable yes PE Size 4.00 MiB Total PE 1279 Free PE 10 Allocated PE 1269 PV UUID eOLd2K-aXSx-cA1M-hwJc-zqdq-7U4Y-ZE8d2R "/dev/sda4" is a new physical volume of "75.00 GiB" ----------#可以看到新增的75G --- NEW Physical volume --- PV Name /dev/sda4 VG Name PV Size 75.00 GiB Allocatable NO PE Size 0 Total PE 0 Free PE 0 --------#现在这里看到的是0,在 lvextend 的时候还要重新查看 Allocated PE 0 PV UUID wyG3ZO-e1a0-3OHW-6afy-u90w-7Lc8-ddMnJL [root@localhost ~]#
[root@localhost ~]# vgdisplay --- Volume group --- VG Name centos --------------#这个名字在下面会用到 System ID Format lvm2 Metadata Areas 2 Metadata Sequence No 5 VG Access read/write VG Status resizable MAX LV 0 Cur LV 2 Open LV 2 Max PV 0 Cur PV 2 Act PV 2 VG Size 24.50 GiB PE Size 4.00 MiB Total PE 6273 Alloc PE / Size 6263 / 24.46 GiB Free PE / Size 10 / 40.00 MiB VG UUID q6Omkk-sEkn-Ex9Y-gfSY-0URm-4z2E-0u9Euj [root@localhost ~]#
[root@localhost ~]# lvdisplay --- Logical volume --- LV Path /dev/centos/swap LV Name swap VG Name centos LV UUID d39rhF-bGNs-fWPE-ItwX-FNQe-QJ4h-taAm94 LV Write Access read/write LV Creation host, time localhost, 2019-05-09 03:42:09 -0400 LV Status available # open 2 LV Size 2.00 GiB Current LE 512 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:1 --- Logical volume --- LV Path /dev/centos/root LV Name root VG Name centos LV UUID rvepaR-xSYs-hPOy-vPWA-Oiuh-A0Je-j29Gk1 LV Write Access read/write LV Creation host, time localhost, 2019-05-09 03:42:10 -0400 LV Status available # open 1 LV Size 22.46 GiB Current LE 5751 Segments 2 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:0 [root@localhost ~]#