在Linux中,逻辑卷管理器(Logical Volume Manager, LVM)是为Linux内核提供逻辑卷管理的设备映射器目标。大多数现代Linux发行版都能够识别lvm,能够将根文件系统放在逻辑卷上。
#查看磁盘
fdisk -l
#创建物理卷
pvcreate /dev/xvdb
#创建卷组
vgcreate VolGroup00 /dev/xvdb
#激活卷组
vgchange -a y VolGroup00
#设置lv大小的时候有两种方法:
#第一种自定义大小>直接设置lv大小510000M
lvcreate -L510000 -n lv_bee VolGroup00
#第二种全部空间设置>先查看vgdisplay
--- Volume group ---
VG Name VolGroup2
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 2
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 1
Open LV 1
Max PV 0
Cur PV 1
Act PV 1
VG Size 500.00 GiB
PE Size 4.00 MiB
Total PE 127999
Alloc PE / Size 127999 / 500.00 GiB
Free PE / Size 0 / 0
VG UUID 4JgmAK-6p2s-6qJM-E9E9-k5c3-fcGA-IS0nSP
#全部创建成lv
lvcreate -l 127999 -n lv_data VolGroup00
#将该设备格式化成ext4文件系统
mkfs -t ext4 /dev/VolGroup00/lv_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
3276800 inodes, 13106176 blocks
655308 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2162163712
400 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
#加入fstab开机自动挂载
vim /etc/fstab
#添加挂载信息
/dev/mapper/VolGroup00-lv_data /data ext4 defaults 0 0
#创建数据目录
mkdir /data
#执行挂载命令
mount -a
#查看挂载情况
df -h
原文:https://www.cnblogs.com/kuzi/p/13661718.html