Storage
Last modified by Kevin Wiki on 2025/09/23 07:42
Adding external high speed VM storage to proxmox. Find the new drive and erase it and then format using parted:
# format drive and create partition
parted /dev/nvme0n1 mklabel gpt
parted /dev/nvme0n1 mkpart primary ext4 0% 100%
# create a ext4 filesystem
mkfs.ext4 /dev/nvme0n1p1
# create dir to mount drive to
mkdir -p /mnt/vmstorage
# add to fstab
printf "\n/dev/nvme0n1p1 /mnt/vmstorage ext4 defaults 0 0" >> /etc/fstab
# mount drives defined in fstab
mount
parted /dev/nvme0n1 mklabel gpt
parted /dev/nvme0n1 mkpart primary ext4 0% 100%
# create a ext4 filesystem
mkfs.ext4 /dev/nvme0n1p1
# create dir to mount drive to
mkdir -p /mnt/vmstorage
# add to fstab
printf "\n/dev/nvme0n1p1 /mnt/vmstorage ext4 defaults 0 0" >> /etc/fstab
# mount drives defined in fstab
mount
Add the new device in proxmox UI or in /etc/pve/storage.cfg to:
dir: nvme
path /mnt/vmstorage
content backup,rootdir,snippets,iso,vztmpl,images
prune-backups keep-all=1
shared 0
path /mnt/vmstorage
content backup,rootdir,snippets,iso,vztmpl,images
prune-backups keep-all=1
shared 0
Moving images from LVM storage
The actual disk is mounted as a mapper device. If is was LXC container with id 401, a disk might look like /dev/mapper/pve-vm--401--disk--0
$ fdisk -l
...
Disk /dev/mapper/pve-vm--121--disk--0: 12 GiB, 12884901888 bytes, 25165824 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 65536 bytes / 65536 bytes
Disklabel type: gpt
Disk identifier: E6B137D0-95DE-4C44-B5D1-1C74DE40F141
Device Start End Sectors Size Type
/dev/mapper/pve-vm--121--disk--0-part1 227328 25165790 24938463 11.9G Linux filesystem
/dev/mapper/pve-vm--121--disk--0-part14 2048 10239 8192 4M BIOS boot
/dev/mapper/pve-vm--121--disk--0-part15 10240 227327 217088 106M EFI System
...
Disk /dev/mapper/pve-vm--121--disk--0: 12 GiB, 12884901888 bytes, 25165824 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 65536 bytes / 65536 bytes
Disklabel type: gpt
Disk identifier: E6B137D0-95DE-4C44-B5D1-1C74DE40F141
Device Start End Sectors Size Type
/dev/mapper/pve-vm--121--disk--0-part1 227328 25165790 24938463 11.9G Linux filesystem
/dev/mapper/pve-vm--121--disk--0-part14 2048 10239 8192 4M BIOS boot
/dev/mapper/pve-vm--121--disk--0-part15 10240 227327 217088 106M EFI System
Identify the vm disk path using the command:
pvesm path STORAGE:vm-VM_ID-disk-0
Stop the container or vm:
qm stop 401
or
lxc-stop 401
or
lxc-stop 401
Then convert the the storage with:
qemu-img convert -p -O qcow2 $(pvesm path local-lvm:vm-401-disk-0) vm-401-disk-0.qcow2
note, here we also move the storage from local-lvm to nvme.