查看磁盘
parted -l
创建分区
parted /dev/sdb
可以定义使用MBR方式还是GPT方式
(parted) mklabel
msdos则分区是mbr,若该结果的值为gpt则分区是gpt。
New disk label type? msdos
创建两个分区
(parted) mkpart primary 1025mb 2049mb
(parted) mkpart primary 1025mb 2049mb
print 打印下
Number Start End Size Type File system Flags
1 512B 1025MB 1025MB primary lba
2 1025MB 2049MB 1024MB primary lba
设置为lvm,这边set后面的是Number号
(parted) set 1 lvm on
(parted) set 2 lvm on
创建物理卷
[root@localhost myluzh]# pvcreate /dev/sdb1 /dev/sdb2
Devices file /dev/sdb is excluded by filter: device is partitioned.
Physical volume "/dev/sdb1" successfully created.
Physical volume "/dev/sdb2" successfully created.
创建卷组 -s 16m为 指定1个PE的大小 database为创建的卷组名
[root@localhost myluzh]# vgcreate -s 16m database /dev/sdb1 /dev/sdb2
Devices file /dev/sdb is excluded by filter: device is partitioned.
Volume group "database" successfully created
创建逻辑卷 -n就是逻辑卷名称 指定大小有-l与-L两种 -l为指定多少个PE -L为指定多少大小,databes为卷组名字
[root@localhost /]# lvcreate -n mysql -L 512m database
Logical volume "mysql" created.
[root@localhost /]# lvcreate -n web -l 50 database
Logical volume "web" created.
创建文件系统
[root@localhost /]# mkfs.xfs /dev/database/mysql
[root@localhost /]# mkfs.ext4 /dev/database/web
其他查看命令:pvdisplay(查看物理卷) vgdisplay(查看卷组) lvdisplay(查看逻辑卷)
创建挂载点
[root@localhost /]# mkdir /mnt/mysql
[root@localhost /]# mkdir /mnt/web
永久挂载
[root@localhost /]# vim /etc/fstab
写入 /dev/database/mysql /mnt/mysql xfs defaults 0 0
写入 /dev/database/web /mnt/web ext4 defaults 0 0
挂载
[root@localhost /]# mount -a
查看是否挂挂载成功
[root@localhost /]# df -h
/dev/mapper/database-mysql 507M 30M 478M 6% /mnt/mysql
/dev/mapper/database-web 770M 24K 714M 1% /mnt/web
下面是自己画的一张图,勿喷
发表评论