Centos_Lvm_Create pv vg lv and mount
阿新 • • 發佈:2018-07-31
def call ces attr lvm2 data val cto calling
re-scan new disks without restarting CentOS
- re-scan new disks(/dev/sdc):
#ls /sys/class/scsi_host/ host0 host1 host2 [root@db210_13:56:14 /data] #echo "- - -" > /sys/class/scsi_host/host0/scan [root@db210_13:57:57 /data] #echo "- - -" > /sys/class/scsi_host/host1/scan [root@db210_13:57:57 /data] #echo "- - -" > /sys/class/scsi_host/host2/scan [root@db210_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
[root@db210_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
[root@db210_12:15:23 /backup] #pvcreate /dev/sdc1 Physical volume "/dev/sdc1" successfully created. [root@db210_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
[root@db210_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
[root@db210_12:24:39 /backup]
#mount /dev/MySQL/lvol0 /data2
[root@db210_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