Thursday 21 September 2017

Error getting authority: Error initializing authority: Could not connect: No such file or directory (g-io-error-quark, 1)

When trying to disaster recover a VM from backup files you need all the disk, partitions, LVM info to match up the new system with the old. When you get this error message:
Error getting authority: Error initializing authority: Could not connect: No such file or directory (g-io-error-quark, 1)
It usually mean that it is referencing a disk, partition or LVM volume that it can't fine. Check out the /etc/fstab and remove those entries. For example, the original VM had this fstab configuration:
#
# /etc/fstab
# Created by anaconda on Tue Jun  9 09:18:57 2015
#
# 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
#
/dev/mapper/centos-root /                       ext4    defaults        1 1
UUID=f3371e3a-e4f9-4423-9bf3-dd7242ce4de9 /boot                   ext4    defaults        1 2
UUID=F7BA-C6DF          /boot/efi               vfat    umask=0077,shortname=winnt 0 0
/dev/mapper/centos-home /home                   ext4    defaults        1 2
/dev/mapper/centos-opt  /opt                    ext4    defaults        1 2
/dev/mapper/centos-tmp  /tmp                    ext4    defaults        1 2
/dev/mapper/centos-var  /var                    ext4    defaults        1 2
/dev/mapper/centos-swap swap                    swap    defaults        0 0
The restored files went on to a system that had no /dev/mapper/centos-tmp LVM volume. This caused the error at boot asking for root password for maintenance!

Tuesday 12 September 2017

Mounting LVM with same PV, LV, VG names as system

What happens when we try to use a disk that has the same LVM names as our system?
[root@st ~]# pvs
  WARNING: Not using lvmetad because duplicate PVs were found.
  WARNING: Use multipath or vgimportclone to resolve duplicate PVs?
  WARNING: After duplicates are resolved, run "pvscan --cache" to enable lvmetad.
  WARNING: PV aP2MDZ-3scA-JYFj-cX1A-22JX-tj1p-iaNIZl on /dev/sdb3 was already found on /dev/sda3.
  WARNING: PV aP2MDZ-3scA-JYFj-cX1A-22JX-tj1p-iaNIZl prefers device /dev/sda3 because device is used by LV.
  PV         VG     Fmt  Attr PSize  PFree
  /dev/sda3  centos lvm2 a--  99.00g 4.00m

[root@st ~]# lvs
  WARNING: Not using lvmetad because duplicate PVs were found.
  WARNING: Use multipath or vgimportclone to resolve duplicate PVs?
  WARNING: After duplicates are resolved, run "pvscan --cache" to enable lvmetad.
  WARNING: PV aP2MDZ-3scA-JYFj-cX1A-22JX-tj1p-iaNIZl on /dev/sdb3 was already found on /dev/sda3.
  WARNING: PV aP2MDZ-3scA-JYFj-cX1A-22JX-tj1p-iaNIZl prefers device /dev/sda3 because device is used by LV.
  LV   VG     Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  home centos -wi-ao----  6.99g
  opt  centos -wi-ao---- 20.00g
  root centos -wi-ao---- 32.00g
  swap centos -wi-ao----  4.00g
  tmp  centos -wi-ao----  4.00g
  var  centos -wi-ao---- 32.00g

[root@st ~]# vgdisplay
  WARNING: Not using lvmetad because duplicate PVs were found.
  WARNING: Use multipath or vgimportclone to resolve duplicate PVs?
  WARNING: After duplicates are resolved, run "pvscan --cache" to enable lvmetad.
  WARNING: PV aP2MDZ-3scA-JYFj-cX1A-22JX-tj1p-iaNIZl on /dev/sdb3 was already found on /dev/sda3.
  WARNING: PV aP2MDZ-3scA-JYFj-cX1A-22JX-tj1p-iaNIZl prefers device /dev/sda3 because device is used by LV.
  --- Volume group ---
  VG Name               centos
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  8
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                6
  Open LV               6
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               99.00 GiB
  PE Size               4.00 MiB
  Total PE              25343
  Alloc PE / Size       25342 / 98.99 GiB
  Free  PE / Size       1 / 4.00 MiB
  VG UUID               u5BLZG-ds9z-6dRh-0AI7-kAxD-n6lh-cvkKEw

[root@st ~]# vgrename aP2MDZ-3scA-JYFj-cX1A-22JX-tj1p-iaNIZl recover
  WARNING: Not using lvmetad because duplicate PVs were found.
  WARNING: Use multipath or vgimportclone to resolve duplicate PVs?
  WARNING: After duplicates are resolved, run "pvscan --cache" to enable lvmetad.
  WARNING: PV aP2MDZ-3scA-JYFj-cX1A-22JX-tj1p-iaNIZl on /dev/sdb3 was already found on /dev/sda3.
  WARNING: PV aP2MDZ-3scA-JYFj-cX1A-22JX-tj1p-iaNIZl prefers device /dev/sda3 because device is used by LV.
  WARNING: PV aP2MDZ-3scA-JYFj-cX1A-22JX-tj1p-iaNIZl on /dev/sdb3 was already found on /dev/sda3.
  WARNING: PV aP2MDZ-3scA-JYFj-cX1A-22JX-tj1p-iaNIZl prefers device /dev/sda3 because of previous preference.
  Volume group "aP2MDZ-3scA-JYFj-cX1A-22JX-tj1p-iaNIZl" not found
  Cannot process volume group aP2MDZ-3scA-JYFj-cX1A-22JX-tj1p-iaNIZl
We can use vgimportclone to rename the extra volume names and then use. However if we do this the volume group will be permanently renamed. To mount on a target system with the original name, we need to boot from CDROM and rename the volume back.
[root@pe-test-st ~]# vgimportclone --basevgname recover /dev/sdb3
  WARNING: PV aP2MDZ-3scA-JYFj-cX1A-22JX-tj1p-iaNIZl on /dev/sdb3 was already found on /dev/sda3.
  WARNING: PV aP2MDZ-3scA-JYFj-cX1A-22JX-tj1p-iaNIZl prefers device /dev/sda3 because device is used by LV.

[root@pe-test-st ~]# lvs
  LV   VG      Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  home centos  -wi-ao----  6.99g
  opt  centos  -wi-ao---- 20.00g
  root centos  -wi-ao---- 32.00g
  swap centos  -wi-ao----  4.00g
  tmp  centos  -wi-ao----  4.00g
  var  centos  -wi-ao---- 32.00g
  home recover -wi-------  6.99g
  opt  recover -wi------- 20.00g
  root recover -wi------- 32.00g
  swap recover -wi-------  4.00g
  tmp  recover -wi-------  4.00g
  var  recover -wi------- 32.00g

[root@pe-test-st ~]# vgchange -a y  recover
  6 logical volume(s) in volume group "recover" now active

[root@pe-test-st ~]# ls /dev/recover/
home  opt  root  swap  tmp  var

[root@pe-test-st ~]# mount /dev/recover/root /mnt

[root@pe-test-st ~]# ls /mnt
1    boot   dev  home  lib64       media  nsr  proc  run   srv  tmp  var
bin  cdrom  etc  lib   lost+found  mnt    opt  root  sbin  sys  usr