Migrate logical volumes
Pvmove / dev/sdd-move PE data to other VG members vgreduce vg0 / dev/sdd Delete VG0 / dev/sddpvremove / dev/sdd Delete PV [root@centos6 ~] # lsblk-View / dev/sdb
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
Loop0 7:0 0 100M 0 loop / mnt/xdisk
Sda 8:0 0 200G 0 disk
├─ sda1 8:1 0 1G 0 part / boot
├─ sda2 8:2 0 97.7G 0 part /
├─ sda3 8:3 0 48.8G 0 part / data
├─ sda4 8:4 0 1K 0 part
└─ sda5 8:5 0 2G 0 part [SWAP]
Sdb 8:16 0 20G 0 disk
Sr0 11:0 1 1024M 0 rom
Loop100 7:100 0 100M 0 loop
[root@centos6 ~] # pvcreate / dev/sdb
Device / dev/sdb not found (or ignored by filtering).
[root@centos6 ~] # pvs
[root@centos6 ~] # dd if=/dev/zero of=/dev/sdb bs=1 count=512-- clear the partition information for / dev/sdb
512'0 records in
512'0 records out
512 bytes (512B) copied, 0.00557043 s, 91.9 kB/s
[root@centos6 ~] #
[root@centos6 ~] # lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
Loop0 7:0 0 100M 0 loop / mnt/xdisk
Sda 8:0 0 200G 0 disk
├─ sda1 8:1 0 1G 0 part / boot
├─ sda2 8:2 0 97.7G 0 part /
├─ sda3 8:3 0 48.8G 0 part / data
├─ sda4 8:4 0 1K 0 part
└─ sda5 8:5 0 2G 0 part [SWAP]
Sdb 8:16 0 20G 0 disk
Sr0 11:0 1 1024M 0 rom
Loop100 7:100 0 100M 0 loop
[root@centos6 ~] # mount
/ dev/sda2 on / type ext4 (rw)
Proc on / proc type proc (rw)
Sysfs on / sys type sysfs (rw)
Devpts on / dev/pts type devpts (rw,gid=5,mode=620)
Tmpfs on / dev/shm type tmpfs (rw)
/ dev/sda1 on / boot type ext4 (rw)
None on / proc/sys/fs/binfmt_misc type binfmt_misc (rw)
/ dev/sda3 on / data type ext4 (rw)
/ mnt/disk on / mnt/xdisk type ext4 (rw,loop=/dev/loop0)
[root@centos6 ~] #
[root@centos6 ~] # blkid-confirm that DEV/sdb does not have partition information
/ dev/sda1: UUID= "15c47a81-93fd-4e76-971e-2383b42b1f8f" TYPE= "ext4"
Dev/sda2: UUID= "70112905-ef35-4144-8a2e-1313c7378581" TYPE= "ext4"
Dev/sda5: UUID= "1311bb6e-4d1f-4cd1-8994-705d8203c6a0" TYPE= "swap"
/ dev/sda3: UUID= "d9896327-7ae0-4fe7-9993-e1b4e14faf6b" TYPE= "ext4"
Dev/loop0: UUID= "5ef7cf1b-23f9-48ec-a3de-3a44a8beb0a3" TYPE= "ext4"
Dev/loop100: UUID= "5ef7cf1b-23f9-48ec-a3de-3a44a8beb0a3" TYPE= "ext4"
[root@centos6 ~] # pvcreate / dev/sdb-create PV
Physical volume "/ dev/sdb" successfully created
[root@centos6 ~] # vgs
[root@centos6 ~] # vgcreate-s 16m vg0 / dev/sdb-create a physical volume vg0
Volume group "vg0" successfully created
[root@centos6 ~] # lvcreate-n mysql-L 2G vg0-- create lv
Logical volume "mysql" created.
[root@centos6 ~] # mkfs.ext4 / dev/vg0/mysql-Partition
Mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
131072 inodes, 524288 blocks
26214 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=536870912
16 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912
Writing inode tables: done
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 36 mounts or
180 days, whichever comes first. Use tune2fs-c or-i to override.
[root@centos6 ~] #
[root@centos6 ~] # mkdir / mnt/mysql-create mount point
[root@centos6 ~] # mount / dev/vg0/mysql / mnt/mysql/--- mount
[root@centos6 ~] # cp / etc/* / mnt/mysql/-copy data
Cp: omitting directory/etc/ abrt'cp: omitting directory/etc/acpi'
Cp: omitting directory/etc/yum'cp: omitting directory/etc/yum.repos.d'
[root@centos6 ~] # ls / mnt/mysql/
Adjtime bashrc drirc gshadow issue.net logrotate.conf my.cnf pm-utils-hd-apm-restore.conf reader.conf smartd.conf warnquota.conf
Aliases cas.conf enscript.cfg gshadow- kde4rc lost+found nanorc pnm2ppa.conf redhat-release sos.conf wgetrc
Aliases.db centos-release environment gssapi_mech.conf kderc lsb-release netconfig
[root@centos6 ~] # umount / mnt/mysql/-uninstall
[root@centos6 ~] #
[root@centos6 ~] #
[root@centos6 ~] #
[root@centos6 ~] # df-confirm
Filesystem 1K-blocks Used Available Use% Mounted on
/ dev/sda2 100660656 4661276 90879380 5% /
Tmpfs 501508 72 501436 / dev/shm
/ dev/sda1 999320 34112 912780 4% / boot
/ dev/sda3 50264772 53048 47651724 1% / data
/ mnt/disk 95054 1550 88384 2% / mnt/xdisk
[root@centos6 ~] # vgrename vg0 vg1-change VG name
Volume group "vg0" successfully renamed to "vg1"
[root@centos6 ~] # vgdisplay--- confirmation
-Volume group
VG Name vg1
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 3
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 1
Open LV 0
Max PV 0
Cur PV 1
Act PV 1
VG Size 19.98 GiB
PE Size 16.00 MiB
Total PE 1279
Alloc PE / Size 128 / 2.00 GiB
Free PE / Size 1151 / 17.98 GiB
VG UUID UBne4H-QpbX-G3jP-Zq12-NUhZ-7iXV-OAPjCZ
[root@centos6 ~] # vgchange-an vg1-disable vg1
0 logical volume (s) in volume group "vg1" now active
[root@centos6 ~] # vgdisplay-confirm
-Volume group
VG Name vg1
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 3
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 1
Open LV 0
Max PV 0
Cur PV 1
Act PV 1
VG Size 19.98 GiB
PE Size 16.00 MiB
Total PE 1279
Alloc PE / Size 128 / 2.00 GiB
Free PE / Size 1151 / 17.98 GiB
VG UUID UBne4H-QpbX-G3jP-Zq12-NUhZ-7iXV-OAPjCZ
[root@centos6 ~] # lvdisplay
-Logical volume
LV Path / dev/vg1/mysql
LV Name mysql
VG Name vg1
LV UUID L9uTCB-aSN6-arMv-eLrA-rAcJ-eKO3-IIuWUX
LV Write Access read/write
LV Creation host, time centos6.localdomain, 2020-03-02 13:47:43 + 0800
LV Status NOT available
LV Size 2.00 GiB
Current LE 128
Segments 1
Allocation inherit
Read ahead sectors auto
[root@centos6 ~] # vgexport vg1-- Export VG1
Volume group "vg1" successfully exported
[root@centos6 ~] # lvdisplay-confirm
Volume group vg1 is exported
[root@centos6 ~] # vgdisplay
-Volume group
VG Name vg1
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 4
VG Access read/write
VG Status exported/resizable
MAX LV 0
Cur LV 1
Open LV 0
Max PV 0
Cur PV 1
Act PV 1
VG Size 19.98 GiB
PE Size 16.00 MiB
Total PE 1279
Alloc PE / Size 128 / 2.00 GiB
Free PE / Size 1151 / 17.98 GiB
VG UUID UBne4H-QpbX-G3jP-Zq12-NUhZ-7iXV-OAPjCZ
[root@bogon ~] $echo'--- > / sys/class/scsi_host/host2/scan-- add centos6's disk to Centos7
[root@bogon ~] $lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
Sda 8:0 0 200G 0 disk
├─ sda1 8:1 0 1G 0 part / mnt/boot
├─ sda2 8:2 0 100G 0 part /
├─ sda3 8:3 0 50G 0 part / data
├─ sda4 8:4 0 1K 0 part
├─ sda5 8:5 0 2G 0 part [SWAP]
├─ sda6 8:6 0 1G 0 part / mnt/sda6
└─ sda7 8:7 0 2G 0 part / mnt/sda7
Sdb 8:16 0 200G 0 disk
├─ sdb1 8:17 0 4G 0 part
│ └─ vg0-mysql 253:0 0 5.9G 0 lvm
└─ sdb2 8:18 0 2G 0 part / home
Sdc 8:32 0 20G 0 disk
Sdd 8:48 0 10G 0 disk
├─ vg0-mysql 253:0 0 5.9G 0 lvm
└─ vg0-binlog 253:1 0 1G 0 lvm / mnt/binlog
Sde 8:64 0 20G 0 disk
Sr0 11:0 1 3.7G 0 rom / mnt/cdrom
Sr1 11:1 1 10G 0 rom
[root@bogon ~] $
Root@bogon ~] $vgdisplay-see the new VG1
-Volume group
VG Name vg0
System ID
Format lvm2
Metadata Areas 3
Metadata Sequence No 22
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 1
Max PV 0
Cur PV 3
Act PV 3
VG Size 33.95 GiB
PE Size 16.00 MiB
Total PE 2173
Alloc PE / Size 442 /