Linux增加LVM分区

Linux增加LVM分区

Posted by BY on May 7, 2019

Linux增加LVM分区

shell> fdisk /dev/sdb                                #### 选择磁盘
Command (m for help): m                              #### 帮助
Command action
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition
   l   list known partition types
   m   print this menu
   n   add a new partition
   o   create a new empty DOS partition table
   p   print the partition table
   q   quit without saving changes
   s   create a new empty Sun disklabel
   t   change a partition's system id
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit
   x   extra functionality (experts only)
Command (m for help): n                               #### 创建新的分区
Command action
   e   extended
   p   primary partition (1-4)
p                                                     #### 创建主分区
Partition number (1-4):1                              #### 分区ID
First cylinder (1-65270, default 1): 
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-65270, default 65270): 
Using default value 65270

Command (m for help):t                                 #### 修改分区类型
Command (m for help):8e                                #### Linux lvm
Command (m for help):w                                 #### 保存修改
shell> pvcreate /dev/sdb1                              #### 创建新的pv卷
shell> pvs                                             #### 查看pv卷
shell> vgcreate VolGroup01 /dev/sdb1                   #### 创建新的vg卷
shell> vgs                                             #### 查看vg卷
##shell> lvcreate -L 50G -n lvmServer    VolGroup01    #### 创建逻辑卷 -L 指定分区大小 -n 指定lvm名称
shell> lvcreate -l 100%VG -n lvmServer VolGroup01      ####分配全部VG卷
shell> mkfs.xfs /dev/VolGroup01/lvmServer              #### 使用mkfs.xfs命令在逻辑卷lvmServer上创建xfs文件系统
#### 修改fstab 开机自动挂载
shell> cat >>/etc/fstab<<-EOF                                   
/dev/VolGroup01/lvmServer                 /data                   xfs     defaults        1 2
EOF
shell>mount -a

END