Skip to content

mount

import { mount, parseFstab, serializeFstab } from 'sysopkit/op/mount';

Mounts a filesystem at the given path (idempotent).

await mount({ src: '/dev/sdb1', path: '/mnt/data', fstype: 'ext4' });

Bind-mounts (idempotent via file identity — a bound path exposes the source’s inode):

await mount({ src: '/srv/data', path: '/mnt/data', bind: true });
// installer API mounts: don't propagate submounts into the bind
await mount({ src: '/dev', path: '/target/dev', rslave: true });
// recursive bind so /dev/pts, /dev/shm propagate; --mkdir creates parents
await mount({ src: '/dev', path: '/target/dev', rbind: true, mkdir: true });
// file bind over a stub symlink without resolving it first
await mount({
src: '/run/systemd/resolve/stub-resolv.conf',
path: '/target/etc/resolv.conf',
bind: true,
noCanonicalize: true,
});

Propagation-only remount (no src; skips when findmnt already reports it):

await mount({ path: '/target/dev', propagation: 'rslave' });

Detaches the mount at the given path (idempotent — skips when nothing is mounted).

await umount({ path: '/mnt/data' });

Recursive + lazy detach for retry cleanup and pre-reboot paths. The pre-check is submount-aware, so orphaned child mounts are detached even when path itself is no longer mounted; ignoreErrors turns a failed detach into a no-op instead of stranding the flow:

await umount({ path: '/target', recursive: true, lazy: true, ignoreErrors: true });

Parse fstab content into entries, or serialize entries back into fstab format.

const entries = parseFstab(existingContent);
entries.push({
device: '/dev/sdb1',
mountPoint: '/mnt/data',
fsType: 'ext4',
options: ['defaults'],
dump: 0,
pass: 2,
});
const newContent = serializeFstab(entries);