Centos_Lvm_Create pv vg lv and mount

Posted 2woods

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Centos_Lvm_Create pv vg lv and mount相关的知识,希望对你有一定的参考价值。

re-scan new disks without restarting CentOS

  • re-scan new disks(/dev/sdc):
#ls /sys/class/scsi_host/
host0  host1  host2
[[email protected]_13:56:14 /data]  
#echo "- - -" > /sys/class/scsi_host/host0/scan
[[email protected]_13:57:57 /data]  
#echo "- - -" > /sys/class/scsi_host/host1/scan
[[email protected]_13:57:57 /data]  
#echo "- - -" > /sys/class/scsi_host/host2/scan
[[email protected]_13:57:58 /data]  
#fdisk -l

Disk /dev/sda: 64.4 GB, 64424509440 bytes, 125829120 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: 0x00084df7

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     1026047      512000   83  Linux
/dev/sda2         1026048     5222399     2098176   82  Linux swap / Solaris
/dev/sda3         5222400    86259711    40518656   83  Linux
/dev/sda4        86259712   125829119    19784704    5  Extended
/dev/sda5        86261760   125829119    19783680   83  Linux

Disk /dev/sdb: 214.7 GB, 214748364800 bytes, 419430400 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: 0x0e9c0acb

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048   419430399   209714176   83  Linux

**Disk /dev/sdc: 536.9 GB**, 536870912000 bytes, 1048576000 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
  • format disk
[[email protected]_12:15:04 /backup] 
#fdisk /dev/sdc
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 0xb4f30c82.

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-1048575999, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-1048575999, default 1048575999):
Using default value 1048575999
Partition 1 of type Linux and of size 500 GiB is set

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
  • Create PV & VG& LV
[[email protected]_12:15:23 /backup] 
#pvcreate /dev/sdc1
  Physical volume "/dev/sdc1" successfully created.
[[email protected]_12:15:47 /backup] 
#pvs
  PV         VG Fmt  Attr PSize    PFree  
  /dev/sdc1     lvm2 ---  <500.00g <500.00g
#vgcreate mysql /dev/sdc1
  Volume group "MySQL" successfully created
#vgs
  VG    #PV #LV #SN Attr   VSize    VFree  
  MySQL   1   0   0 wz--n- <500.00g <500.00g
#lvcreate -L499G MySQL
  Logical volume "lvol0" created.
  • Format LV and Mount the LV
[[email protected]_12:21:52 /backup] 
#mkfs.xfs /dev/MySQL/lvol0
meta-data=/dev/MySQL/lvol0       isize=256    agcount=4, agsize=32702464 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=0        finobt=0
data     =                       bsize=4096   blocks=130809856, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=0
log      =internal log           bsize=4096   blocks=63872, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0


#mkdir /data2
[[email protected]_12:24:39 /backup] 
#mount /dev/MySQL/lvol0 /data2
[[email protected]_12:25:18 /data] 
#mv * /data2/
  • show the mounted disk .
#df -h
Filesystem               Size  Used Avail Use% Mounted on
/dev/sda3                 39G   12G   28G  30% /
devtmpfs                 3.9G     0  3.9G   0% /dev
tmpfs                    3.9G     0  3.9G   0% /dev/shm
tmpfs                    3.9G  8.6M  3.9G   1% /run
tmpfs                    3.9G     0  3.9G   0% /sys/fs/cgroup
/dev/sda5                 19G   33M   19G   1% /home
/dev/sdb1                200G   33M  200G   1% /data
/dev/sda1                497M  119M  379M  24% /boot
tmpfs                    783M     0  783M   0% /run/user/0
/dev/mapper/MySQL-lvol0  499G   44G  456G   9% /data2
  • To make the mount persistent across reboots
vi /etc/fstab
**********************************************************
# /etc/fstab
# Created by anaconda on Sat Jun 30 21:49:24 2018
#
# Accessible filesystems, by reference, are maintained under ‘/dev/disk‘
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=4e617a1c-dcd5-4891-b649-a096e15371d9 /                       xfs     defaults        0 0
UUID=202e21ef-c8f9-44b2-8fd0-e9dee6be5df8 /boot                   xfs     defaults        0 0
UUID=f249e917-5db3-40e4-8738-c7c17077e8d5 /home                   xfs     defaults        0 0
UUID=738f0097-2ef4-42b3-8782-f96fc3eaa95d swap                    swap    defaults        0 0
/dev/mapper/MySQL-lvol0                   /data                   xfs     defaults        0 0

以上是关于Centos_Lvm_Create pv vg lv and mount的主要内容,如果未能解决你的问题,请参考以下文章

如何在AIX下进行磁盘管理pv vg lv

lvm管理磁盘卷

AIX中PV,VG,LV及FS常用相关命令

linux vg lv pv

PE,VG,PV,LV概念与结构关系

从VG中去除PV unknown device