Offline docs (switch to live docs)                         UI-only  CLI-only 

Using storage tags

MAAS can tag block storage devices for easy recognition

Errors or typos? Topics missing? Hard to read? Let us know!

This article explains how to create, assign, remove, and view block device tags in MAAS. Block device tags are useful for organizing and categorizing your storage resources in MAAS. Here you will find two major sections:

Device tags do not currently vary by version in MAAS.

Device tags with the UI

How to create and assign block device tags

Remember: In order to create and assign tags to a block device, the device has to be in an "available" state, with no active partitions.

To create and assign tags to block devices:

  1. Select Machines.

  2. Select the machine that has the block device you want to tag.

  3. Select Storage.

  4. Scroll to Available disks and partitions.

  5. Select the Edit... option at the right end of the row for the block device you want to tag (the wording may vary).

  6. Add Tags as desired.

  7. Register your changes by selecting Save.

How to remove and delete block device tags

Remember: In order to create and assign tags to a block device, the device has to be in an "available" state, with no active partitions.

To create and assign tags to block devices:

  1. Select Machines.

  2. Select the machine that has the block device you want to tag.

  3. Select Storage.

  4. Scroll to Available disks and partitions.

  5. Select the Edit... option at the right end of the row for the block device you want to tag (the wording may vary).

  6. Remove Tags by selecting the X on the tag name.

  7. Register your changes by selecting Save.

How to list block device and partition tags

To see block device and partition tags in the UI, you can list all storage links by using the filter tool on the machine list. Here's how:

  1. Select Machines.

  2. Select Filters >> Storage tags from the drop-down.

  3. Select the tags you wish to filter against. The screen will immediately narrow to match your selections.

  4. Uncheck tags to return to the previous view.

How to view block device tags

To view all tags associated with block devices on a given machine:

  1. Select Machines.

  2. Select the machine you want to examine.

  3. Select Storage.

  4. Scroll down to Available disks and partitions.

You can view the various storage tags in this table.

How to view partition tags

To view all tags associated with partitions on a given machine:

  1. Select Machines.

  2. Select the machine you want to examine.

  3. Select Storage.

  4. Scroll down to Available disks and partitions.

You can view the various storage tags in this table.

Device tags with the CLI

How to discover the ID of your block device

Block devices do not exist apart from the physical or virtual machines to which they are attached. Finding the ID of the block device that interests you requires starting with a particular machine, in a command form that looks like this:

maas $PROFILE block-devices read $SYSTEM_ID \
| jq -r '(["system_id","block_device_id","path","avail_size"]
|(.,map(length*"-"))),(.[]|[.system_id,.id,.path,.available_size])
| @tsv' | column -t

For example:

maas admin block-devices read qk4b3g \
| jq -r '(["system_id","block_device_id","path","avail_size"]
|(.,map(length*"-"))),(.[]|[.system_id,.id,.path,.available_size])
| @tsv' | column -t

This example would produce output that looks something like this:

system_id  block_device_id  path                    avail_size
---------  ---------------  ----                    ----------
qk4b3g     10               /dev/disk/by-dname/sda  0

The path component is printed to help you confirm that you are choosing the right block device when there are several present. The avail-size column will tell you whether you can operate on that block device at all. If the available size is "0," for example, you can't set a block device tag on any part of that drive. Instead, you'd want to see something like this:

system_id  block_device_id  path                    avail_size
---------  ---------------  ----                    ----------
xn8taa     8                /dev/disk/by-dname/sda  1996488704

How to assign tags to a block device

You can only assign tags to a block device that is available. You can find out whether the block device is available at all when you discover its ID.

To assign an existing tag to a block device, you would type a command formulated like this:

maas $PROFILE block-device add-tag $SYSTEM_ID $BLOCK_DEVICE_ID tag=$TAG_NAME

If you're not sure about the ID of your block device, you can look it up.

For example:

maas admin block-device add-tag xn8taa 8 tag=farquar

If this command succeeds, it will display Success, followed by a JSON sequence describing the new state of the block device.

Note that if you try to add a tag to a block device that is not available, that is, to a block device that is in use, you will get a result like this:

Not Found

How to remove tags from a block device

You can only remove tags from a block device that is available. You can find out whether the block device is available at all when you discover its ID.

To remove an assigned tag from a block device, you would type a command formulated like this:

maas $PROFILE block-device remove-tag $SYSTEM_ID $BLOCK_DEVICE_ID tag=$TAG_NAME

If you're not sure about the ID of your block device, you can look it up.

For example:

maas admin block-device remove-tag xn8taa 8 tag=farquar

If this command succeeds, it will display Success, followed by a JSON sequence describing the new state of the block device.

Note that if you try to remove a tag from a block device that is not available, that is, from a block device that is in use, you will get a result like this:

Not Found

On the other hand, if you try to remove a tag that is not assigned to the block device you've chosen, MAAS will simply return Success, followed by a JSON sequence describing the current state of the block device.

How to list tags for all block devices

To list tags for all block devices associated with a physical or virtual machine, you can use a command of this form:

maas $PROFILE block-devices read $SYSTEM_ID | jq -r '(["id","tags"]|(.,map(length*"-"))),(.[]|[.id,.tags[]]) | @tsv' | column -t

For example:

maas admin block-devices read xn8taa | jq -r '(["id","tags"]|(.,map(length*"-"))),(.[]|[.id,.tags[]]) | @tsv' | column -t

This command would produce output similar to this:

id  tags
--  ----
8   hello  ssd  trinkoplinko

How to view tags for one block device

To view tags for one specific block device, you can enter a command like this:

maas $PROFILE block-device read $SYSTEM_ID $BLOCK_DEVICE_ID | jq -r '(["id","tags"]|(.,map(length*"-"))),([.id,.tags[]]) | @tsv' | column -t

If you're not sure about the ID of your block device, you can look it up.

For example:

maas admin block-device read xn8taa 8 | jq -r '(["id","tags"]|(.,map(length*"-"))),([.id,.tags[]]) | @tsv' | column -t

This command would produce output similar to this:

id  tags
--  ----
8   hello  ssd  trinkoplinko
9   20gig  ssd
10  250Gs  ssd

<a href="#heading--discover

-the-id-of-your-partition">

How to discover the ID of your partition

Partitions do not exist apart from the block devices on which they reside. Finding the ID of the partition that interests you requires starting with a particular machine and block device, similar to this command:

maas $PROFILE partitions read $SYSTEM_ID $BLOCK_DEVICE_ID \
| jq -r '(["system_id","block_dev_id","part_id","path"]
|(.,map(length*"-"))),(.[]|[.system_id,.device_id,.id,.path])
|@tsv' | column -t

For example:

maas admin partitions read xn8taa 8 \
| jq -r '(["system_id","block_dev_id","part_id","path"]
|(.,map(length*"-"))),(.[]|[.system_id,.device_id,.id,.path])
|@tsv' | column -t

This example would produce output that looks something like this:

system_id  block_dev_id  part_id  path
---------  ------------  -------  ----
xn8taa     8             67       /dev/disk/by-dname/sda-part1

The path component is printed to help you confirm that you are choosing the right partition, when there are several present.

How to assign tags to a partition

You can only assign tags to a partition that is available. To assign an existing tag to a partition, you would type a command formulated like this:

maas $PROFILE partition add-tag $SYSTEM_ID $BLOCK_DEVICE_ID $PARTITION_ID tag=$TAG_NAME

If you're not sure about the ID of your partition, you can look it up.

For example:

maas admin partition add-tag xn8taa 8 67 tag=farquar

If this command succeeds, it will display Success, followed by a JSON sequence describing the new state of the partition.

Note that if you try to add a tag to a partition that is not available, that is, to a partition that is in use, you will get a result like this:

Not Found

How to remove tags from a partition

You can only remove tags from a partition that is available. To remove a existing tag from a partition, you would type a command formulated like this:

maas $PROFILE partition remove-tag $SYSTEM_ID $BLOCK_DEVICE_ID $PARTITION_ID tag=$TAG_NAME

If you're not sure about the ID of your partition, you can look it up.

For example:

maas admin partition remove-tag xn8taa 8 67 tag=farquar

If this command succeeds, it will display Success, followed by a JSON sequence describing the new state of the partition.

Note that if you try to remove a tag from a partition that is not available, that is, from a partition that is in use, you will get a result like this:

Not Found

On the other hand, if you try to remove a tag that is not assigned to the partition you've chosen, MAAS will simply return Success, followed by a JSON sequence describing the current state of the partition.

How to list tags for all partitions

To list tags for all partitions of a particular block device, use a command like this one:

maas $PROFILE partitions read $SYSTEM_ID $BLOCK_DEVICE_ID \
| jq -r '(["id","tags"]
|(.,map(length*"-"))),(.[]|[.id,.tags[]])
| @tsv' | column -t

For example:

maas admin partitions read xn8taa 8 \
| jq -r '(["id","tags"]
|(.,map(length*"-"))),(.[]|[.id,.tags[]])
| @tsv' | column -t

A command like this should return output similar to the following:

id  tags
--  ----
54  farquar swap opendisk
67  foobar  farquar
97  foobar

How to view tags for one partition

To view tags for one partition, enter

a command like this:

maas $PROFILE partition read $SYSTEM_ID $BLOCK_DEVICE_ID $PARTITION_ID | jq -r '(["id","tags"]|(.,map(length*"-"))),([.id,.tags[]]) | @tsv' | column -t

If you're not sure about the ID of your partition, you can look it up.

For example:

maas admin partition read xn8taa 8 67 | jq -r '(["id","tags"]|(.,map(length*"-"))),([.id,.tags[]]) | @tsv' | column -t

This command would produce output similar to this:

id  tags
--  ----
67  farquar foobar

Remember, these are the basic commands for managing tags on block devices and partitions. You can adapt them to your specific needs and use cases within your MAAS environment.