in azurelinuxagent/daemon/resourcedisk/openbsd.py [0:0]
def mount_resource_disk(self, mount_point):
fs = self.fs
if fs != 'ffs':
raise ResourceDiskError("Unsupported filesystem type: {0}, only "
"ufs/ffs is supported.".format(fs))
# 1. Get device
device = self.osutil.device_for_ide_port(1)
if not device:
raise ResourceDiskError("Unable to detect resource disk device.")
logger.info('Resource disk device {0} found.', device)
# 2. Get partition
partition = "/dev/{0}a".format(device)
# 3. Mount partition
mount_list = shellutil.run_get_output("mount")[1]
existing = self.osutil.get_mount_point(mount_list, partition)
if existing:
logger.info("Resource disk {0} is already mounted", partition)
return existing
fileutil.mkdir(mount_point, mode=0o755)
mount_cmd = 'mount -t {0} {1} {2}'.format(self.fs,
partition, mount_point)
err = shellutil.run(mount_cmd, chk_err=False)
if err:
logger.info('Creating {0} filesystem on {1}'.format(fs, device))
fdisk_cmd = "/sbin/fdisk -yi {0}".format(device)
err, output = shellutil.run_get_output(fdisk_cmd, chk_err=False)
if err:
raise ResourceDiskError("Failed to create new MBR on {0}, "
"error: {1}".format(device, output))
size_mb = conf.get_resourcedisk_swap_size_mb()
if size_mb:
if size_mb > 512 * 1024:
size_mb = 512 * 1024
disklabel_cmd = ("echo -e '{0} 1G-* 50%\nswap 1-{1}M 50%' "
"| disklabel -w -A -T /dev/stdin "
"{2}").format(mount_point, size_mb, device)
ret, output = shellutil.run_get_output(
disklabel_cmd, chk_err=False)
if ret:
raise ResourceDiskError("Failed to create new disklabel "
"on {0}, error "
"{1}".format(device, output))
err, output = shellutil.run_get_output("newfs -O2 {0}a"
"".format(device))
if err:
raise ResourceDiskError("Failed to create new filesystem on "
"partition {0}, error "
"{1}".format(partition, output))
err, output = shellutil.run_get_output(mount_cmd, chk_err=False)
if err:
raise ResourceDiskError("Failed to mount partition {0}, "
"error {1}".format(partition, output))
logger.info("Resource disk partition {0} is mounted at {1} with fstype "
"{2}", partition, mount_point, fs)
return mount_point