Migrate disk to lvm and extend disk
xfs admin and data
- we have /dev/sdc and /dev/sdc1
[root@localhost ~]# lsblk -p
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
/dev/sda 8:0 0 20G 0 disk
├─/dev/sda1 8:1 0 1G 0 part /boot
└─/dev/sda2 8:2 0 19G 0 part
├─/dev/mapper/centos-root 253:0 0 17G 0 lvm /
└─/dev/mapper/centos-swap 253:1 0 2G 0 lvm [SWAP]
/dev/sdb 8:16 0 1G 0 disk
└─/dev/sdb1 8:17 0 1023M 0 part
└─/dev/mapper/data_vg-data_rozpravky 253:2 0 1020M 0 lvm /data
/dev/sdc 8:32 0 2G 0 disk
└─/dev/sdc1 8:33 0 2G 0 part
/dev/sr0 11:0 1 1024M 0 rom
We will mount /dev/sdc1 to /data2
1. check UUID
[root@localhost ~]# blkid | grep -i sdc1
/dev/sdc1: UUID="250212ed-0818-4f5b-a1a4-7f6889cc5184" TYPE="xfs"
2. write UUID to /etc/fstab
[root@localhost ~]# vi /etc/fstab
[root@localhost ~]# cat /etc/fstab | grep -i data2
UUID=250212ed-0818-4f5b-a1a4-7f6889cc5184 /data2 xfs defaults 0 0
[root@localhost ~]#
3. create some data to /data2
[root@localhost ~]# dd if=/dev/zero of=/data2/file.txt bs=1024 count=102400
4. backup data:
[root@localhost ~]# tar czvf /mnt/floppy_secret/backup.tar.gz /data2/
[root@localhost ~]# ls -l /mnt/floppy_secret/
total 100
-rw-r--r--. 1 root root 101909 Apr 22 09:10 backup.tar.gz
[root@localhost ~]#
5. umount /data2, create lvm and use xfs_admin
[root@localhost ~]# umount /data2/
[root@localhost ~]# pvcreate /dev/sdc1
WARNING: xfs signature detected on /dev/sdc1 at offset 0. Wipe it? [y/n]: y
Wiping xfs signature on /dev/sdc1.
Physical volume "/dev/sdc1" successfully created.
[root@localhost ~]# vgcreate flopyy_vg /dev/sdc1
Volume group "flopyy_vg" successfully created
[root@localhost ~]# lvcreate -n floppy_lv -l 100%FREE flopyy_vg
Logical volume "floppy_lv" created.
xfs_admin -U 250212ed-0818-4f5b-a1a4-7f6889cc5184 /dev/mapper/flopyy_vg-floppy_lv
6. restore from backup
tar xfvz /mnt/floppy_secret/backup.tar.gz -C /
[root@localhost ~]# ls -lh /data2/
total 100M
-rw-r--r--. 1 root root 100M Apr 22 09:05 file.txt
[root@localhost ~]#
[root@localhost ~]# df -hT | grep -i data
/dev/mapper/data_vg-data_rozpravky xfs 1017M 33M 985M 4% /data
/dev/mapper/flopyy_vg-floppy_lv xfs 2.0G 133M 1.9G 7% /data2
[root@localhost ~]#
7. add new disk and extend data2 partition:
- adding disk via virtualbox, vmware or adding physical disk to hw
- new disk in linux /dev/sdd
[root@localhost ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 20G 0 disk
├─sda1 8:1 0 1G 0 part /boot
└─sda2 8:2 0 19G 0 part
├─centos-root 253:0 0 17G 0 lvm /
└─centos-swap 253:1 0 2G 0 lvm [SWAP]
sdb 8:16 0 1G 0 disk
└─sdb1 8:17 0 1023M 0 part
└─data_vg-data_rozpravky 253:2 0 1020M 0 lvm /data
sdc 8:32 0 2G 0 disk
└─sdc1 8:33 0 2G 0 part
└─flopyy_vg-floppy_lv 253:3 0 2G 0 lvm /data2
sdd 8:48 0 3G 0 disk
sr0 11:0 1 1024M 0 rom
[root@localhost ~]# vgs
VG #PV #LV #SN Attr VSize VFree
centos 1 2 0 wz--n- <19.00g 0
data_vg 1 1 0 wz--n- 1020.00m 0
flopyy_vg 1 1 0 wz--n- <2.00g 0
[root@localhost ~]# vgextend flopyy_vg /dev/sdd
Physical volume "/dev/sdd" successfully created.
Volume group "flopyy_vg" successfully extended
[root@localhost ~]# lvextend -l +100%FREE -r /dev/mapper/flopyy_vg-floppy_lv
[root@localhost ~]# df -hT | grep -i data
/dev/mapper/data_vg-data_rozpravky xfs 1017M 33M 985M 4% /data
/dev/mapper/flopyy_vg-floppy_lv xfs 5.0G 133M 4.9G 3% /data2
[root@localhost ~]#
---nothing change in /etc/fstab
Žiadne komentáre:
Zverejnenie komentára