CLI for filesystem?


I am using the CLI for fine-tuning storage as referred in the documentation.

I can assign a LVM template with tunned volume sizes,

I can add a logical volume for swap,

however, I cannot assign the “swap” filesystem to the logical volume (as in UI)

how do I configure filesystems from the CLI?

Hi @rvallel,

To format logical volume, you need the use the block-device command (it’s a lite confusing)

The basic steps are:

# Create logical volume
out=$(maas $login volume-group create-logical-volume $system_id $vg_id name=$name size=$size)

# Get the id of the new logical-volume
id=$(echo $out | jq -r '.id')

# Format the partition
maas $login block-device format $system_id $id fstype=$fs > /dev/null

# Mount the partition
maas $login block-device mount $system_id $id mount_point=$mp mount_options=$mo

The block-device id used for formatting and mounting is the logical-volume id.
Settings used for swap type: fstype="swap", mount_point="none" and mount_options=sw


@adolfo94 many thanks

what would be $mo in this case? none?

Ok, I can see that it is optional and can be omitted.

Depends of the SO, but I in this case, you can specify nothing (not use mount_options) or use sw.

I just edited the response, to make the parameter more visible.

1 Like