Filesystem handling

Volume

class bootstrapvz.base.fs.volume.Volume(partition_map)[source]

Represents an abstract volume. This class is a finite state machine and represents the state of the real volume.

Links the volume using the device mapper This allows us to create a ‘window’ into the volume that acts like a volume in itself. Mainly it is used to fool grub into thinking that it is working with a real volume, rather than a loopback device or a network block device.

Parameters:e (_e_obj) – Event object containing arguments to create()

Keyword arguments to link_dm_node() are:

Parameters:
  • logical_start_sector (int) – The sector the volume should start at in the new volume
  • start_sector (int) – The offset at which the volume should begin to be mapped in the new volume
  • sectors (int) – The number of sectors that should be mapped

Read more at: http://manpages.debian.org/cgi-bin/man.cgi?query=dmsetup&apropos=0&sektion=0&manpath=Debian+7.0+wheezy&format=html&locale=en

Raises:VolumeError – When a free block device cannot be found.

Unlinks the device mapping

_check_blocking(e)[source]

Checks whether the volume is blocked

Raises:VolumeError – When the volume is blocked from being detached

Partitionmaps

Abstract Partitionmap

class bootstrapvz.base.fs.partitionmaps.abstract.AbstractPartitionMap(bootloader)[source]

Abstract representation of a partiton map This class is a finite state machine and represents the state of the real partition map

_before_map(event)[source]
Raises:PartitionError – In case a partition could not be mapped.
_before_unmap(event)[source]
Raises:PartitionError – If the a partition cannot be unmapped
create(volume)[source]

Creates the partition map

Parameters:volume (Volume) – The volume to create the partition map on
get_total_size()[source]

Returns the total size the partitions occupy

Returns:The size of all partitions
Return type:Sectors
is_blocking()[source]

Returns whether the partition map is blocking volume detach operations

Return type:bool
map(volume)[source]

Maps the partition map to device nodes

Parameters:volume (Volume) – The volume the partition map resides on
unmap(volume)[source]

Unmaps the partition

Parameters:volume (Volume) – The volume to unmap the partition map from

GPT Partitionmap

class bootstrapvz.base.fs.partitionmaps.gpt.GPTPartitionMap(data, sector_size, bootloader)[source]

Represents a GPT partition map

_before_create(event)[source]

Creates the partition map

MS-DOS Partitionmap

class bootstrapvz.base.fs.partitionmaps.msdos.MSDOSPartitionMap(data, sector_size, bootloader)[source]

Represents a MS-DOS partition map Sometimes also called MBR (but that confuses the hell out of me, so ms-dos it is)

No Partitionmap

class bootstrapvz.base.fs.partitionmaps.none.NoPartitions(data, sector_size, bootloader)[source]

Represents a virtual ‘NoPartitions’ partitionmap. This virtual partition map exists because it is easier for tasks to simply always deal with partition maps and then let the base abstract that away.

get_total_size()[source]

Returns the total size the partitions occupy

Returns:The size of all the partitions
Return type:Sectors
is_blocking()[source]

Returns whether the partition map is blocking volume detach operations

Return type:bool

Partitions

Abstract partition

class bootstrapvz.base.fs.partitions.abstract.AbstractPartition(size, filesystem, format_command, mountopts)[source]

Abstract representation of a partiton This class is a finite state machine and represents the state of the real partition

_after_mount(e)[source]

Mount any mounts associated with this partition

_before_format(e)[source]

Formats the partition

_before_mount(e)[source]

Mount the partition

_before_unmount(e)[source]

Unmount any mounts associated with this partition

add_mount(source, destination, opts=[])[source]

Associate a mount with this partition Automatically mounts it

Parameters:
  • source (str,AbstractPartition) – The source of the mount
  • destination (str) – The path to the mountpoint
  • opts (list) – Any options that should be passed to the mount command
get_end()[source]

Gets the end of the partition

Returns:The end of the partition
Return type:Sectors
get_uuid()[source]

Gets the UUID of the partition

Returns:The UUID of the partition
Return type:str
remove_mount(destination)[source]

Remove a mount from this partition Automatically unmounts it

Parameters:destination (str) – The mountpoint path of the mount that should be removed

Base partition

class bootstrapvz.base.fs.partitions.base.BasePartition(size, filesystem, format_command, mountopts, previous)[source]

Represents a partition that is actually a partition (and not a virtual one like ‘Single’)

_before_create(e)[source]

Creates the partition

create(volume)[source]

Creates the partition

Parameters:volume (Volume) – The volume to create the partition on
get_index()[source]

Gets the index of this partition in the partition map

Returns:The index of the partition in the partition map
Return type:int
get_start()[source]

Gets the starting byte of this partition

Returns:The starting byte of this partition
Return type:Sectors
map(device_path)[source]

Maps the partition to a device_path

Parameters:device_path (str) – The device path this partition should be mapped to

GPT partition

class bootstrapvz.base.fs.partitions.gpt.GPTPartition(size, filesystem, format_command, mountopts, name, previous)[source]

Represents a GPT partition

_before_create(e)[source]

Creates the partition

GPT swap partition

class bootstrapvz.base.fs.partitions.gpt_swap.GPTSwapPartition(size, previous)[source]

Represents a GPT swap partition

_before_format(e)[source]

Formats the partition

MS-DOS partition

class bootstrapvz.base.fs.partitions.msdos.MSDOSPartition(size, filesystem, format_command, mountopts, name, previous)[source]

Represents an MS-DOS partition

MS-DOS swap partition

class bootstrapvz.base.fs.partitions.msdos_swap.MSDOSSwapPartition(size, previous)[source]

Represents a MS-DOS swap partition

_before_format(e)[source]

Formats the partition

Single

class bootstrapvz.base.fs.partitions.single.SinglePartition(size, filesystem, format_command, mountopts)[source]

Represents a single virtual partition on an unpartitioned volume

get_start()[source]

Gets the starting byte of this partition

Returns:The starting byte of this partition
Return type:Sectors

Unformatted partition

class bootstrapvz.base.fs.partitions.unformatted.UnformattedPartition(size, previous)[source]

Represents an unformatted partition It cannot be mounted

Exceptions

exception bootstrapvz.base.fs.exceptions.PartitionError[source]

Raised when an error occurs while interacting with the partitions on the volume

exception bootstrapvz.base.fs.exceptions.VolumeError[source]

Raised when an error occurs while interacting with the volume