While imount
heavily utilizes the Python API of imagemounter
, this API is also available for other classes.
The basic structure of imagemounter
is the imagemounter.ImageParser
class, which provides access to underlying imagemounter.Disk
and imagemounter.Volume
objects. Each file name passed to a new imagemounter.ImageParser
object results in one imagemounter.Disk
object. imagemounter.Volume
objects are created by analysis of the Disk
object (each volume generates one object, even if it is not mountable), and each imagemounter.Volume
can have one or more subvolumes.
For instance, a LUKS volume may contain a LVM system that contains a Ext volume. This would create a Disk
with a Volume
containing a Volume
which contains the actual Ext Volume
.
Most operations are managed on a Volume
level, although RAIDs (and volume detection) are managed on a Disk
level and reconstruction is performed on a ImageParser
level. This means the following main parts make up the Python package:
imagemounter.ImageParser
, maintaining a list of Disks, providing several methods that are carried out on all disks (e.g. mount) and reconstruct.imagemounter.Disk
, which represents a single disk iamge and can be mounted, added to RAID, and detect and maintain volumes. It is also responsible for maintaining the write cache.imagemounter.Volume
, which can detect its own type and fill its stats, can be mounted, and detect LVM (sub)volumes.
All three classes maintain an init()
method that yields the volumes below it. You should call clean()
on the parser as soon as you are done; you may also call unmount()
on separate volumes or disks, which will also unmount all volumes below it. Warning: unmounting one of the RAID volumes in a RAID array, causes the entire array to be unmounted.
imagemounter
If you utilize the API, you typically only require the ImageParser
object, e.g.:
parser = ImageParser(['/path/to/disk'])
for v in parser.init():
print v.size
root = parser.reconstruct()
print root.mountpoint
parser.clean()
The best example of the use of the Python interface is the imount
command. The entirety of all methods and attributes is documented below.
ImageParser
init
reconstruct
clean
force_clean
Most methods above, especially init
, handle most complicated tasks. However, you may need some more fine-grained control over the mount process, which may require you to use the following methods. Each of these methods passes their activities down to all disks in the parser and return whether it succeeded.
rw_active
get_volumes
mount_disks
mount_raid
mount_single_volume
mount_multiple_volumes
mount_volumes
For completeness, this is a list of all attributes of ImageParser
:
disks
List of all Disk
objects.
paths out verbose verbose_color args
See the constructor of ImageParser
.
Disk
init
unmount
The following methods are only required if you want some fine-grained control, typically if you are not using init
.
rw_active
get_fs_path
get_raw_path
get_volumes
mount
mount_volumes
mount_multiple_volumes
mount_single_volume
is_raid
add_to_raid
The following attributes are also available:
name
Pretty name of the disk.
index
Disk index. May be None if it is the only disk of this type.
mountpoint
The mountpoint of the disk, after a call to mount
.
rwpath
The path to the read-write cache, filled after a call to mount
.
volumes
List of all direct child volumes of this disk, excluding all subvolumes. See get_volumes
.
volume_source
The source of the volumes of this disk, either single or multi, filled after a call to mount_volumes
.
loopback md_device
Used for RAID support.
parser path offset vstype read_write method detection multifile args
See the constructor of Disk
.
Volume
init
unmount
The following methods offer some more information about the volume:
get_description
get_safe_label
get_size_gib
get_volumes
These functions offer access to some internals:
get_fs_type
get_raw_base_path
mount
bindmount
fill_stats
detect_mountpoint
find_lvm_volumes
open_luks_container
The following details may also be available as attributes:
size
The size of the volume in bytes.
offset
The offset of the volume in the disk in bytes.
index
The index of the volume in the disk. If there are subvolumes, the index is separated by periods, though the exact format depends on the detection method and its format.
flag
Indicates whether this volume is allocated (alloc), unallocated (unalloc) or a meta volume (meta).
fsdescription
A description of the file system type.
lastmountpoint
The last mountpoint of this volume. Set by fill_stats
or detect_mountpoint
and only available for UFS and Ext volumes.
label
The volume label as detected by fill_stats
.
version
The volume version as detected by fill_stats
.
fstype
The volume file system type as detected by fill_stats
.
mountpoint
The mountpoint of the volume after mount
has been called.
bindmountpoint
The mountpoint of the volume after bindmount
has been called.
loopback
The loopback device used by the volume after mount
(or related methods) has been called.
exception
Contains an exception that occurred during a call to mount
.
was_mounted
Boolean indicating that the volume has successfully been mounted during its lifetime.
volumes parent
volumes
contains a list of all subvolumes of this volume; parent
contains the parent volume (if any).
volume_group lv_path
Attributes used for LVM support
luks_path
Attribute used for LUKS support
disk stats fsforce fsfallback fstypes pretty mountdir args
See the constructor of Volume
.