NAME

Langertha::Holmgang::Sim::Linux::Storage - Disks and file systems on a simulated Linux server — LVM, mount, fstab, swap, mdadm

VERSION

version 0.001

SYNOPSIS

# from the Linux simulator: lsblk, blkid, findmnt, mount, umount, pvs, lvextend, resize2fs, …
Langertha::Holmgang::Sim::Linux::Storage::prepare( $dev );       # when the case loads

DESCRIPTION

Block devices, LVM, file systems and mount points of a device of type linux (cai-platform docs/entwurf-evals.md §3.3.1). The state lives under storage, the mounted file systems as before under mounts (df):

storage:
  disks:                                   # disks and partitions (parent)
    /dev/vda:  { size: 40G }
    /dev/vda1: { size: 39G, parent: /dev/vda, fstype: ext4, uuid: 0b6f…, label: root }
    /dev/vdb:  { size: 100G }              # empty
  vgs:                                     # LVM: size and free from the PVs and LVs
    vg0: { pvs: [/dev/vda2], lvs: { var: { size: 20G, fstype: ext4, uuid: … }, root: { … } } }
  md:                                      # software RAID
    /dev/md0: { level: raid1, raid_disks: 2, size: 39G, members: { /dev/sda1: active, /dev/sdb1: faulty }, fstype: ext4, uuid: … }
  swaps: [ { name: /dev/vda3, size: 2G } ] # active swap
mounts:
  /var: { dev: /dev/mapper/vg0-var, size: 20G, used: 19G, fstype: ext4, opts: "rw,relatime", reserved_pct: 5 }

A file system belongs to a device (disk, partition, LV, md) and carries there fstype, uuid, label, fssize (default: size of the device), reserved_pct, errors. When mounted, size and usage are in mounts; umount stores usage and the files under the mount point on the device (offline), mount brings them back — so the files vanish on unmount and reappear on mount, also under a different mount point.

Commands: lsblk [-f], blkid [device], findmnt [target] [--verify] [-s], mount (list), mount -a, mount [-t type] [-o opt] source target, mount target (from fstab), mount -o remount,…, umount, pvs, vgs, lvs, pvdisplay|vgdisplay|lvdisplay, pvcreate, vgextend, lvcreate -L|-l -n [-s], lvextend|lvresize -L [+]n|-l +n%FREE [-r], resize2fs, xfs_growfs, mkfs[.ext4|.xfs] [-F], mkswap, swapon [-a|--show], swapoff, fallocate -l, dd if=/dev/zero of= bs= count=, tune2fs -l|-m, e2fsck|fsck [-f] [-y], mdadm --detail|--add|--remove|--fail, cat /proc/mdstat, sfdisk -d and sfdisk device (table from the input), sgdisk -R target source, growpart disk n, partprobe, free [-h].

Like Linux: lvextend without -r grows only the LV — df sees it only after resize2fs or xfs_growfs; resize2fs on XFS and xfs_growfs on ext4 fail; a file system cannot be shrunk; mkfs refuses mounted devices and asks when a file system is present (without -F it fails); pvcreate refuses devices with a file system or partitions; umount fails ("target is busy") while a running service with uses works below it; e2fsck refuses mounted file systems; swapon without mkswap fails, warns on permissions other than 0600; mount -a reports a changed fstab as long as systemd has not reread it.

canon

my $path = canon( $dev, "UUID=…" );   # canonical device path or undef

Resolves device names: path, /dev/vg/lv, vg/lv, UUID=, LABEL=, /dev/disk/by-uuid/….

prepare

When the case loads: adds fstype from the device to mounted file systems and remembers the fstab systemd has loaded.

mount

mount (see above).

umount

umount target|device (-l same as without).

findmnt

findmnt [target] [--verify] [-s].

lsblk

lsblk [-f] [device].

blkid

blkid [device …].

lvm

pvs, vgs, lvs, pvdisplay, vgdisplay, lvdisplay, pvcreate, vgextend, lvcreate, lvextend, lvresize (the program as the fourth value).

resize2fs

resize2fs device [size] (ext2/3/4 only).

xfs_growfs

xfs_growfs mountpoint|device (mounted XFS only).

mkfs

mkfs[.ext4|.xfs] [-F|-f] [-L label] device, mkfs -t type.

tune2fs

tune2fs -l device, tune2fs -m percent device.

fsck

e2fsck|fsck|fsck.ext4 [-f] [-y|-p|-n] device.

swap

mkswap, swapon, swapoff, fallocate, dd, free (the program as the fourth value).

part

sfdisk, sgdisk, growpart, partprobe (the program as the fourth value).

mdadm

mdadm --detail md, mdadm [--manage] md --add|--remove|--fail device …, cat /proc/mdstat (via mdstat).

mdstat

Content of /proc/mdstat.

SUPPORT

Issues

Please report bugs and feature requests at https://github.com/Getty/langertha-holmgang/issues.

IRC

Join #langertha on irc.perl.org or message Getty directly.

CONTRIBUTING

Contributions are welcome! Please fork the repository and submit a pull request.

AUTHOR

Torsten Raudssus <torsten@raudssus.de>

COPYRIGHT AND LICENSE

This software is copyright (c) 2026 by Torsten Raudssus <torsten@raudssus.de> https://raudssus.de/.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.