[root@test ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 20G 18G 698M 97% /
/dev/mapper/VG1-backup
49G 197M 46G 1% /backup
/dev/mapper/VG1-downloads
50G 52M 47G 1% /downloads
/dev/mapper/VG1-home 49G 181M 46G 1% /home
tmpfs 979M 0 979M 0% /dev/shm
/dev/mapper/VG1-public
59G 641M 55G 2% /public
[root@test ~]# lvremove /dev/VG1/public
Can't remove open logical volume "public"
[root@test ~]# dmsetup info -c /dev/VG1/public
Name Maj Min Stat Open Targ Event UUID
VG1-public 253 7 L--w 1 2 0 LVM-8FQ0SbqlR7hlFHpG2rnxUQ2WvafgEa1yMvxZcKGIIj6Rippe9VdxO4MptcgKaO1O
Device mapper maintains entry for logical drives, so first we need to delete it from there. Then it can't restrict us while removing logical volumes which are in open status.
rom above table you can see Open = 1 which means the logical volume testlv is open status, so we need to delete entry for this logical volume from dmsetup table then only we can delete any logical volume with open status. let's do it
[root@test /]# dmsetup remove --force /dev/VG1/backup
device-mapper: remove ioctl failed: Device or resource busy
Command failed
[root@test ~]# umount /public/
[root@test ~]# lvremove /dev/VG1/public
Do you really want to remove active logical volume public? [y/n]: y
Logical volume "public" successfully removed
[root@test ~]# lvs
LV VG Attr LSize Origin Snap% Move Log Copy% Convert
backup VG1 -wi-ao 50.00G
downloads VG1 -wi-ao 54.00G
home VG1 -wi-ao 50.00G
images VG1 -wi-a- 50.00G
stripe VG1 -wi-a- 128.00M
[root@test ~]# vgcfgrestore --list VG1
File: /etc/lvm/archive/VG1_00011-1959345004.vg
VG name: VG1
Description: Created *before* executing 'lvremove /dev/VG1/snap1'
Backup Time: Wed Sep 11 20:23:22 2013
File: /etc/lvm/archive/VG1_00012-1817284231.vg
VG name: VG1
Description: Created *before* executing 'lvcreate -s --name backup-snap --size 1G /dev/VG1/backup'
Backup Time: Wed Sep 11 20:48:21 2013
File: /etc/lvm/archive/VG1_00013-1680048821.vg
VG name: VG1
Description: Created *before* executing 'lvremove /dev/VG1/backup-snap'
Backup Time: Mon Sep 16 09:13:22 2013
File: /etc/lvm/archive/VG1_00014-2084989037.vg
VG name: VG1
Description: Created *before* executing 'lvremove /dev/VG1/dbba'
Backup Time: Mon Sep 16 09:13:47 2013
File: /etc/lvm/archive/VG1_00015-1654653445.vg
VG name: VG1
Description: Created *before* executing 'lvremove /dev/VG1/public_snap'
Backup Time: Mon Sep 16 09:14:14 2013
File: /etc/lvm/archive/VG1_00016-1108210628.vg
VG name: VG1
Description: Created *before* executing 'lvremove /dev/VG1/test1'
Backup Time: Mon Sep 16 09:14:25 2013
File: /etc/lvm/archive/VG1_00017-319369726.vg
VG name: VG1
Description: Created *before* executing 'lvremove /dev/VG1/home1'
Backup Time: Mon Sep 16 09:14:35 2013
File: /etc/lvm/archive/VG1_00018-1088715738.vg
VG name: VG1
Description: Created *before* executing 'lvremove /dev/VG1/home2'
Backup Time: Mon Sep 16 09:14:45 2013
File: /etc/lvm/archive/VG1_00019-950166769.vg
VG name: VG1
Description: Created *before* executing 'lvremove /dev/VG1/dbbackup'
Backup Time: Mon Sep 16 09:15:03 2013
File: /etc/lvm/archive/VG1_00020-722332065.vg
VG name: VG1
Description: Created *before* executing 'lvresize -L -1G /dev/VG1/public'
Backup Time: Mon Sep 16 09:20:38 2013
File: /etc/lvm/archive/VG1_00021-227400998.vg
VG name: VG1
Description: Created *before* executing 'lvresize -L +1G /dev/VG1/public'
Backup Time: Mon Sep 16 09:21:18 2013
File: /etc/lvm/archive/VG1_00022-271935578.vg
VG name: VG1
Description: Created *before* executing 'vgsplit VG1 test /dev/sda5'
Backup Time: Mon Sep 16 10:01:04 2013
File: /etc/lvm/archive/VG1_00023-196107041.vg
VG name: VG1
Description: Created *before* executing 'lvremove /dev/VG1/public'
Backup Time: Tue Sep 17 09:35:07 2013
File: /etc/lvm/backup/VG1
VG name: VG1
Description: Created *after* executing 'lvremove /dev/VG1/public'
Backup Time: Tue Sep 17 09:35:07 2013
[root@test ~]# vgcfgrestore -f /etc/lvm/archive/VG1_00023-196107041.vg
Please specify a *single* volume group to restore.
You also need to specify the volume group name
[root@test ~]# vgcfgrestore -f /etc/lvm/archive/VG1_00023-196107041.vg VG1
Restored volume group VG1
[root@test ~]# lvs
LV VG Attr LSize Origin Snap% Move Log Copy% Convert
backup VG1 -wi-ao 50.00G
downloads VG1 -wi-ao 54.00G
home VG1 -wi-ao 50.00G
images VG1 -wi-a- 50.00G
public VG1 -wi--- 60.00G
stripe VG1 -wi-a- 128.00M
Logical volume public is present now.
lvdisplay
--- Logical volume ---
LV Name /dev/VG1/public
VG Name VG1
LV UUID MvxZcK-GIIj-6Rip-pe9V-dxO4-Mptc-gKaO1O
LV Write Access read/write
LV Status NOT available
LV Size 60.00 GB
Current LE 1920
Segments 2
Allocation inherit
Read ahead sectors auto
The status is not available. Make it active
[root@test ~]# lvchange -a y /dev/VG1/public
[root@test ~]# lvdisplay
--- Logical volume ---
LV Name /dev/VG1/public
VG Name VG1
LV UUID MvxZcK-GIIj-6Rip-pe9V-dxO4-Mptc-gKaO1O
LV Write Access read/write
LV Status available
# open 0
LV Size 60.00 GB
Current LE 1920
Segments 2
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:1
Now it is in available state, mount and see the data is present or not.
[root@test ~]# mount /dev/VG1/public /public
[root@test ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 20G 18G 699M 97% /
/dev/mapper/VG1-backup
49G 197M 46G 1% /backup
/dev/mapper/VG1-downloads
50G 52M 47G 1% /downloads
/dev/mapper/VG1-home 49G 181M 46G 1% /home
tmpfs 979M 0 979M 0% /dev/shm
/dev/mapper/VG1-public
59G 641M 55G 2% /public
[root@test public]# ls
testdir
[root@test public]# cd testdir/
[root@test testdir]# ls
1 11 14 17 2 22 25 28 30 33 36 39 41 44 47 5 52 55 58 60 63 66 69 71 74 77 8 82 85 88 90 93 96 99
10 12 15 18 20 23 26 29 31 34 37 4 42 45 48 50 53 56 59 61 64 67 7 72 75 78 80 83 86 89 91 94 97
100 13 16 19 21 24 27 3 32 35 38 40 43 46 49 51 54 57 6 62 65 68 70 73 76 79 81 84 87 9 92 95 98
the data are present.
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 20G 18G 698M 97% /
/dev/mapper/VG1-backup
49G 197M 46G 1% /backup
/dev/mapper/VG1-downloads
50G 52M 47G 1% /downloads
/dev/mapper/VG1-home 49G 181M 46G 1% /home
tmpfs 979M 0 979M 0% /dev/shm
/dev/mapper/VG1-public
59G 641M 55G 2% /public
[root@test ~]# lvremove /dev/VG1/public
Can't remove open logical volume "public"
[root@test ~]# dmsetup info -c /dev/VG1/public
Name Maj Min Stat Open Targ Event UUID
VG1-public 253 7 L--w 1 2 0 LVM-8FQ0SbqlR7hlFHpG2rnxUQ2WvafgEa1yMvxZcKGIIj6Rippe9VdxO4MptcgKaO1O
Device mapper maintains entry for logical drives, so first we need to delete it from there. Then it can't restrict us while removing logical volumes which are in open status.
rom above table you can see Open = 1 which means the logical volume testlv is open status, so we need to delete entry for this logical volume from dmsetup table then only we can delete any logical volume with open status. let's do it
[root@test /]# dmsetup remove --force /dev/VG1/backup
device-mapper: remove ioctl failed: Device or resource busy
Command failed
[root@test ~]# umount /public/
[root@test ~]# lvremove /dev/VG1/public
Do you really want to remove active logical volume public? [y/n]: y
Logical volume "public" successfully removed
[root@test ~]# lvs
LV VG Attr LSize Origin Snap% Move Log Copy% Convert
backup VG1 -wi-ao 50.00G
downloads VG1 -wi-ao 54.00G
home VG1 -wi-ao 50.00G
images VG1 -wi-a- 50.00G
stripe VG1 -wi-a- 128.00M
[root@test ~]# vgcfgrestore --list VG1
File: /etc/lvm/archive/VG1_00011-1959345004.vg
VG name: VG1
Description: Created *before* executing 'lvremove /dev/VG1/snap1'
Backup Time: Wed Sep 11 20:23:22 2013
File: /etc/lvm/archive/VG1_00012-1817284231.vg
VG name: VG1
Description: Created *before* executing 'lvcreate -s --name backup-snap --size 1G /dev/VG1/backup'
Backup Time: Wed Sep 11 20:48:21 2013
File: /etc/lvm/archive/VG1_00013-1680048821.vg
VG name: VG1
Description: Created *before* executing 'lvremove /dev/VG1/backup-snap'
Backup Time: Mon Sep 16 09:13:22 2013
File: /etc/lvm/archive/VG1_00014-2084989037.vg
VG name: VG1
Description: Created *before* executing 'lvremove /dev/VG1/dbba'
Backup Time: Mon Sep 16 09:13:47 2013
File: /etc/lvm/archive/VG1_00015-1654653445.vg
VG name: VG1
Description: Created *before* executing 'lvremove /dev/VG1/public_snap'
Backup Time: Mon Sep 16 09:14:14 2013
File: /etc/lvm/archive/VG1_00016-1108210628.vg
VG name: VG1
Description: Created *before* executing 'lvremove /dev/VG1/test1'
Backup Time: Mon Sep 16 09:14:25 2013
File: /etc/lvm/archive/VG1_00017-319369726.vg
VG name: VG1
Description: Created *before* executing 'lvremove /dev/VG1/home1'
Backup Time: Mon Sep 16 09:14:35 2013
File: /etc/lvm/archive/VG1_00018-1088715738.vg
VG name: VG1
Description: Created *before* executing 'lvremove /dev/VG1/home2'
Backup Time: Mon Sep 16 09:14:45 2013
File: /etc/lvm/archive/VG1_00019-950166769.vg
VG name: VG1
Description: Created *before* executing 'lvremove /dev/VG1/dbbackup'
Backup Time: Mon Sep 16 09:15:03 2013
File: /etc/lvm/archive/VG1_00020-722332065.vg
VG name: VG1
Description: Created *before* executing 'lvresize -L -1G /dev/VG1/public'
Backup Time: Mon Sep 16 09:20:38 2013
File: /etc/lvm/archive/VG1_00021-227400998.vg
VG name: VG1
Description: Created *before* executing 'lvresize -L +1G /dev/VG1/public'
Backup Time: Mon Sep 16 09:21:18 2013
File: /etc/lvm/archive/VG1_00022-271935578.vg
VG name: VG1
Description: Created *before* executing 'vgsplit VG1 test /dev/sda5'
Backup Time: Mon Sep 16 10:01:04 2013
File: /etc/lvm/archive/VG1_00023-196107041.vg
VG name: VG1
Description: Created *before* executing 'lvremove /dev/VG1/public'
Backup Time: Tue Sep 17 09:35:07 2013
File: /etc/lvm/backup/VG1
VG name: VG1
Description: Created *after* executing 'lvremove /dev/VG1/public'
Backup Time: Tue Sep 17 09:35:07 2013
[root@test ~]# vgcfgrestore -f /etc/lvm/archive/VG1_00023-196107041.vg
Please specify a *single* volume group to restore.
You also need to specify the volume group name
[root@test ~]# vgcfgrestore -f /etc/lvm/archive/VG1_00023-196107041.vg VG1
Restored volume group VG1
[root@test ~]# lvs
LV VG Attr LSize Origin Snap% Move Log Copy% Convert
backup VG1 -wi-ao 50.00G
downloads VG1 -wi-ao 54.00G
home VG1 -wi-ao 50.00G
images VG1 -wi-a- 50.00G
public VG1 -wi--- 60.00G
stripe VG1 -wi-a- 128.00M
Logical volume public is present now.
lvdisplay
--- Logical volume ---
LV Name /dev/VG1/public
VG Name VG1
LV UUID MvxZcK-GIIj-6Rip-pe9V-dxO4-Mptc-gKaO1O
LV Write Access read/write
LV Status NOT available
LV Size 60.00 GB
Current LE 1920
Segments 2
Allocation inherit
Read ahead sectors auto
The status is not available. Make it active
[root@test ~]# lvchange -a y /dev/VG1/public
[root@test ~]# lvdisplay
--- Logical volume ---
LV Name /dev/VG1/public
VG Name VG1
LV UUID MvxZcK-GIIj-6Rip-pe9V-dxO4-Mptc-gKaO1O
LV Write Access read/write
LV Status available
# open 0
LV Size 60.00 GB
Current LE 1920
Segments 2
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:1
Now it is in available state, mount and see the data is present or not.
[root@test ~]# mount /dev/VG1/public /public
[root@test ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 20G 18G 699M 97% /
/dev/mapper/VG1-backup
49G 197M 46G 1% /backup
/dev/mapper/VG1-downloads
50G 52M 47G 1% /downloads
/dev/mapper/VG1-home 49G 181M 46G 1% /home
tmpfs 979M 0 979M 0% /dev/shm
/dev/mapper/VG1-public
59G 641M 55G 2% /public
[root@test public]# ls
testdir
[root@test public]# cd testdir/
[root@test testdir]# ls
1 11 14 17 2 22 25 28 30 33 36 39 41 44 47 5 52 55 58 60 63 66 69 71 74 77 8 82 85 88 90 93 96 99
10 12 15 18 20 23 26 29 31 34 37 4 42 45 48 50 53 56 59 61 64 67 7 72 75 78 80 83 86 89 91 94 97
100 13 16 19 21 24 27 3 32 35 38 40 43 46 49 51 54 57 6 62 65 68 70 73 76 79 81 84 87 9 92 95 98
the data are present.
No comments:
Post a Comment