':param job: A L{client.job} instance.
:param device: The device in question (e.g."/dev/hda2"). If device is a
file it will be mounted as loopback. If you have job config
\'partition.partitions\', e.g.,
job.config_set(\'partition.partitions\', ["/dev/sda2", "/dev/sda3"])
you may specify a partition in the form of "partN" e.g. "part0",
"part1" to refer to elements of the partition list. This is
specially useful if you run a test in various machines and you
don\'t want to hardcode device names as those may vary.
:param loop_size: Size of loopback device (in MB). Defaults to 0.'

def __init__(self, job, device, loop_size=0, mountpoint=None):

    part = re.compile('^part(\\d+)$')
    m = part.match(device)
    if m:
        number = int(m.groups()[0])
        partitions = job.config_get('partition.partitions')
        try:
            device = partitions[number]
        except Exception:
            raise NameError((("Partition    '" + device) + "'    not    available"))
    self.device = device
    self.name = os.path.basename(device)
    self.job = job
    self.loop = loop_size
    self.fstype = None
    self.mountpoint = mountpoint
    self.mkfs_flags = None
    self.mount_options = None
    self.fs_tag = None
    if self.loop:
        cmd = ('dd    if=/dev/zero    of=%s    bs=1M    count=%d' % (device, loop_size))
        utils.system(cmd)
