def sd_part_size(partition):
    """Return SD partition size in bytes

    :param partition: device
    :type partition: string, e.g. "sda"
    :return: partition size in bytes
    :rtype: int
    """
    try:
        device_path = '/sys/block/'
        device = partition[:-1]
        num_sectors = open(device_path + device + '/' + partition + '/size'
            ).read().rstrip('\n')
        sector_size = open(device_path + device + '/queue/hw_sector_size'
            ).read().rstrip('\n')
    except TypeError:
        print('Not enough USB devices available')
        exit(1)
    else:
        return int(num_sectors) * int(sector_size)
