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)


  • 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:”

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
    • boot the rescue CentOS system
    • you will be prompted to hit “3” to get a shell

now that one has rescue shell..

# RedHat/CentOS per default uses lvm, so let's find and activate all logical lvm partitions

# 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

# 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:


Moving a volume group to another system:

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!