Did Promox version update move my disks?

drjaymz@

Member
Jan 19, 2022
124
5
23
102
I have been using a guest hookscript for a few years that runs fsck on disks on the pre-start hook. It does this because the VM I am running uses a kernel boot file and so there is no opportunity to check the disk from within it.

Anyway, the script ran but didn't find the disks.

Long story short it was looking it was looking in /dev/rpool/data/vm-$vmid-* and they are now in /dev/zvol/rpool/data/vm-$vmid-* but nobody told me and I don't know how or why they moved.
I can just update my script, however, I don't like this hard coding nonsense so I want to know how I can get the disk paths from within that perl script. Also its beyond me as to how or why they would move so I thought maybe someone in this forum would know?

Perl:
    # First phase 'pre-start' will be executed before the guest
    # is started. Exiting with a code != 0 will abort the start

    print "$vmid is starting, doing preparations.\n";
  
 
    # Loop through the disks
    for my $disk (glob("/dev/rpool/data/vm-$vmid-*")) {
        # Check if the disk is a swap partition
        my $blkid_output = `blkid $disk`;
        if ($blkid_output =~ /TYPE="swap"/) {
            print "\nSkipping swap partition $disk.\n";
            next;
       }
  
       print "\nRunning e2fsck on $disk...\n";
       system("e2fsck -y $disk");
    }
    
  
    # print "preparations failed, aborting."
    # exit(1);
 
this was changed upstream in OpenZFS back in 2021:

https://github.com/openzfs/zfs/pull/12303

and made its way into the ZFS 2.2.0 stable release, which was imported into PVE last fall..

you can iterate over the VM config and call "pvesm path $VOLUME" on each volume to get the path.
 
Terrific response! I will get those updated ASAP. I only updated from PVE 7 - 8 a couple of months back so that is probably why I didn't notice it.
 
note that the disks are still exactly where they were before - just one of the links pointing at them was dropped ;) these links are similar to those in /dev/disk/by-XXX and can change depending on the rule set. you can also write your own if you want :p
 
That hook script comes out of source control so I just updated the path and everywhere its in use it will just read the new path. Its still hardcoded, I'll fix it when I get around to it. But for now it should work.
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!