Filesystem handling

Volume

class bootstrapvz.base.fs.volume.Volume(partition_map)

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)

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)

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)
Raises:PartitionError – In case a partition could not be mapped.
_before_unmap(event)
Raises:PartitionError – If the a partition cannot be unmapped
create(volume)

Creates the partition map

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

Returns the total size the partitions occupy

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

Returns whether the partition map is blocking volume detach operations

Return type:bool
map(volume)

Maps the partition map to device nodes

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

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)

Represents a GPT partition map

_before_create(event)

Creates the partition map

MS-DOS Partitionmap

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

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)

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()

Returns the total size the partitions occupy

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

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)

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

_after_mount(e)

Mount any mounts associated with this partition

_before_format(e)

Formats the partition

_before_mount(e)

Mount the partition

_before_unmount(e)

Unmount any mounts associated with this partition

add_mount(source, destination, opts=[])

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()

Gets the end of the partition

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

Gets the UUID of the partition

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

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)

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

_before_create(e)

Creates the partition

create(volume)

Creates the partition

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

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()

Gets the starting byte of this partition

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

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)

Represents a GPT partition

GPT swap partition

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

Represents a GPT swap partition

MS-DOS partition

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

Represents an MS-DOS partition

MS-DOS swap partition

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

Represents a MS-DOS swap partition

Single

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

Represents a single virtual partition on an unpartitioned volume

get_start()

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)

Represents an unformatted partition It cannot be mounted

Exceptions

exception bootstrapvz.base.fs.exceptions.PartitionError

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

exception bootstrapvz.base.fs.exceptions.VolumeError

Raised when an error occurs while interacting with the volume