Mount an old lvm1 disk image

I have restored an old backup disc containing a raw dd image of an LVM1 volume. I can attach the image to a loop device, but I cannot mount it because NixOS (like every other modern distribution) only supports LVM2, and has removed the obsolete LVM1

# lsblk -f /dev/loop1
NAME  FSTYPE      FSVER LABEL UUID                                   FSAVAIL FSUSE% MOUNTPOINTS
loop1 LVM1_member             qvBl4K-3QK0-wYyg-la09-LGdg-tjCj-Vz5EIu 

Could you suggest a solution for me to mount the image?

Run a NixOS VM based on an older NixOS release, then mount the image inside the VM:

NixOS virtual machines — nix.dev documentation, but build it with

nix-build '<nixpkgs/nixos>' -A vm \
-I nixpkgs=channel:nixos-18.04 \
-I nixos-config=./configuration.nix

or whatever release still had LVM1.

thanks!
but how should I add a channel for 18.04?

$ nix-build '<nixpkgs/nixos>' -A vm -I nixpkgs=channel:nixos-18.04 -I nixos-config=./configuration.nix
warning: Nix search path entry 'channel:nixos-18.04' cannot be downloaded, ignoring
/nix/store/pslfy1bmp8rv19vc70capzkhppvqizjd-nixos-vm

Sorry, that should have been 18.03 (not 18.04). You do not need to add the channel anywhere, just pass it in the invocation as given above.

Example
Running

nix-build '<nixpkgs/nixos>' -A vm -I nixpkgs=channel:nixos-18.03 -I nixos-config=./configuration.nix

with this configuration.nix:

{ config, pkgs, ... }:
{
  boot.loader.systemd-boot.enable = true;
  boot.loader.efi.canTouchEfiVariables = true;

  services.xserver.enable = false;
  users.users.punkpen = {
    isNormalUser = true;
    extraGroups = [ "wheel" ]; # Enable ‘sudo’ for the user.
    packages = with pkgs; [
      cryptsetup      
    ];
    initialPassword = "testpw";
  };

  system.stateVersion = "18.03";
}

creates a VM (in my case as /nix/store/6fbr56v8akfz03v709fnmzpidg8bw0jc-nixos-vm). The resulting store path has a bin/run-nixos-vm. When run, you can login to the VM with punkpen/testpw and you have access to cryptsetup 1.7.5.

In a similar way you can go back to a version that has LVM1-support (LVM2 was introduced 22.05-ish) and add all the tools you need to the VM config. Passing in your image is left as an exercise. :wink:

ha, damned ubuntu muscle memory :slight_smile:

It works, thanks a lot!

I managed passing the raw images inside the vm with:

virtualisation.qemu.options = [
    "-virtfs local,path=/home/punkpen/image,security_model=none,mount_tag=images"
];

and then

mount -t 9p images /mnt/

I wasn’t able to use virtualisation.fileSystems but is not relevant.

After attaching the disk with losetup I can see the vg and all lvs.
Thanks again.