Skip to content

LinuxAdmin::Disk.create_partition causes parted to exit with a 1 #98

@twiest

Description

@twiest

I get an error when I try to create a partition like this:

irb> require 'linux_admin'
=> true

irb> disk = LinuxAdmin::Disk.new(:path => '/dev/xvdp')
=> #<LinuxAdmin::Disk:0x00000001f64108 @path="/dev/xvdp">

irb> disk.create_partition('primary', 1024)
CommandResultError: /sbin/parted exit code: 1
    from /opt/rh/ruby193/root/usr/share/gems/gems/linux_admin-0.7.0/lib/linux_admin/common.rb:41:in `run!'
    from /opt/rh/ruby193/root/usr/share/gems/gems/linux_admin-0.7.0/lib/linux_admin/disk.rb:156:in `create_partition'
    from (irb):3
    from /opt/rh/ruby193/root/usr/bin/irb:12:in `<main>'

irb>

I've tracked this down to this line in disk.rb:
options = parted_options_array('mkpart', '-a opt', partition_type, start, finish)

It should be:
options = parted_options_array('mkpart', '-a', 'opt', partition_type, start, finish)

'-a opt' all together makes the parted command look like this (the slash is the problem):
/sbin/parted --script /dev/xvdp mkpart -a\ opt primary 0 1024

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions