Skip to content

LambdaLabsML/antman

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 

Repository files navigation

antman

Adjustable mount manager for Lambda Cloud persistent filesystems.

antman creates loop-mounted ext4 filesystems backed by image files on Lambda's persistent NFS storage (/lambda/nfs/<name>). You can create, expand, shrink, remove, and migrate these mounts across instances.

Why

Lambda Cloud persistent filesystems are truly elastic (no fixed size), but sometimes you need a mount with a controlled size limit -- for quotas, sandboxing, or keeping a dataset bounded. antman gives you that by creating a fixed-size ext4 image on the elastic NFS and loop-mounting it.

Prerequisites

Standard Linux utilities (present on Lambda Cloud instances by default):

  • truncate, mkfs.ext4, mount, umount
  • losetup, resize2fs, e2fsck
  • rsync, ssh (for migration)
  • sudo access

Install

git clone https://github.com/LambdaLabsML/antman.git && cd antman
sudo make install

To uninstall:

sudo make uninstall

Usage

antman [--yes|-y] <command> [options]

create -- Create a new filesystem

antman create --fs-lambda <lambda-fs-name> --fs-new <mount-name> --size <size>

Creates a sized ext4 image at /lambda/nfs/<fs-lambda>/<mount-name>.img and mounts it to /mnt/<mount-name>.

Example:

antman create --fs-lambda my-persistent-fs --fs-new data --size 100M

This creates a 100MB filesystem at /lambda/nfs/my-persistent-fs/data.img mounted at /mnt/data.


expand -- Grow an existing mount

antman expand --fs-new <mount-name> --size <new-size>

Expands the filesystem to the new (larger) size. The mount stays active throughout -- no downtime.

--fs-lambda is auto-detected from the active mount. You can override it with --fs-lambda <name> if needed.

Example:

antman expand --fs-new data --size 2T

shrink -- Shrink an existing mount

antman shrink --fs-new <mount-name> --size <new-size>

Shrinks the filesystem to the new (smaller) size. The mount is temporarily unmounted during the operation.

Before proceeding, antman shows the current used space so you can verify the target size is safe. If resize2fs fails (e.g., data won't fit), the original image is remounted unchanged.

Example:

antman shrink --fs-new data --size 1T

remove -- Delete a mount

antman remove --fs-new <mount-name>

Unmounts the filesystem, deletes the image file, and removes the mount directory. Irreversible.

If the mount is not currently active, provide --fs-lambda explicitly so antman can find the image.

Example:

antman remove --fs-new data

# If not mounted:
antman remove --fs-new data --fs-lambda my-persistent-fs

migrate -- Copy a mount to another Lambda instance

antman migrate --fs-local <local-mount-name> \
    --remote-ip <ip> \
    --ssh-key <key-name-or-path> \
    --remote-fs-lambda <remote-lambda-fs-name> \
    [--fs-remote <remote-mount-name>] \
    [--remote-user <user>]

Copies the image to a remote Lambda Cloud instance and mounts it there. Uses rsync for resumable transfers. The local mount is temporarily unmounted during the transfer to ensure a clean image.

--fs-local identifies the local mount to copy. --fs-remote sets the name on the remote side (defaults to the same as --fs-local).

Safety checks (run before transfer):

  • Remote persistent FS (/lambda/nfs/<remote-fs-lambda>) must exist
  • Remote image (<remote-mount-name>.img) must NOT already exist
  • Remote mount point (/mnt/<remote-mount-name>) must NOT be active

If any check fails, antman tells you what went wrong and prompts you to enter a corrected value (e.g., a different --remote-fs-lambda or --fs-remote). Checks are re-run automatically until all pass or you type q to abort.

The local copy is not removed. Run antman remove afterward if you want to clean up.

--remote-user defaults to ubuntu. --ssh-key accepts either a key name (looked up in ~/.ssh/) or a full path.

Examples:

# Same name on remote
antman migrate --fs-local data \
    --remote-ip 203.0.113.42 \
    --ssh-key lambda-key \
    --remote-fs-lambda new-instance-fs

# Different name on remote
antman migrate --fs-local data --fs-remote data-backup \
    --remote-ip 203.0.113.42 \
    --ssh-key lambda-key \
    --remote-fs-lambda new-instance-fs

list -- Show all antman filesystems

antman list

Displays all antman-managed filesystems, both mounted (detected via loop devices) and unmounted (found by scanning /lambda/nfs/*/*.img).

Example output:

ANTMAN MOUNTS

  data          fs-lambda=my-persistent-fs    size=100M     used=12M      mounted at /mnt/data
  archive       fs-lambda=my-persistent-fs    size=500M     used=-         not mounted

Scripting

Use --yes / -y to skip confirmation prompts:

antman -y remove --fs-new data
antman -y shrink --fs-new data --size 50M

How it works

/lambda/nfs/<persistent-fs>/          # Lambda's elastic NFS (no size limit)
  └── <mount-name>.img                # Fixed-size ext4 image (antman-managed)
        ↕ loop mount
/mnt/<mount-name>/                    # Bounded mount point
  1. truncate creates a sparse file of the desired size on NFS
  2. mkfs.ext4 formats it as ext4
  3. mount -o loop attaches it as a loop device and mounts it
  4. Expand/shrink use resize2fs + truncate to adjust the image and filesystem

License

MIT

About

Resize fs on lambda cloud

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published