[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): n Partition type: p primary (2 primary, 0 extended, 2 free) e extended Select (default p): p Partition number (3,4, default 3): 3 First sector (16777216-122879999, default 16777216): Using default value 16777216 Last sector, +sectors or +size{K,M,G} (16777216-122879999, default 122879999): Using default value 122879999 Partition 3 of type Linux and of size 50.6 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.
Disk /dev/sda: 62.9 GB, 62914560000 bytes, 122880000 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: 0x00068d77
Device Boot Start End Blocks Id System /dev/sda1 * 2048 1026047 512000 83 Linux /dev/sda2 1026048 16777215 7875584 8e Linux LVM /dev/sda3 16777216 122879999 53051392 83 Linux
[root@localhost ~]# mkfs.ext4 /dev/sda3 mke2fs 1.42.9 (28-Dec-2013) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 3317760 inodes, 13262848 blocks 663142 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=2162163712 405 block groups 32768 blocks per group, 32768 fragments per group 8192 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000, 7962624, 11239424
Allocating group tables: done Writing inode tables: done Creating journal (32768 blocks): done Writing superblocks and filesystem accounting information: done
创建物理卷
1 2 3 4
[root@localhost ~]# pvcreate /dev/sda3 WARNING: ext4 signature detected on /dev/sda3 at offset 1080. Wipe it? [y/n]: y Wiping ext4 signature on /dev/sda3. Physical volume "/dev/sda3" successfully created
[root@localhost ~]# pvdisplay --- Physical volume --- PV Name /dev/sda2 VG Name centos PV Size 7.51 GiB / not usable 3.00 MiB Allocatable yes PE Size 4.00 MiB Total PE 1922 Free PE 10 Allocated PE 1912 PV UUID v3Ulr1-lAnh-XdSy-4oGg-CQmE-4aWZ-1Zaxx6
"/dev/sda3" is a new physical volume of "50.59 GiB" --- NEW Physical volume --- PV Name /dev/sda3 VG Name PV Size 50.59 GiB Allocatable NO PE Size 0 Total PE 0 Free PE 0 Allocated PE 0 PV UUID UYFro7-8ttA-3eQ9-yZfY-fr3V-d3St-DvM06V
[root@localhost ~]# vgdisplay --- Volume group --- VG Name centos System ID Format lvm2 Metadata Areas 1 Metadata Sequence No 3 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 7.51 GiB PE Size 4.00 MiB Total PE 1922 Alloc PE / Size 1912 / 7.47 GiB Free PE / Size 10 / 40.00 MiB VG UUID oN3432-gfKs-TOYw-n8Jy-fu6j-ZR0i-xg1i6y
目前存在一个7.5G的卷组
扩展卷组
1 2
[root@localhost ~]# vgextend centos /dev/sda3 Volume group "centos" successfully extended
[root@localhost ~]# lvdisplay --- Logical volume --- LV Path /dev/centos/swap LV Name swap VG Name centos LV UUID fy3cy2-d2Pd-eNQ8-DWXO-DaT0-3o6v-Ee2SKq LV Write Access read/write LV Creation host, time localhost.localdomain, 2016-08-26 13:30:06 +0800 LV Status available # open 2 LV Size 820.00 MiB Current LE 205 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 wdrHLD-l66S-jkAF-2fE4-I8NC-liQ9-mEAXKH LV Write Access read/write LV Creation host, time localhost.localdomain, 2016-08-26 13:30:07 +0800 LV Status available # open 1 LV Size 6.67 GiB Current LE 1707 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:0
[root@localhost ~]# resize2fs /dev/mapper/centos-root resize2fs 1.42.9 (28-Dec-2013) resize2fs: Bad magic number in super-block while trying to open /dev/mapper/centos-root Couldn't find valid filesystem superblock.