TSF – Giải pháp IT toàn diện cho doanh nghiệp SMB | HCM

How to Setup ZFS RAID 1 on Proxmox 9 & Replace Failed Disk

In this tutorial, you will learn how to setup ZFS RAID on Proxmox to create a reliable storage solution for your virtual machines and containers. The guide covers installing Proxmox, creating ZFS partitions, and configuring RAID mirrors for data redundancy. You will also see how to monitor your ZFS pools using zpool status and zfs list. This tutorial explains step-by-step how to replace a failed disk without losing any data. We demonstrate both initial RAID setup and managing disk resilvering to ensure your storage remains healthy. By following this guide, IT admins and homelab enthusiasts can build a secure and resilient Proxmox environment. The procedures are explained with real examples to make replication on your own server easy. By the end, you will confidently manage ZFS RAID on Proxmox and protect your virtual workloads.

I LAB

Server host proxmox has 2 or more Disks
Disk 1, 2: Run raid containing OS Proxmox, and can also be used to store VMs, Backup Files, ISO Files, etc.
Demo: GPT

Step 1: Set serial for DISK VM

Simulate adding 2 more Disks to Server host proxmox to run RAID 1 (Add hard drive to run RAID 5, RAID 10..). Real hard drives will have different serials, so to simulate accurately, we will set different serials for this Disk VM Host.
nano /etc/pve/qemu-server/105.conf
Add serial line
serial=AbcxyzDSK001
serial=AbcxyzDSK002

Step 2: Install OS with ZFS Raid 1

Note: Importan GPT + 2 Disk + ZFS Raid 1

Step 3: Setup VM on Host and Run

II Simulate Disk Failure

Step 1: Identify the faulty hard drive


View zpool status
zpool status

Get the faulty hard drive ID information
 ID : 14912614961185646598
 Name: scsi-0QEMU_QEMU_HARDDISK_AbcxyzDSK001-part3
Offline Disk fail
zpool offline rpool scsi-0QEMU_QEMU_HARDDISK_AbcxyzDSK001-part3

Step 2: Shutdown the host and replace the faulty hard drive


• If the server does not support hot-swap, then shutdown Proxmox, remove the faulty hard drive, and attach a new one to the same location.
• If the server has hot-swap, you can hot-swap it and then move on to the next step.
In this demo, because I’m using a simulated VM, I’ll add a new disk according to SCSI standard and assign a serial to this disk.
nano /etc/pve/qemu-server/105.conf
Add serial line
serial=AbcxyzDSK003
Note: In case of installing OS Proxmox from the beginning as MBR (SeaBios), the work will stop at the error disk  boot with the remaining Disk  Proceed to backup VM/Data to external Storage such as NFS/SMB/OneDrive/Physical Disk  Shutdown host, attach new hard drive  Reinstall OS Proxmox for 2 Disks from the beginning  Mount Storage again and proceed to Restore VM.

Step 3: Identify the new drive after mounting

ls -l /dev/disk/by-id/

 New name: scsi-0QEMU_QEMU_HARDDISK_AbcxyzDSK003
new drive is sda, current drive is sdb

Step 4: Copy partition from old disk to new disk (BIOS boot + EFI)


On GPT, partition 1 is BIOS boot (1 MiB), partition 2 is EFI (FAT32, 512 MiB), partition 3 is ZFS root.
# Check partition
lsblk /dev/sdb
lsblk /dev/sda

# Copy partition table
sgdisk –replicate=/dev/sda /dev/sdb

• Copy partition table → create sda1, sda2, sda3 similar to sdb
• Do not copy ZFS data of sdb3 to sda3, ZFS will rebuild.
• Copy small partition (BIOS boot + EFI) if you want, but on Proxmox + PBT, EFI will reformat later:
dd if=/dev/sdb1 of=/dev/sda1 bs=1M status=progress
dd if=/dev/sdb2 of=/dev/sda2 bs=1M status=progress

• Do not copy sdb3 (ZFS root) → zpool replace will rebuild.
________________________________________
Step 5: Replace faulty disk / add new disk to mirror


Assume faulty disk is /dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_AbcxyzDSK001-part3
# Replace faulty disk with new disk
zpool replace rpool <disk old> <disk new>
zpool replace rpool scsi-0QEMU_QEMU_HARDDISK_AbcxyzDSK001-part3 scsi-0QEMU_QEMU_HARDDISK_AbcxyzDSK003-part3

# Check rebuild/resilver progress
zpool status -v
• Wait until ONLINE status, scan resilvered 100%, rpool mirror ready.
________________________________________
Step 6: Mount root dataset to prepare chroot

# Mount all datasets
zfs mount -a

# Mount root dataset using bind, chroot on Proxmox does not allow direct mounting
mkdir -p /mnt
mount –bind / /mnt

_______________________________________
Step 7: Mount EFI partition and bind necessary filesystems

# Mount EFI partition (sda2)
mkdir -p /mnt/boot/efi
mount /dev/sda2 /mnt/boot/efi

# Bind filesystem for chroot
mount –bind /dev /mnt/dev
mount –bind /proc /mnt/proc
mount –bind /sys /mnt/sys
mount –bind /run /mnt/run

_________________________________________
Step 8: Chroot and install bootloader with Proxmox Boot Tool

chroot /mnt /bin/bash

# Format EFI partition correctly Proxmox standard
proxmox-boot-tool format /dev/sda

# Refresh bootloader
proxmox-boot-tool refresh

# Check EFI partition
ls /boot/efi/EFI/proxmox

• If you see .efi files → bootloader is ready.

reboot