Manage a flash filesystem
Syntax:
flashctl [-eFfimruvxz] [-A] [-a flags] [-b align]
[-c flag] [-L] [-l limit] [-n path] [-o offset]
-p path [-s num] [-U] [-u] [-v...]
Options:
The options are processed in the order given, and apply to the last
partition specified by a -p option, letting you control
multiple partitions with one command.
- -A
- Unlock the entire flash array specified by the preceding -p option.
Note:
Use this option only with a raw device (e.g., /dev/fs0);
don't use it with a mounted partition.
You can't use the -l and -o options with the -A option.
- -a flags
- The mount-attribute flags
(the _MOUNT_* bits defined in <sys/mount.h>, and
the IOFUNC_MOUNT_* bits defined in <sys/iofunc.h>).
The default is 0.
- -b align
- Set the alignment to 2align.
The default value of align is 2, resulting in an alignment of 22.
If you start the
devf-*
driver with the -D (automatic detection of error-correcting code mode) or
-x (enable software ECC mode) option, you need to specify the alignment.
If you're using 64-byte alignment ECC, specify 6.
For example:
devf-generic -x1 -s0x20000000,16M
flashctl -p /dev/fs0 -o1M -ev
flashctl -p /dev/fs0p0 -o1M -f -b6
If you're using 32-byte alignment ECC, specify 5 for align.
For example:
devf-generic -x2 -s0x20000000,16M
flashctl -p /dev/fs0 -o1M -ev
flashctl -p /dev/fs0p0 -o1M -fv -b5
- -c flag
- Set the compression flag (default 1).
- -e
- Erase the raw partition specified by the preceding -p option
from the offset specified by the -o option through to
limit specified by the -l option.
If you specify the -v option for verbose output,
flashctl outputs a period (.) for every partition unit that it erases.
On RAM disk, the unit size is 64K; on other devices, it varies.
This output is reassuring because it can take several minutes to erase slow flash devices.
- -f
- Format the raw partition specified by the preceding -p option
from the offset specified by the -o option through to
limit specified by the -l option.
- -F
- Force the driver to use the given offset and length parameters, even
if the offset and length parameters don't fall within the bounds
of the partition specified by the preceding -p option. The range
provided by the -o and -l arguments must fit in a single
partition, and can't cross partition boundaries.
- -i
- Print filesystem information for the partition specified by the preceding -p option; see
Filesystem information,
below.
- -L
- Lock the raw partition specified by the preceding -p option
from the offset specified by the -o option
through to limit specified by the -1 option.
Note:
The
-L option fails if the partition (e.g.,
/dev/fs0p0) is mounted.
You can use /dev/fs0 to bypass the mounted
filesystem check, but we don't recommend that you do so, because
the /dev/fs0 path bypasses all protection mechanisms.
If you use it, the flash driver doesn't know what filesystem or partition the locking affects.
The filesystem might think the flash is writable and suddenly it isn't.
The filesystem will get very confused, and write operations will start to fail.
Worse yet, if you lock a single block in a filesystem via
/dev/fs0, most of your writes will fail and suddenly stop working.
- -l limit
- Specify a size limit in bytes (default 2 GB) for the
partition specified by the preceding -p option.
The limit can include a suffix of k, K,
m, M, g, or G.
- -m
- Mount the filesystem partition specified by the preceding -p option.
The -m option doesn't work when you use the -o offset option.
You must restart the driver for the partition to be recognized.
- -n path
- Specify the filesystem mountpoint for the partition specified by the preceding -p option.
This option overrides any mountpoint specified with the mount attribute of the
mkefs
command.
- -o offset
- Specify the offset in bytes (default 0 bytes).
The offset can include a suffix of k, K,
m, M, g, or G.
- -p path
- Specify the raw mountpoint for the partition.
- -r
- Reclaim deleted blocks on the partition specified by the preceding
-p option, up to the limit specified by the -l option.
- -s num
- Specify the number of spare blocks (default 1) on the
partition specified by the preceding -p option.
- -U
- Unlock the raw partition specified by the preceding -p
option from the offset specified by the -o option through
to limit specified by -l option.
Note:
The
-U option fails if the partition (e.g.,
/dev/fs0p0) is mounted.
You can use /dev/fs0 to bypass the mounted
filesystem check, but we don't recommend that you do so.
- -u
- Unmount the filesystem partition specified by the preceding -p option.
- -v...
- Be verbose; more v characters cause more verbosity.
- -x
- Exit the driver.
- -z
- Query for the compression flag.
Description:
The flashctl utility is used to manage a flash filesystem.
The utility interacts with the flash filesystem driver using
devctl()
messages.
Using flashctl, you can erase and format a raw partition,
force a reclaim operation, and get information about flash filesystem
partitions.
Note:
- The options are processed in the order entered.
For example, you must erase (-e), format (-f),
and mount (-m) a partition in this order.
-
For now, use flashctl instead of mount and
umount to mount and unmount flash partitions.
The flashctl utility rounds the values of the -o and
-l (el) options down to the nearest block bound.
If the range specified exceeds the partition size, it's rounded down to fit.
If you use the -v option, flashctl displays
what the values have been rounded to.
Filesystem information
If you use the -i option, flashctl displays
information about the partition that you chose with the -p option;
the amount of information depends on what you chose
(the raw socket, raw partition, or formatted mounted filesystem):
- /dev/fs0 points to the entire socket, which means the
whole chip (or all physically contiguous chips).
This is the Array Info listed below.
- /dev/fs0pX refers to a partition, referred
to as a Part.
- The erase sectors on flash are referred to as Units.
Here's an example of the output:
Array Info
Total : 0x00800000 100%
Chip Size : 0x00800000 100%
Unit Size : 0x00020000 1%
Part Info
Total : 0x00800000 100%
Spare : 0x00020000 1%
Headers : 0x00001A34 0%
Padding : 0x00000000 0%
Overhead : 0x00021A34 1%
Free : 0x007DE5AC 98%
Stale : 0x00000000 0%
Avail. : 0x007DE5AC 98%
Reserved : 0x00000020 0%
Unit Info
Erase Stats
Average : 0
Minimum : 0
Maximum : 0
Total : 0
Here's how to interpret the output:
- Array Info
- The total amount of contiguous flash at the specified base address:
- Total — the size.
- Chip Size — the size of each chip if there are
multiple physical chips (they're assumed to all be the same size).
- Unit Size — the size of one sector, and the percentage of the total size.
- Part Info
- Information for the requested partition.
Sizes are given in bytes and as a percentage of the size of the partition; some fields might not be filled in:
- Total — the partition size.
- Spare — the amount of space used for spare blocks;
Spare/Unit Size gives the number of spare blocks.
- Headers — the space used for filesystem extent headers.
- Padding — the space used for alignment padding.
- Overhead — the total of Headers + Padding.
- Free — the amount of free space (no reclaim necessary).
- Stale — the amount of stale space.
- Avail. — the total amount of usable space; this is
the total of Free + Stale.
- Reserved — internal reserved space for unlinking, etc.
- Unit Info
- Information pertaining to individual sectors:
- Erase Stats — the average, minimum, maximum, and
total number of erasures performed within the specified partition.
Examples:
Create a flash filesystem between 1 MB and 3 MB in a 4 MB raw partition:
flashctl -p /dev/fs0p0 -o 1M -l 2M -e -f
Note:
This command line results in this organization:
- /dev/fs0p0
- A raw partition at 0–1 MB
- /dev/fs0p1
- A flash filesystem partition at 1–3 MB (mounted as /fs0p1)
- /dev/fs0p2
- A raw partition at 3–4 MB
Erase, format, and then mount (as /fs0p0) the flash filesystem
partition /dev/fs0p0:
flashctl -p /dev/fs0p0 -e -f -m
Mount the given flash filesystem partition as /flash:
flashctl -p /dev/fs0p0 -n /flash -m
Use the following command to format the range from 3 to 6 MB, if the layout is unknown:
flashctl -p /dev/fs0p0 -F -o 3m -l 6m -f
Note:
For
devf-ram
partitions only, you must format and erase a
partition before you can mount the flash filesystem.
Otherwise, you may get an error message
flashctl: mounting partition failed.
Caveats:
The mount facility (with the -m and -u options)
doesn't provide complete mount functionality, such
as read-only (mount -r) and special options
(mount -o).