problem: manually changing uuids is tidious and might not yield the result you want. unfortunately have not succeeded yet with integrating an old harddisk.vdi (same uuids) back into the template vm (same uuids) – so the recommendation is: reinstall os from scratch, then attach the old harddisk.vdi – yes it sucks.
tested on CentOS7/rhel7
latest CentOS7 as guest does not play nicely with xfs on older VirtualBox 5.1.18 (no matter if vbox additions are installed on guest or not)
scenario: and update messed up the xfs filesystem of your vm.
so you want to:
- power down
- xfs_repair the filesystem
- mount the xfs lvm partition
- rescue the data (copy it to another place)
problem:
- if you use cloned vms (templates) your lvm partitions might all have the same uuid
- the volume groups might be called the same confusing lvm and oneself
to avoid all this hazzle it’s probably best to export/import:
“Moving a volume group to another system:” http://tldp.org/HOWTO/LVM-HOWTO/recipemovevgtonewsys.html
how to change uuid of lvm partition:
- create a rescue vm (same CentOS version your vm is running/template, that used to work fine/tested)
- power down the vm with the broken filesystem
- clone the broken vm and name it “vmname-broken” (so you will get one consistent vdi virtualbox harddisk file, remove all the snapsnots)
- copy the vmname-broken.vdi harddisk file into the rescue vm folder
- in virtualbox gui, remove rescuevm.vdi and attach “vmname-broken.vdi”
- attach CentOS-Minimal.iso to vm and boot it
now that one has rescue shell..
# RedHat/CentOS per default uses lvm, so let's find and activate all logical lvm partitions vgscan # activate lvm centos_centos volume group lvchange -a y centos_centos # gives one info about the volume group # and the physical volumes (PV) it is using vgdisplay -v # now one should be able to mount access the lvm partitions under ls -lah /dev/mapper/ # will show you all partitions and used uuids blkid # xfs repair xfs_repair /dev/mapper/centos_centos-home xfs_repair /dev/mapper/centos_centos-root # if this does not help, try to mount and unmount mkdir /mnt/home mount /dev/mapper/centos_centos-home /mnt/home umount /dev/mapper/centos_centos-home mkdir /mnt/root mount /dev/mapper/centos_centos-root /mnt/root umount /dev/mapper/centos_centos-root # if that does not help, force deleting log then repair # (last resort) xfs_repair -L /dev/mapper/centos_centos-home xfs_repair -L /dev/mapper/centos_centos-root # /dev/mapper/centos_centos-home is using xfs # /dev/mapper/centos_centos-root is using xfs # generate and apply new uuid on xfs partitions xfs_admin -U generate /dev/mapper/centos_centos-home xfs_admin -U generate /dev/mapper/centos_centos-root # changing the uuid of swap is possible but basically can only be done by re-creating it # if this would be ext4 or ext3 one would use tune2fs -U random /dev/mapper/centos_centos-home tune2fs -U random /dev/mapper/centos_centos-root # if you one wants to label the partitions xfs_admin -L "old_home" /dev/mapper/centos_centos-home xfs_admin -L "old_root" /dev/mapper/centos_centos-root # probably also a good idea to stop confusing lvm and oneself vgrename /dev/mapper/centos_centos /dev/mapper/centos_centos_old # the partition itself is marked as type "LVM2_member" # and has it's own uuid # to change it one first needs to deactivate all PVs of the VG vgchange -an centos_centos_old # also change uuid of LVM2 member /dev/sda2 pvchange --uid /dev/sda2 # restart machine sync; reboot
all xfs related man pages:
https://dwaves.de/man/xfs_admin.man.txt
https://dwaves.de/man/xfs_io.man.txt
https://dwaves.de/man/xfs_bmap.man.txt
https://dwaves.de/man/xfs_logprint.man.txt
https://dwaves.de/man/xfs_copy.man.txt
https://dwaves.de/man/xfs_mdrestore.man.txt
https://dwaves.de/man/xfs_db.man.txt
https://dwaves.de/man/xfs_metadump.man.txt
https://dwaves.de/man/xfs_estimate.man.txt
https://dwaves.de/man/xfs_mkfile.man.txt
https://dwaves.de/man/xfs_freeze.man.txt
https://dwaves.de/man/xfs_ncheck.man.txt
https://dwaves.de/man/xfs_fsr.man.txt
https://dwaves.de/man/xfs_quota.man.txt
https://dwaves.de/man/xfs_growfs.man.txt
https://dwaves.de/man/xfs_repair.man.txt
https://dwaves.de/man/xfs_info.man.txt
https://dwaves.de/man/xfs_rtcp.man.txt
Links:
Moving a volume group to another system: http://tldp.org/HOWTO/LVM-HOWTO/recipemovevgtonewsys.html
https://serverfault.com/questions/777299/proper-way-to-deal-with-corrupt-xfs-filesystems
https://www.thegeekdiary.com/how-to-use-xfs_admin-command-to-change-parameters-of-an-xfs-filesystem/
https://www.maketecheasier.com/best-file-system-linux/
https://docs.oracle.com/cd/E37670_01/E37355/html/ol_repair_xfs.html
liked this article?
- only together we can create a truly free world
- plz support dwaves to keep it up & running!
- (yes the info on the internet is (mostly) free but beer is still not free (still have to work on that))
- really really hate advertisement
- contribute: whenever a solution was found, blog about it for others to find!
- talk about, recommend & link to this blog and articles
- thanks to all who contribute!