Standardizing a KVM Data Disk and Recovering udev on Ubuntu

This KVM server has one system disk and two 500 GB data disks. The third disk, /dev/vdc, had the filesystem label docker-data and was mounted at /docker-data, which made it look like dedicated Docker storage.

It was not. Docker's DockerRootDir was /data/docker, still backed by the system disk /dev/vda2. The XFS filesystem on /dev/vdc contained no user files and was intended to be general-purpose storage.

Renaming the mount point was only the visible part of the work. The audit also found that the main udev and initramfs-tools packages had been removed. An old systemd-udevd process was still alive, but its executable, management tool, and persistent-storage rules were missing. The first hard symptom was that lsblk, findmnt, and the on-disk XFS superblock reported different UUIDs for the same device.

The repair therefore covered three layers:

  1. Data: rename and mount /dev/vdc as general-purpose storage-03.
  2. Device management: restore udev and rebuild block-device properties and stable links.
  3. Boot: restore initramfs tooling, rebuild the current initrd, and confirm that systemd owns the mount through /etc/fstab.

TL;DR

  • /data/storage-02 is reserved for /dev/vdb, which contains legacy data. It remains unmounted and untouched; the underlying directory uses mode 000 to reduce accidental writes by ordinary non-root processes.
  • The XFS label on /dev/vdc changed from docker-data to storage-03; its mount point changed from /docker-data to /data/storage-03.
  • /etc/fstab identifies the filesystem by UUID, never by the probe-order-dependent name /dev/vdc.
  • udev, systemd, and libudev were aligned to Ubuntu 22.04 version 249.11-0ubuntu3.22.
  • initramfs-tools, initramfs-tools-core, and initramfs-tools-bin were restored at 0.140ubuntu13.5, and the current kernel's initrd was rebuilt.
  • Docker was not restarted. Its main PID, original start time, restart count, and container running/health baselines remained unchanged.
  • Online validation passed for udev, the data disk, and the systemd runtime state. At 12:04 on 2026-08-30, root completed daemon-reload; both relevant mount units were active/mounted with NeedDaemonReload=no. Only observed reboot validation remains.

Model the storage before changing it

The actual topology before the change was:

text
/dev/vda2 ext4 -> /
├── /data/docker DockerRootDir, physically on the system disk
└── /docker-data only the mount point for vdc
/dev/vdb XFS -> unmounted, preserves legacy data
/dev/vdc XFS -> /docker-data, no user files

Mounting /dev/vdc directly at /data would have been destructive to the namespace. It would not migrate /data/docker; it would merely hide the existing /data tree beneath another filesystem.

The final naming scheme uses stable ordinal roles:

text
/data/storage-02 -> reserved for the second storage disk, vdb
/data/storage-03 -> the third storage disk, vdc

The ordinal is an operational name. The filesystem UUID is the persistent identity. If the kernel later enumerates the virtual disks under different /dev/vdX names, fstab must still select the same filesystem.

Baseline evidence

Four checks established that the mount-point migration was safe:

  1. /dev/vdc had no user files, and fuser showed no user-space process using /docker-data.
  2. Docker explicitly reported /data/docker and did not use /docker-data.
  3. /dev/vdb was unmounted and had a different filesystem UUID.
  4. The XFS filesystem reported ftype=1.

The critical inconsistency was the UUID:

text
lsblk / findmnt cache: 97686168-…
blkid -p / xfs_db: e2cd018d-…

blkid -p and xfs_db read the device directly and agreed. The stale value came from the udev database. Copying that value into fstab would have created a boot-time failure.

The package and process state explained the stale database:

text
udev package: rc (removed, configuration remnants only)
systemd-udevd: old process still running
udevadm: missing
60-persistent-storage.rules: missing

The host was running on borrowed time: the old process could continue executing from memory, but it could not be cleanly restarted after a crash or reboot.

Step 1: normalize the mount point

The underlying mount-point directories were created with mode 000. This blocks ordinary non-root processes from silently writing to the system disk when the expected filesystem is absent. It is not a security boundary against root or a process with CAP_DAC_OVERRIDE:

bash
sudo install -d -o root -g root -m 000 \
/data/storage-02 \
/data/storage-03

After confirming that /docker-data was unused and empty, the filesystem was unmounted and relabeled:

bash
sudo umount /docker-data
sudo xfs_admin -L storage-03 /dev/vdc
sudo blkid -p /dev/vdc

The persistent fstab entry uses a sanitized UUID placeholder here:

fstab
# storage-02: legacy XFS data disk, intentionally not auto-mounted.
# UUID=<VDB_UUID>
# storage-03: general-purpose XFS data disk.
UUID=<VDC_UUID> /data/storage-03 xfs defaults 0 0

Only the target filesystem was mounted:

bash
sudo mount /data/storage-03
findmnt --mountpoint /data/storage-03

I deliberately did not run mount -a. The existing fstab also manages several JuiceFS mounts, and a local-disk change should not opportunistically re-evaluate unrelated remote filesystems.

Once mounted, the XFS root exposes its normal 0755 permissions. If it is unmounted, the hidden mount-point directory returns to mode 000, retaining the guard for ordinary processes. The obsolete and empty /docker-data directory was then removed.

Step 2: restore udev

The package transaction was simulated first:

bash
sudo apt-get --simulate install udev

The actual scope was:

  • install udev and systemd-hwe-hwdb;
  • upgrade systemd, systemd-sysv, libsystemd0, libudev1, libudev-dev, and libpam-systemd;
  • remove nothing.

The installation ran non-interactively while asking needrestart to report rather than restart unrelated services:

bash
sudo env DEBIAN_FRONTEND=noninteractive \
NEEDRESTART_MODE=l \
apt-get install -y udev

No apt autoremove followed. Apt listed a large set of automatically installed packages, including boot and device-management components. Treating that list as a cleanup command without an ownership audit would have turned a focused recovery into a larger outage risk.

After installation, a new systemd-udevd process was owned by the restored unit, and all three units were active:

text
systemd-udevd.service
systemd-udevd-control.socket
systemd-udevd-kernel.socket

Step 3: replay block-device rules

Installing rule files is insufficient for devices that already exist. Reloading the rule database affects future events; a trigger is required to reprocess the current block devices:

bash
sudo udevadm control --reload-rules
sudo udevadm control --ping --timeout=10
sudo udevadm trigger --subsystem-match=block --action=change
sudo udevadm settle --timeout=60

The host has a local udev rule that sets max_sectors_kb=512 on VirtIO disks. vda, vdb, and vdc already used that value before the replay, so the trigger introduced no new I/O tuning change.

After the replay, the independent views agreed:

text
LABEL=storage-03
UUID=e2cd018d-…
FSTYPE=xfs
MOUNTPOINT=/data/storage-03

The correct stable links were recreated:

text
/dev/disk/by-label/storage-03 -> /dev/vdc
/dev/disk/by-uuid/e2cd018d-… -> /dev/vdc

The stale /dev/disk/by-label/docker-data link was gone.

Step 4: remove an fstab generator conflict

When the systemd package transaction reran the fstab generator, it exposed a pre-existing error: the same <JUICEFS_MOUNT> target was declared twice with different JuiceFS sources.

The live process, generated mount unit, and current filesystem all proved that the first definition was in use. The second definition was commented out and retained as a historical note. The active JuiceFS mount was neither unmounted nor restarted.

Static verification then reported:

text
0 parse errors
0 errors
16 warnings

Those warnings came from findmnt's detection limits for UUID-backed local sources, user-space JuiceFS sources/types, and the swapfile. The duplicate mount-point error was gone from static validation.

Static configuration and runtime state must be distinguished here. After the duplicate line was commented out, sudo /usr/bin/systemctl daemon-reload was rejected for the ordinary operations account by the effective sudo policy. That boundary was not bypassed. At 12:04 on 2026-08-30, an administrator later entered a real root session and ran:

bash
systemctl daemon-reload

The sanitized verification result was:

text
data-disk mount unit: active/mounted, SourcePath=/etc/fstab, NeedDaemonReload=no
<JUICEFS_MOUNT_UNIT>: active/mounted, SourcePath=/etc/fstab, NeedDaemonReload=no
generator output: newer than /etc/fstab

This proved that PID 1 had loaded the corrected static configuration rather than merely retaining the old generator output. The final storage-03 mount unit state was:

text
FragmentPath=/run/systemd/generator/data-storage\x2d03.mount
SourcePath=/etc/fstab
ActiveState=active
SubState=mounted
NeedDaemonReload=no

The same verification confirmed that JuiceFS remained mounted, Docker's main PID, restart count, container counts, and health state were unchanged, and systemd gained no new failed unit.

Step 5: restore and rebuild initramfs

Boot-chain validation found a second removed package set: initramfs-tools and initramfs-tools-core were both in the rc state. The host still had an initrd generated in 2024, but it no longer had a reliable way to build its successor.

The existing image was preserved before any write to /boot:

text
/boot/initrd.img-5.15.0-94-generic.before-udev-recovery-20260830

The package change was simulated and then applied:

bash
sudo apt-get --simulate install initramfs-tools
sudo env DEBIAN_FRONTEND=noninteractive \
NEEDRESTART_MODE=l \
apt-get install -y initramfs-tools

This installed initramfs-tools and initramfs-tools-core, upgraded initramfs-tools-bin, and regenerated the initrd for 5.15.0-94-generic.

lsinitramfs confirmed that the new image contains:

text
usr/bin/udevadm
usr/lib/systemd/systemd-udevd
usr/lib/udev/rules.d/60-persistent-storage.rules
virtio_blk.ko
xfs.ko

The root filesystem's ext4 support and VirtIO PCI support are built into the current kernel as CONFIG_EXT4_FS=y and CONFIG_VIRTIO_PCI=y.

Layered validation

Device layer

  • udevadm info, lsblk, and blkid -p agreed on filesystem type, label, and UUID.
  • /dev/disk/by-uuid and /dev/disk/by-label pointed to the correct device.
  • The udev daemon and both sockets were active.
  • No new udev warning was logged.

Filesystem layer

  • /dev/vdc remained mounted read-write as XFS at /data/storage-03.
  • A create/remove write test succeeded.
  • /dev/vdb remained unmounted and its legacy data was not modified.
  • The fstab entry resolved the UUID to the expected device.

systemd layer

  • The system manager reported 249.11-0ubuntu3.22.
  • The data-disk and JuiceFS mount units both came from /etc/fstab and were active/mounted.
  • The duplicate target was removed from static fstab, and findmnt --verify reported zero errors.
  • Root completed daemon-reload, and both units reported NeedDaemonReload=no.
  • The generator files were newer than /etc/fstab, proving that the cleanup was loaded into runtime state.
  • /dev/vdc, JuiceFS, and Docker retained their previous runtime state.
  • The failed-unit count remained at the four failures that existed before the change; this work introduced no new failed unit.

Docker layer

  • Docker kept the same main PID and activation timestamp.
  • NRestarts=0.
  • DockerRootDir=/data/docker, still backed by /dev/vda2.
  • Running and total container counts remained unchanged.
  • The unhealthy-container count remained zero.

This is infrastructure-level validation. It does not claim that every application endpoint inside every running container received a functional test.

Configuration snapshots and manual rollback material

The change retained separate forensic and manual rollback materials:

text
/etc/fstab.before-storage-layout-20260830
/etc/fstab.before-udev-recovery-20260830
/etc/udev.before-recovery-20260830/
/etc/initramfs-tools.before-udev-recovery-20260830/
/boot/initrd.img-5.15.0-94-generic.before-udev-recovery-20260830

Their scopes are intentionally different:

  • the first fstab copy records the previous disk layout; a rollback must first unmount the new target in a controlled way, recreate /docker-data, and decide whether to restore the old XFS label rather than blindly replacing the file and rebooting;
  • the second fstab copy records the pre-cleanup JuiceFS state; restoring it verbatim would reintroduce the duplicate definition, so it is evidence or a source for a line-by-line rollback;
  • the old initrd is recovery material for the KVM console or a recovery environment, not a file to overwrite casually on a running production host;
  • removing udev is not a valid rollback, because its absence was the fault being repaired.

What remains

The systemd runtime state is now closed and verified. The server was still not rebooted during this change. Correct runtime state and a complete initrd are strong evidence, but they are not a substitute for observed boot-chain validation after a real reboot.

A separate maintenance window still needs to:

  1. confirm KVM console access;
  2. capture container and failed-unit baselines;
  3. reboot;
  4. verify the root filesystem, storage-03, networking, Docker, and JuiceFS;
  5. run application-level requests against critical containers.

needrestart also reported long-running services that still have old shared libraries mapped. They were deliberately not restarted during this change to avoid disrupting running containers. A planned reboot will complete that transition in one controlled event.

Four pre-existing failed units remain, covering two remote-filesystem mounts and two other system services. They were not caused by this storage repair and should be handled as separate incidents rather than smuggled into the same change window.

Takeaway

The tempting interpretation was “rename /docker-data.” The real system had three chains to repair:

text
Data role: storage-03 -> general-purpose storage, not Docker storage
Device identity: XFS superblock -> udev database -> stable /dev/disk links
Boot dependency: initrd -> udev -> fstab generator -> mount unit

A path is an interface; the filesystem UUID is the identity. A successful online mount only proves the current state. Boot-chain validation is complete only when the machine reconstructs the same state after an observed reboot.

The online udev, data-disk, fstab, and systemd runtime chains are now closed without bypassing the privilege boundary. The only remaining validation is an observed reboot with a working KVM recovery path. The four pre-existing failed units remain separate incidents outside this storage change.


Comments