diff --git a/src/include/partitioning/custom_part_check_generated.rb b/src/include/partitioning/custom_part_check_generated.rb index 8eaf8875a..14456de08 100644 --- a/src/include/partitioning/custom_part_check_generated.rb +++ b/src/include/partitioning/custom_part_check_generated.rb @@ -82,6 +82,7 @@ def check_created_partition_table(targetMap, installation) fat_system_mount = false fat_system_boot = false raid_type = "" + rootdlabel = "" Builtins.foreach(targetMap) do |disk, diskinfo| part_info = Ops.get_list(diskinfo, "partitions", []) @@ -117,6 +118,9 @@ def check_created_partition_table(targetMap, installation) end raid_type = Ops.get_string(part, "raid_type", "") if !boot_raid root_lvm = true if Ops.get_symbol(part, "type", :unknown) == :lvm + if diskinfo.fetch( "type", :CT_UNKNOWN ) == :CT_DISK + rootdlabel = diskinfo.fetch( "label", "" ) + end elsif mountpoint == Partitions.BootMount if (Partitions.EfiBoot || Arch.ia64) && Ops.get_string(diskinfo, "label", "gpt") != "gpt" @@ -189,9 +193,18 @@ def check_created_partition_table(targetMap, installation) end end end + if rootdlabel.empty? + targetMap.values do |diskinfo| + if diskinfo.fetch( "type", :CT_UNKNOWN ) == :CT_DISK && + rootdlabel.empty? + rootdlabel = diskinfo.fetch( "label", "" ) + end + end + end Builtins.y2milestone("diskless:%1", diskless) - Builtins.y2milestone("root_found:%1 root_fs:%2", root_found, root_fs) + Builtins.y2milestone("root_found:%1 root_fs:%2 rootdlabel:%3", + root_found, root_fs, rootdlabel) Builtins.y2milestone( "boot_found:%1 boot_fs:%2 boot_fsid:%3", boot_found, @@ -261,7 +274,7 @@ def check_created_partition_table(targetMap, installation) ok = false if !Popup.YesNo(message) end - if boot_found && installation || show_all_popups + if boot_found && boot_fsid!=Partitions.fsid_bios_grub && installation || show_all_popups if Ops.greater_or_equal(boot_end, Partitions.BootCyl) || show_all_popups # popup text, %1 is a number message = Builtins.sformat( @@ -300,6 +313,19 @@ def check_created_partition_table(targetMap, installation) end #/////////////////////////// NO BOOT /////////////////////////// + if (!boot_found && installation && + !Partitions.EfiBoot && rootdlabel=="gpt") || show_all_popups + message = _( + "Warning: There is no partition of type bios_grub present.\n" + + "To boot from a GPT disk using grub2 such a partition is needed.\n" + + "\n" + + "Really use this setup?\n" + ) + + ok = false if !Popup.YesNo(message) + # set it to true to avoid further possible boot warnings + boot_found = true + end if !boot_found && installation || show_all_popups # iSeries does not really need a boot partition diff --git a/src/modules/Storage.rb b/src/modules/Storage.rb index e3a7012ce..5e7bbaa21 100644 --- a/src/modules/Storage.rb +++ b/src/modules/Storage.rb @@ -6069,70 +6069,68 @@ def SpecialBootHandling(tg) tg = deep_copy(tg) have_ppc_boot = false Builtins.foreach(tg) do |dev, disk| - Builtins.foreach(Ops.get_list(disk, "partitions", [])) do |part| + disk.fetch("partitions",[]).each do |part| if !have_ppc_boot && - Ops.get_integer(part, "fsid", 0) == Partitions.fsid_prep_chrp_boot && - Builtins.size(Ops.get_string(part, "mount", "")) == 0 && - Ops.get_boolean(part, "create", false) + part.fetch("fsid",0) == Partitions.fsid_prep_chrp_boot && + part.fetch("mount","").empty? && + part.fetch("create",false) have_ppc_boot = true end end end - Builtins.y2milestone( - "SpecialBootHandling: have_ppc_boot:%1", - have_ppc_boot - ) + Builtins.y2milestone( "SpecialBootHandling: ppc_boot:%1", have_ppc_boot) Builtins.foreach(tg) do |dev, disk| new_part = [] - Builtins.foreach(Ops.get_list(disk, "partitions", [])) do |part| + disk.fetch("partitions",[]).each do |part| # convert a mount point of /boot to a 41 PReP boot partition if Partitions.PrepBoot && - Ops.get_string(part, "mount", "") == Partitions.BootMount && - !have_ppc_boot + part.fetch("mount","") == Partitions.BootMount && + !have_ppc_boot id = Partitions.fsid_prep_chrp_boot - Ops.set(part, "format", false) - Ops.set(part, "mount", "") - Ops.set(part, "fstype", Partitions.FsIdToString(id)) - Ops.set(part, "prep_install", true) - if !Ops.get_boolean(part, "create", false) && - Ops.get_integer(part, "fsid", 0) != id - Ops.set(part, "ori_fsid", Ops.get_integer(part, "fsid", 0)) - Ops.set(part, "change_fsid", true) + part["format"]=false + part["mount"]="" + part["fstype"]=Partitions.FsIdToString(id) + part["prep_install"]=true + if !part.fetch("create",false) && + part.fetch("fsid",0) != id + part["ori_fsid"] = part.fetch("fsid",0) + part["change_fsid"] = true end - Ops.set(part, "fsid", id) - Builtins.y2milestone( - "SpecialBootHandling modified Prep part=%1", - part - ) + part["fsid"] = id + Builtins.y2milestone( "SpecialBootHandling modified Prep part=%1", part) end if Arch.board_mac && - Ops.get_string(part, "mount", "") == Partitions.BootMount + part.fetch("mount","") == Partitions.BootMount id = Partitions.fsid_mac_hfs - Ops.set(part, "mount", "") - Ops.set(part, "fstype", Partitions.FsIdToString(id)) - Ops.set(part, "fsid", id) - Ops.set(part, "used_fs", :hfs) - Ops.set(part, "detected_fs", :hfs) - Builtins.y2milestone( - "SpecialBootHandling modified hfs part=%1", - part - ) + part["mount"] = "" + part["fstype"] = Partitions.FsIdToString(id) + part["fsid"] = id + part["used_fs"] = :hfs + part["detected_fs"] = :hfs + Builtins.y2milestone( "SpecialBootHandling modified hfs part=%1", part) end if Arch.ia64 && - Ops.get_string(part, "mount", "") == Partitions.BootMount + part.fetch("mount","") == Partitions.BootMount id = Partitions.fsid_gpt_boot - Ops.set(part, "fsid", id) - Ops.set(part, "fstype", Partitions.FsIdToString(id)) - if !Ops.get_boolean(part, "create", false) && - Ops.get_symbol(part, "detected_fs", :none) == :vfat - Ops.set(part, "format", false) + part["fsid"] = id + part["fstype"] = Partitions.FsIdToString(id) + if !part.fetch("create",false) && + part.fetch("detected_fs",:none)==:vfat + part["format"] = false end - Builtins.y2milestone( - "SpecialBootHandling modified GPT boot part=%1", - part - ) + Builtins.y2milestone( "SpecialBootHandling modified GPT boot part=%1", part) + end + if !Partitions.EfiBoot && (Arch.i386||Arch.x86_64) && + disk.fetch("label","") == "gpt" && + part.fetch("mount","") == Partitions.BootMount + id = Partitions.fsid_bios_grub + part["fsid"] = id + part["fstype"] = Partitions.FsIdToString(id) + part["format"] = false + part["mount"] = "" + Builtins.y2milestone( "SpecialBootHandling modified BIOS grub part=%1", part) end - new_part = Builtins.add(new_part, part) + new_part.push(part) end Ops.set(tg, [dev, "partitions"], new_part) end diff --git a/src/modules/StorageProposal.rb b/src/modules/StorageProposal.rb index 2eeb8cd51..74734e79f 100644 --- a/src/modules/StorageProposal.rb +++ b/src/modules/StorageProposal.rb @@ -604,71 +604,51 @@ def has_flex_proposal def need_boot(disk) - disk = deep_copy(disk) Builtins.y2milestone( "need_boot NeedBoot:%1 GetProposalBtrfs:%2 type:%3", Partitions.NeedBoot, GetProposalBtrfs(), - Ops.get_symbol(disk, "type", :CT_UNKNOWN) + disk.fetch("type",:CT_UNKNOWN) ) ret = Partitions.NeedBoot || - Ops.get_symbol(disk, "type", :CT_UNKNOWN) == :CT_DMRAID + disk.fetch("type",:CT_UNKNOWN) == :CT_DMRAID || + (disk.fetch("label","")=="gpt" && !Partitions.EfiBoot) Builtins.y2milestone("need_boot ret:%1", ret) ret end def try_add_boot(conf, disk, force) - conf = deep_copy(conf) - disk = deep_copy(disk) - boot = Ops.greater_than( - Builtins.size(Builtins.filter(Ops.get_list(conf, "partitions", [])) do |e| - Ops.get_string(e, "mount", "") == Partitions.BootMount - end), - 0 - ) - root = Ops.greater_than( - Builtins.size(Builtins.filter(Ops.get_list(conf, "partitions", [])) do |e| - Ops.get_string(e, "mount", "") == "/" - end), - 0 - ) + pl = conf.fetch("partitions", []) + boot = pl.index { |e| e.fetch("mount","")==Partitions.BootMount }!=nil + root = pl.index { |e| e.fetch("mount","")=="/" }!=nil tc = deep_copy(conf) Builtins.y2milestone("try_add_boot conf %1", conf) Builtins.y2milestone( "try_add_boot boot %1 root %2 force %3 need_boot:%4", - boot, - root, - force, - need_boot(disk) - ) + boot, root, force, need_boot(disk)) if !boot && (root || force) && - (Ops.greater_than( - Ops.get_integer(disk, "cyl_count", 0), - Partitions.BootCyl - ) || - need_boot(disk)) + disk.fetch("cyl_count",0)>Partitions.BootCyl || + need_boot(disk) pb = {} - Ops.set(pb, "mount", Partitions.BootMount) - Ops.set(pb, "size", Partitions.ProposedBootsize) - Ops.set(pb, "fsys", Partitions.DefaultBootFs) - Ops.set(pb, "id", Partitions.FsidBoot) - Ops.set(pb, "auto_added", true) - Ops.set(pb, "max_cyl", Partitions.BootCyl) - Ops.set(pb, "primary", Partitions.BootPrimary) - Ops.set(pb, "maxsize", Partitions.MaximalBootsize) - Ops.set( - tc, - "partitions", - Builtins.add(Ops.get_list(tc, "partitions", []), pb) - ) + pb["mount"] = Partitions.BootMount + pb["size"] = Partitions.ProposedBootsize + if disk.fetch("label","")=="gpt" && !Partitions.EfiBoot + sz = disk.fetch("cyl_size",0)-1024 + sz = 200*1024 if sz<200*1024 + pb["size"] = sz + end + pb["fsys"] = Partitions.DefaultBootFs + pb["id"] = Partitions.FsidBoot + pb["auto_added"] = true + pb["max_cyl"] = Partitions.BootCyl + pb["primary"] = Partitions.BootPrimary + pb["maxsize"] = Partitions.MaximalBootsize + tc["partitions"].push( pb ) Builtins.y2milestone( "try_add_boot disk_cyl %1 boot_cyl %2 need_boot %3 typ %4", - Ops.get_integer(disk, "cyl_count", 0), - Partitions.BootCyl, - Partitions.NeedBoot, - Ops.get_symbol(disk, "type", :CT_UNKNOWN) - ) + disk.fetch("cyl_count",0), Partitions.BootCyl, + Partitions.NeedBoot, disk.fetch("type",:CT_UNKNOWN)) Builtins.y2milestone("try_add_boot boot added automagically pb %1", pb) end deep_copy(tc) @@ -3592,55 +3572,44 @@ def can_swap_reuse(disk, partitions, tgmap) def can_boot_reuse(disk, label, boot, max_prim, partitions) - partitions = deep_copy(partitions) ret = [] Builtins.y2milestone("can_boot_reuse boot:%1", boot) if boot && !Partitions.PrepBoot Builtins.y2milestone( "can_boot_reuse disk:%1 max_prim:%2 label:%3 part:%4", - disk, - max_prim, - label, - partitions - ) - pl = [] - pl = Builtins.filter(partitions) do |p| - !Ops.get_boolean(p, "delete", false) && - Ops.greater_or_equal( - Ops.multiply(Ops.get_integer(p, "size_k", 0), 1024), - Partitions.MinimalBootsize - ) + disk, max_prim, label, partitions) + pl = partitions.select do |p| + !p.fetch("delete",false) && + (p.fetch("size_k",0)*1024>=Partitions.MinimalBootsize|| + p.fetch("fsid",0)==Partitions.fsid_bios_grub) end + Builtins.y2milestone( "can_boot_reuse pl:%1", pl ) boot2 = Builtins.find(pl) do |p| - Ops.get_integer(p, "fsid", 0) == Partitions.fsid_gpt_boot || - Ops.get_integer(p, "fsid", 0) == Partitions.FsidBoot && - Ops.less_or_equal( - Ops.multiply(Ops.get_integer(p, "size_k", 0), 1024), - Partitions.MaximalBootsize - ) || - Ops.get_symbol(p, "detected_fs", :unknown) == :hfs && - Ops.get_boolean(p, "boot", false) && - label == "mac" || - Ops.get_integer(p, "fsid", 0) == Partitions.fsid_prep_chrp_boot && - Ops.less_or_equal(Ops.get_integer(p, "nr", 0), max_prim) && - Partitions.PrepBoot - end - ret = Builtins.maplist(partitions) do |p| - if !Ops.get_boolean(p, "delete", false) && - Ops.get_string(p, "device", "") == - Ops.get_string(boot2, "device", "") && - Storage.CanEdit(p, false) - p = Storage.SetVolOptions( - p, - Partitions.BootMount, - Partitions.DefaultBootFs, - "", - "", - "" - ) - end - deep_copy(p) - end if boot2 != nil + p.fetch("fsid",0) == Partitions.fsid_gpt_boot || + p.fetch("fsid",0) == Partitions.FsidBoot && + p.fetch("size_k",0)*1024<=Partitions.MaximalBootsize || + p.fetch("detected_fs",:unknown) == :hfs && + p.fetch("boot",false) && + label == "mac" || + p.fetch("fsid",0) == Partitions.fsid_prep_chrp_boot && + p.fetch("nr",0)<=max_prim && + Partitions.PrepBoot || + p.fetch("fsid",0) == Partitions.fsid_bios_grub && + label=="gpt" && + !Partitions.EfiBoot + end + Builtins.y2milestone("can_boot_reuse boot2:%1", boot2) + if boot2 != nil + ret = partitions.map do |p| + if !p.fetch("delete",false) && + p.fetch("device","") == boot2.fetch("device","") && + Storage.CanEdit(p, false) + p = Storage.SetVolOptions( p, Partitions.BootMount, + Partitions.DefaultBootFs, "", "", "") + end + p + end + end Builtins.y2milestone("can_boot_reuse ret:%1", ret) end deep_copy(ret) @@ -4119,7 +4088,8 @@ def prepare_part_lists(ddev, tg) Partitions.fsid_native, Partitions.fsid_swap, Partitions.fsid_lvm, - Partitions.fsid_raid + Partitions.fsid_raid, + Partitions.fsid_bios_grub ] remk = ["del_ptable", "disklabel"] Builtins.foreach(ddev) do |s|