Add existing directory storage to proxmox without wiping it first

I wanted to blog about this because I couldn't find any info about it on the internet.

Against the advice of everyone, I installed Proxmox on a USB thumbdrive. And, as predicted by everyone who gave that advice, the thumbdrive failed after a couple months.

So I rebuilt my server with a new 1TB SSD disk and a backup of /etc/pve, but my (Directory) storage wasn't appearing. Most blogs suggested editing fstab but my previous config didn't have the target disks in fstab, so I knew that wasn't the solution I was looking for. Turns out, Proxmox uses systemd to mount Directory storage.

Here's the path I took based on a number of helpful forum posts and blogs.

  • Take a look around the disks using lsblk
  • Got more details after my initial orientation
  • Added the mounts to systemd
  • Enabled the mounts in systemd
  • Party when it works

So first, I started with getting idea of what the current disk setup looks like with lsblk.

 1> lsblk
 2NAME               MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
 3sda                  8:0    0 931.5G  0 disk
 4├─sda1               8:1    0  1007K  0 part
 5├─sda2               8:2    0   512M  0 part
 6└─sda3               8:3    0   931G  0 part
 7  ├─pve-swap       253:0    0     8G  0 lvm  [SWAP]
 8  ├─pve-root       253:1    0    96G  0 lvm  /
 9  ├─pve-data_tmeta 253:2    0   8.1G  0 lvm
10  │ └─pve-data     253:4    0 794.8G  0 lvm
11  └─pve-data_tdata 253:3    0 794.8G  0 lvm
12    └─pve-data     253:4    0 794.8G  0 lvm
13sdb                  8:16   0 465.8G  0 disk
14└─sdb1               8:17   0 465.8G  0 part
15nvme0n1            259:0    0 476.9G  0 disk
16└─nvme0n1p1        259:1    0 476.9G  0 part

Then, I got more details, taking particular note of the UUID of each disk.

 1root@proxmox:~# lsblk -fs
 2NAME             FSTYPE      FSVER    LABEL UUID                                   FSAVAIL FSUSE% MOUNTPOINT
 3sda1
 4└─sda
 5sda2             vfat        FAT32          8EB3-321A
 6└─sda
 7sdb1             ext4        1.0            4ebde4e5-f56e-4bbb-bf16-a803efd5ae60    282.8G    33% 
 8└─sdb
 9pve-swap         swap        1              53bd881c-6778-496e-939f-76f716311840                  [SWAP]
10└─sda3           LVM2_member LVM2 001       0s1SbD-EreR-DwIQ-WcdO-ywLD-e5DF-3rAtrM
11  └─sda
12pve-root         ext4        1.0            1c91f72d-1721-49d3-bbf7-76681f5aec4c     86.4G     3% /
13└─sda3           LVM2_member LVM2 001       0s1SbD-EreR-DwIQ-WcdO-ywLD-e5DF-3rAtrM
14  └─sda
15pve-data
16├─pve-data_tmeta
17│ └─sda3         LVM2_member LVM2 001       0s1SbD-EreR-DwIQ-WcdO-ywLD-e5DF-3rAtrM
18│   └─sda
19└─pve-data_tdata
20  └─sda3         LVM2_member LVM2 001       0s1SbD-EreR-DwIQ-WcdO-ywLD-e5DF-3rAtrM
21    └─sda
22nvme0n1p1        ext4        1.0            4106806e-0ec1-49a4-85e8-dc2337a04086    127.9G    68% 
23└─nvme0n1

Now that I've got the UUID I need, I created a mount file in /etc/systemd/system.

Note: this process could probably be simplified using something like pvesm add dir ssd -path /mnt/pve/ssd --is_mountpoint yes but I don't have extra disks to test.

Mount up!

 1root@proxmox:~# cat /etc/systemd/system/mnt-pve-ssd.mount
 2[Install]
 3WantedBy=multi-user.target
 4
 5[Mount]
 6Options=defaults
 7Type=ext4
 8What=/dev/disk/by-uuid/4ebde4e5-f56e-4bbb-bf16-a803efd5ae60
 9Where=/mnt/pve/ssd
10
11[Unit]
12Description=Mount storage 'ssd' under /mnt/pve

After creating the configs for both mnt-pve-ssd.mount and mnt-pve-m2.mount, I checked to see if they were enabled.

 1root@proxmox:~# systemctl list-unit-files -t mount
 2
 3UNIT FILE                     STATE     VENDOR PRESET
 4-.mount                       generated -
 5dev-hugepages.mount           static    -
 6dev-mqueue.mount              static    -
 7mnt-pve-m2.mount              disabled  disabled
 8mnt-pve-ssd.mount             disabled  disabled
 9proc-fs-nfsd.mount            static    -
10proc-sys-fs-binfmt_misc.mount disabled  disabled
11run-rpc_pipefs.mount          static    -
12sys-fs-fuse-connections.mount static    -
13sys-kernel-config.mount       static    -
14sys-kernel-debug.mount        static    -
15sys-kernel-tracing.mount      static    -
16
1712 unit files listed.

Not yet! So I enabled both of my disks

1root@proxmox:~# systemctl enable mnt-pve-m2.mount
2Created symlink /etc/systemd/system/multi-user.target.wants/mnt-pve-m2.mount → /etc/systemd/system/mnt-pve-m2.mount.
3root@proxmox:~# systemctl enable mnt-pve-ssd.mount
4Created symlink /etc/systemd/system/multi-user.target.wants/mnt-pve-ssd.mount → /etc/systemd/system/mnt-pve-ssd.mount.

Then I checked to see they were enabled.

 1root@proxmox:~# systemctl list-unit-files -t mount
 2
 3UNIT FILE                     STATE     VENDOR PRESET
 4-.mount                       generated -
 5dev-hugepages.mount           static    -
 6dev-mqueue.mount              static    -
 7mnt-pve-m2.mount              enabled   enabled
 8mnt-pve-ssd.mount             enabled   enabled
 9proc-fs-nfsd.mount            static    -
10proc-sys-fs-binfmt_misc.mount disabled  disabled
11run-rpc_pipefs.mount          static    -
12sys-fs-fuse-connections.mount static    -
13sys-kernel-config.mount       static    -
14sys-kernel-debug.mount        static    -
15sys-kernel-tracing.mount      static    -
16
1712 unit files listed.

Lookin good. I rebooted, then checked out /etc/mtab and there they were.

1/dev/nvme0n1p1 /mnt/pve/m2 ext4 rw,relatime 0 0
2/dev/sdb1 /mnt/pve/ssd ext4 rw,relatime 0 0

Then I checked again with lsblk and there were my mounted disk, nice!

 1root@proxmox:~# lsblk
 2NAME               MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
 3sda                  8:0    0 931.5G  0 disk
 4├─sda1               8:1    0  1007K  0 part
 5├─sda2               8:2    0   512M  0 part
 6└─sda3               8:3    0   931G  0 part
 7  ├─pve-swap       253:0    0     8G  0 lvm  [SWAP]
 8  ├─pve-root       253:1    0    96G  0 lvm  /
 9  ├─pve-data_tmeta 253:2    0   8.1G  0 lvm
10  │ └─pve-data     253:4    0 794.8G  0 lvm
11  └─pve-data_tdata 253:3    0 794.8G  0 lvm
12    └─pve-data     253:4    0 794.8G  0 lvm
13sdb                  8:16   0 465.8G  0 disk
14└─sdb1               8:17   0 465.8G  0 part /mnt/pve/ssd
15nvme0n1            259:0    0 476.9G  0 disk
16└─nvme0n1p1        259:1    0 476.9G  0 part /mnt/pve/m2

One big caveat I wanted to mention -- if you back up your /etc/pve directory, make sure the UUID in your backup files match your current setup. Took me 3 days of battling Proxmox to realize that.