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 -lDisk /dev/sda: 64.4 GB, 64424509440 bytes, 125829120 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk label type: dosDisk 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 LinuxDisk /dev/sdb: 214.7 GB, 214748364800 bytes, 419430400 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk label type: dosDisk 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 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytes
[root@db210_12:15:04 /backup] #fdisk /dev/sdcWelcome 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 tableBuilding a new DOS disklabel with disk identifier 0xb4f30c82.Command (m for help): nPartition type: p primary (0 primary, 0 extended, 4 free) e extendedSelect (default p): pPartition number (1-4, default 1):First sector (2048-1048575999, default 2048):Using default value 2048Last sector, +sectors or +size{K,M,G} (2048-1048575999, default 1048575999):Using default value 1048575999Partition 1 of type Linux and of size 500 GiB is setCommand (m for help): wThe partition table has been altered!Calling ioctl() to re-read partition table.Syncing disks.
[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/lvol0meta-data=/dev/MySQL/lvol0 isize=256 agcount=4, agsize=32702464 blks = sectsz=512 attr=2, projid32bit=1 = crc=0 finobt=0data = bsize=4096 blocks=130809856, imaxpct=25 = sunit=0 swidth=0 blksnaming =version 2 bsize=4096 ascii-ci=0 ftype=0log =internal log bsize=4096 blocks=63872, version=2 = sectsz=512 sunit=0 blks, lazy-count=1realtime =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/
#df -hFilesystem Size Used Avail Use% Mounted on/dev/sda3 39G 12G 28G 30% /devtmpfs 3.9G 0 3.9G 0% /devtmpfs 3.9G 0 3.9G 0% /dev/shmtmpfs 3.9G 8.6M 3.9G 1% /runtmpfs 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% /boottmpfs 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 0UUID=202e21ef-c8f9-44b2-8fd0-e9dee6be5df8 /boot xfs defaults 0 0UUID=f249e917-5db3-40e4-8738-c7c17077e8d5 /home xfs defaults 0 0UUID=738f0097-2ef4-42b3-8782-f96fc3eaa95d swap swap defaults 0 0/dev/mapper/MySQL-lvol0 /data xfs defaults 0 0