Linux硬盘简易初始化(LVM)

在已有Linux系统中,增加了磁盘一块。
以此为模式,对磁盘进行简单的初始化和挂接。
Step 1:

用parted对磁盘进行分区:

[ ~]# parted /dev/sdb

进行分区,开启LVM:

(parted) mklabel gpt
(parted) mkpart primary xfs 0% 100%
(parted) set 1 lvm on
(parted)

扫描一次,让分区立即生效:

[ ~]# partprobe
Step 2:

将添加磁盘进行LVM划分:

[ ~]# pvcreate /dev/sdb1
Physical volume "/dev/sdb1" successfully created.
[ ~]# vgcreate yunvg /dev/sdb1
Volume group "yunvg" successfully created
[ ~]# vgdisplay
[ ~]# lvcreate -L 999.99GB -n YunDisk yunvg
Rounding up size to full physical extent 999.99 GiB
Logical volume "YunDisk" created.

[ Exdisk]# lvcreate -l 100%FREE -n exdisk1 exdisk
Step 3:

格式化磁盘,用XFS格式:

[ ~]# mkfs.xfs /dev/yunvg/YunDisk
meta-data=/dev/yunvg/YunDisk     isize=512    agcount=4, agsize=65535488 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=0, sparse=0
data     =                       bsize=4096   blocks=262141952, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal log           bsize=4096   blocks=127999, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
[ ~]
Step 4:

将磁盘挂接到指定的目录,并设置开机自动挂接:

[ /]# mkdir /Exdisk
[ /]# mount -t xfs /dev/yunvg/YunDisk /Exdisk/
[ /]# df -h
Filesystem                 Size  Used Avail Use% Mounted on
/dev/mapper/cl-root         16G  1.8G   15G  12% /
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/sda2                  235M  119M  117M  51% /boot
tmpfs                      783M     0  783M   0% /run/user/0
/dev/mapper/yunvg-YunDisk 1000G   33M 1000G   1% /Exdisk
[ /]# vim /etc/fstab
[ ~]#

以上为简易快速的挂接新硬盘。