Skip to content

Commit

Permalink
fix bootloader device by label for disks (bsc#1009493)
Browse files Browse the repository at this point in the history
  • Loading branch information
jreidinger committed Nov 11, 2016
1 parent 973b911 commit 3ed504e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/lib/bootloader/udev_mapping.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ def to_mountby_device(dev)
# explicit request to mount by kernel device
return kernel_dev if mount_by == :device

disk = Yast::Storage.GetTargetMap.key?(kernel_dev)
if disk && mount_by == :label
log.info "mount be label for disk, so using kernel device as fallback"
return kernel_dev
end

udev_data_key = MOUNT_BY_MAPPING_TO_UDEV[mount_by]
raise "Internal error unknown mountby #{mount_by}" unless udev_data_key
udev_pair = map_device_to_udev_devices(
Expand Down
7 changes: 7 additions & 0 deletions test/udev_mapping_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,13 @@
expect(subject.to_mountby_device("/dev/vda1")).to eq "/dev/vda1"
end

it "returns kernel device if mount by is used by label" do
target_map_stub("storage_dm.yaml")
expect(Yast::Storage).to receive(:GetDefaultMountBy).and_return(:label)

expect(subject.to_mountby_device("/dev/sda")).to eq "/dev/sda"
end

it "returns its name if partition do not exists" do
target_map_stub("storage_lvm.yaml")
allow(Yast::Storage).to receive(:GetDefaultMountBy).and_return(:uuid)
Expand Down

0 comments on commit 3ed504e

Please sign in to comment.