zfs / zvol / partition does not show up
On our Proxmox virtual machine I had to go into a volume to quickly fix an IP address. The volume exists on the VM host, so surely mounting is easy. Right?
I checked in /dev/zvol/pve2-pool/
where I found the disk:
# ls /dev/zvol/pve2-pool/vm-125-virtio0*
total 0
lrwxrwxrwx 1 root root 10 Dec 29 15:55 vm-125-virtio0 -> ../../zd48
Good, there's a disk:
# fdisk -l /dev/zd48
Disk /dev/zd48: 50 GiB, 53687091200 bytes, 104857600 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 8192 bytes
I/O size (minimum/optimal): 8192 bytes / 8192 bytes
Disklabel type: dos
Disk identifier: 0x000aec27
Device Boot Start End Sectors Size Id Type
/dev/zd48p1 * 2048 97656831 97654784 46.6G 83 Linux
/dev/zd48p2 97656832 104855551 7198720 3.4G 82 Linux swap / Solaris
And it has partitions. Now if I could only find them, so I can mount them...
Apparently, there's a volmode
on the ZFS volume that specifies how
volumes should be exposed to the OS.
Setting it to
full
exposes volumes as fully fledged block devices, providing maximal functionality. [...] Setting it todev
hides its partitions. Volumes with property set tonone
are not exposed outside ZFS, but can be snapshoted, cloned, replicated, etc, that can be suitable for backup purposes.
So:
# zfs get volmode zl-pve2-ssd1/vm-125-virtio0
NAME PROPERTY VALUE SOURCE
zl-pve2-ssd1/vm-125-virtio0 volmode default default
# zfs set volmode=full zl-pve2-ssd1/vm-125-virtio0
# zfs get volmode zl-pve2-ssd1/vm-125-virtio0
NAME PROPERTY VALUE SOURCE
zl-pve2-ssd1/vm-125-virtio0 volmode full local
# ls -1 /dev/zl-pve2-ssd1/
vm-122-virtio0
vm-123-virtio0
vm-124-virtio0
vm-125-virtio0
vm-125-virtio0-part1
vm-125-virtio0-part2
Yes! Partitions for vm-125-virtio0
.
If that partition does not show up as expected, a call to
partx -a /dev/zl-pve2-ssd1/vm-125-virtio0
might do the trick.
Quick, do some
mount /dev/zl-pve2-ssd1/vm-125-virtio0-part1 /mnt/root
; edit some
files.
But, try to refrain from editing the volume while the VM is running. That may cause filesystem corruption.
Lastly umount
and unset the volmode again:
# zfs inherit volmode zl-pve2-ssd1/vm-125-virtio0
# zfs get volmode zl-pve2-ssd1/vm-125-virtio0
NAME PROPERTY VALUE SOURCE
zl-pve2-ssd1/vm-125-virtio0 volmode default default
And optionally updating kernel bookkeeping, with:
partx -d -n 1:2 /dev/zl-pve2-ssd1/vm-125-disk-0