Logical volume 的创建
[root@xxxx-centos7-template ~]# fdisk -l
Disk /dev/sda: 53.7 GB, 53687091200 bytes, 104857600 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: 0x000a580e
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 411647 204800 83 Linux
/dev/sda2 411648 104857599 52222976 8e Linux LVM
Disk /dev/sdb: 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 /dev/mapper/centos-root: 44.9 GB, 44883247104 bytes, 87662592 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 /dev/mapper/centos-swap: 8589 MB, 8589934592 bytes, 16777216 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
[root@xxxx-centos7-template ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos-root 42G 1.6G 41G 4% /
devtmpfs 3.9G 0 3.9G 0% /dev
tmpfs 3.9G 0 3.9G 0% /dev/shm
tmpfs 3.9G 8.5M 3.9G 1% /run
tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
/dev/sda1 197M 103M 95M 53% /boot
tmpfs 799M 0 799M 0% /run/user/0
[root@xxxx-centos7-template ~]# mkdir /data
[root@xxxx-centos7-template ~]# fdisk /dev/sdb
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.
Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0x3bb4b474.
Command (m for help): n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): p
Partition number (1-4, default 1):
First sector (2048-209715199, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-209715199, default 209715199):
Using default value 209715199
Partition 1 of type Linux and of size 100 GiB is set
Command (m for help): p
Disk /dev/sdb: 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: 0x3bb4b474
Device Boot Start End Blocks Id System
/dev/sdb1 2048 209715199 104856576 83 Linux
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@xxxx-centos7-template ~]# partprobe
Warning: Unable to open /dev/sr0 read-write (Read-only file system). /dev/sr0 has been opened read-only.
[root@xxxxcentos7-template ~]# pvcreate /dev/sdb1
Physical volume "/dev/sdb1" successfully created.
[root@xxxx-centos7-template ~]# 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 49.80 GiB
PE Size 4.00 MiB
Total PE 12749
Alloc PE / Size 12749 / 49.80 GiB
Free PE / Size 0 / 0
VG UUID uYlfgy-kh0D-YE6a-A3Eq-n4RN-t3QF-C7HBLS
[root@xxxx-centos7-template ~]# vgextend centos /dev/sdb1
Volume group "centos" successfully extended
[root@xxxx-centos7-template ~]# pvscan
PV /dev/sda2 VG centos lvm2 [49.80 GiB / 0 free]
PV /dev/sdb1 VG centos lvm2 [<100.00 GiB / <100.00 GiB free]
Total: 2 [<149.80 GiB] / in use: 2 [<149.80 GiB] / in no VG: 0 [0 ]
> * 逻辑卷创建
[root@xxxx-centos7-template ~]# lvdisplay
--- Logical volume ---
LV Path /dev/centos/swap
LV Name swap
VG Name centos
LV UUID vFM0SF-6giK-lWPg-iCTY-usKM-ywpA-bp5zxd
LV Write Access read/write
LV Creation host, time xxxx-centos7-template, 2018-04-20 13:44:01 +0800
LV Status available
open 2
LV Size 8.00 GiB
Current LE 2048
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 mtRvdH-eFlc-3EiS-xQbW-lqfm-y6K5-bAiZrv
LV Write Access read/write
LV Creation host, time xxxx-centos7-template, 2018-04-20 13:44:01 +0800
LV Status available
open 1
LV Size 41.80 GiB
Current LE 10701
Segments 1
Allocation inherit
Read ahead sectors auto
* currently set to 8192
Block device 253:0
[root@xxxx-centos7-template ~]# lvcreate -L 100G -n data centos
Volume group "centos" has insufficient free space (25599 extents): 25600 required.
[root@xxxx-centos7-template ~]# lvdisplay
--- Logical volume ---
LV Path /dev/centos/swap
LV Name swap
VG Name centos
LV UUID vFM0SF-6giK-lWPg-iCTY-usKM-ywpA-bp5zxd
LV Write Access read/write
LV Creation host, time xxxx-centos7-template, 2018-04-20 13:44:01 +0800
LV Status available
# open 2
LV Size 8.00 GiB
Current LE 2048
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 mtRvdH-eFlc-3EiS-xQbW-lqfm-y6K5-bAiZrv
LV Write Access read/write
LV Creation host, time xxxx-centos7-template, 2018-04-20 13:44:01 +0800
LV Status available
open 1
LV Size 41.80 GiB
Current LE 10701
Segments 1
Allocation inherit
Read ahead sectors auto
* currently set to 8192
Block device 253:0
[root@xxxx-centos7-template ~]# lvcreate -L 99G -n data centos
Logical volume "data" created.
[root@xxxx-centos7-template ~]# lvdisplay
--- Logical volume ---
LV Path /dev/centos/swap
LV Name swap
VG Name centos
LV UUID vFM0SF-6giK-lWPg-iCTY-usKM-ywpA-bp5zxd
LV Write Access read/write
LV Creation host, time xxxx-centos7-template, 2018-04-20 13:44:01 +0800
LV Status available
open 2
LV Size 8.00 GiB
Current LE 2048
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 mtRvdH-eFlc-3EiS-xQbW-lqfm-y6K5-bAiZrv
LV Write Access read/write
LV Creation host, time xxxx-centos7-template, 2018-04-20 13:44:01 +0800
LV Status available
open 1
LV Size 41.80 GiB
Current LE 10701
Segments 1
Allocation inherit
Read ahead sectors auto
* currently set to 8192
Block device 253:0
--- Logical volume ---
LV Path /dev/centos/data
LV Name data
VG Name centos
LV UUID Jj7pYx-vlUm-2z9U-UcK0-Wx3m-182t-UeQH25
LV Write Access read/write
LV Creation host, time xxxx-centos7-template, 2019-03-13 20:50:49 +0800
LV Status available
open 0
LV Size 99.00 GiB
Current LE 25344
Segments 1
Allocation inherit
Read ahead sectors auto
* currently set to 8192
Block device 253:2
> * 挂载lvm
[root@xxxx-centos7-template ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos-root 42G 1.6G 41G 4% /
devtmpfs 3.9G 0 3.9G 0% /dev
tmpfs 3.9G 0 3.9G 0% /dev/shm
tmpfs 3.9G 8.5M 3.9G 1% /run
tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
/dev/sda1 197M 103M 95M 53% /boot
tmpfs 799M 0 799M 0% /run/user/0
[root@xxxx-centos7-template ~]# mkfs.ext4 -j /dev/centos/data
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
6488064 inodes, 25952256 blocks
1297612 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2174746624
792 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, 20480000, 23887872
Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
[root@xxxx-centos7-template ~]# vim /etc/fstab
[root@xxxx-centos7-template ~]# cat /etc/fstab
/dev/mapper/centos-root / xfs defaults 0 0
UUID=30d431c7-640e-4431-8850-4a686d553114 /boot xfs defaults 0 0
/dev/mapper/centos-swap swap swap defaults 0 0
/dev/centos/data /data ext4 defaults 0 0
[root@xxxx-centos7-template ~]#
[root@xxxx-centos7-template ~]# mount -a
[root@xxxx-centos7-template ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos-root 42G 1.6G 41G 4% /
devtmpfs 3.9G 0 3.9G 0% /dev
tmpfs 3.9G 0 3.9G 0% /dev/shm
tmpfs 3.9G 8.5M 3.9G 1% /run
tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
/dev/sda1 197M 103M 95M 53% /boot
tmpfs 799M 0 799M 0% /run/user/0
/dev/mapper/centos-data 98G 61M 93G 1% /data
Logical volume 扩容
fdisk -l
fdisk /dev/sdb
partprobe
fdisk -l
lvdisplay
pvcreate /dev/sdb1
vgdisplay
vgextend centos /dev/sdb1
pvscan
lvdisplay
lvextend /dev/centos/data /dev/sdb1
[root@silence ~]# df -T
文件系统 类型 1K-块 已用 可用 已用% 挂载点
/dev/mapper/centos-root xfs 52403200 1913936 50489264 4% /
devtmpfs devtmpfs 1964224 0 1964224 0% /dev
tmpfs tmpfs 1976320 0 1976320 0% /dev/shm
tmpfs tmpfs 1976320 11908 1964412 1% /run
tmpfs tmpfs 1976320 0 1976320 0% /sys/fs/cgroup
/dev/sda1 xfs 1038336 135236 903100 14% /boot
/dev/mapper/centos-home xfs 26324420 32992 26291428 1% /home
tmpfs tmpfs 395268 0 395268 0% /run/user/0
xfs_growfs /dev/centos/data ##当逻辑卷文件系统为xfs使用
resize2fs /dev/centos/data ##当逻辑卷文件系统为ext4使用