Class: Yast::BootSupportCheckClass

Inherits:
Module
  • Object
show all
Defined in:
../../src/modules/BootSupportCheck.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) AddNewProblem(description)

Add a new problem description to the list of found problems



38
39
40
41
42
# File '../../src/modules/BootSupportCheck.rb', line 38

def AddNewProblem(description)
  @detected_problems = Builtins.add(@detected_problems, description)

  nil
end

- (Object) check_BootDevice



172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
# File '../../src/modules/BootSupportCheck.rb', line 172

def check_BootDevice
  result = true
  boot_device = ""

  devices = Storage.GetTargetMap

  boot_device = BootCommon.getBootPartition

  boot_disk = BootCommon.getBootDisk
  # if (BootStorage::BootPartitionDevice == BootStorage::RootPartitionDevice)
  # AddNewProblem (_("Doesn't exist separete /boot partition"));

  found_boot = false
  # check if boot device is on raid0
  Builtins.foreach(devices) do |k, v|
    # check if boot disk is iscsi disk
    # bnc#393928: Installing root system on iscsi disk makes the system useless
    if k == boot_disk
      # if "iscsi" is true
      if Ops.get_boolean(v, "iscsi", false)
        AddNewProblem(
          Builtins.sformat(
            _("The boot device is on iSCSI disk: %1. System may not boot."),
            k
          )
        )
        Builtins.y2error(
          "The boot partition: %1 is on iscsi disk: %2",
          boot_device,
          k
        )
        result = false
      end
    end
    Builtins.foreach(Ops.get_list(v, "partitions", [])) do |p|
      if Ops.get_string(p, "device", "") == boot_device
        if Ops.get_string(p, "raid_type", "") != "raid1" &&
            Ops.get(p, "type") == :sw_raid
          AddNewProblem(
            Builtins.sformat(
              _(
                "The boot device is on raid type: %1. System will not boot."
              ),
              Ops.get_string(p, "raid_type", "")
            )
          )
          Builtins.y2error(
            "The boot device: %1 is on raid type: %2",
            boot_device,
            Ops.get_string(p, "raid_type", "")
          )
          result = false
          raise Break
        else
          # bnc#501043 added check for valid configuration
          if Ops.get_string(p, "raid_type", "") == "raid1" &&
              Ops.get(p, "type") == :sw_raid
            if Builtins.tolower(Ops.get_string(p, "fstype", "")) == "md raid" &&
                Ops.get(BootCommon.globals, "boot_mbr", "false") != "true"
              AddNewProblem(
                _(
                  "The boot device is on software RAID1. Select other bootloader location, e.g. Master Boot Record"
                )
              )
              Builtins.y2error(
                "Booting from soft-raid: %1 and bootloader setting are not valid: %2",
                p,
                BootCommon.globals
              )
              result = false
              raise Break
            else
              found_boot = true
              Builtins.y2milestone("Valid configuration for soft-raid")
            end
          else
            found_boot = true
            Builtins.y2milestone(
              "The boot device: %1 is on raid: %2",
              boot_device,
              Ops.get_string(p, "raid_type", "")
            )
          end
        end
        if Ops.get(p, "used_fs") == :xfs
          AddNewProblem(
            _(
              "The /boot directory is on an XFS filesystem. System may not boot."
            )
          )
          Builtins.y2error("The /boot directory is on an XFS filesystem")
          result = false
          raise Break
        else
          found_boot = true
          Builtins.y2milestone("/boot filesystem is OK")
          raise Break
        end
      end
    end
    raise Break if !result || found_boot
  end if boot_device != ""
  result
end

- (Boolean) CheckBios_ID

Check if there is bios_id if not show warning

Returns:

  • (Boolean)

    true on success



282
283
284
285
286
287
288
289
290
291
292
293
# File '../../src/modules/BootSupportCheck.rb', line 282

def CheckBios_ID
  ret = true
  if BootStorage.bois_id_missing
    AddNewProblem(
      _(
        "It was not possible to determine the exact order of disks for device map. The order of disks can be changed in \"Boot Loader Installation Details\""
      )
    )
    ret = false
  end
  ret
end

- (Object) checkElilo

Check if elilo is supported



91
92
93
94
95
96
97
98
99
100
# File '../../src/modules/BootSupportCheck.rb', line 91

def checkElilo
  cmd = "modprobe efivars 2>/dev/null"
  ret = Convert.to_map(SCR.Execute(path(".target.bash_output"), cmd))
  # bnc#581213 - x86-64/UEFI: "Unsupported combination of hardware platform x86_64 and bootloader elilo"
  if FileUtils.Exists("/sys/firmware/efi/systab")
    return true
  else
    return false
  end
end

- (Object) CorrectLoaderType

Check that bootloader matches current hardware



105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# File '../../src/modules/BootSupportCheck.rb', line 105

def CorrectLoaderType
  lt = Bootloader.getLoaderType
  return true if lt == "none"

  return true if Arch.s390 && lt == "zipl"
  return true if Arch.ppc && lt == "ppc"
  return true if Arch.ia64 && lt == "elilo"
  if Arch.i386 || Arch.x86_64
    if checkElilo
      return true if lt == "elilo" || lt == "grub2-efi"
    else
      return true if lt == "grub" || lt == "lilo" || lt == "grub2"
    end
  end
  Builtins.y2error(
    "Unsupported combination of hardware platform %1 and bootloader %2",
    Arch.architecture,
    lt
  )
  AddNewProblem(
    Builtins.sformat(
      _("Unsupported combination of hardware platform %1 and bootloader %2"),
      Arch.architecture,
      lt
    )
  )
  false
end

- (Boolean) DetectedProblems

List detected problems Always run SystemSupported before calling this function

Returns:

  • (Boolean)

    a list of problems, empty if no was found



47
48
49
# File '../../src/modules/BootSupportCheck.rb', line 47

def DetectedProblems
  deep_copy(@detected_problems)
end

- (Object) ELILO

ELILO related check



320
321
322
# File '../../src/modules/BootSupportCheck.rb', line 320

def ELILO
  true
end

- (Object) EndOfBootOrRootPartition



373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
# File '../../src/modules/BootSupportCheck.rb', line 373

def EndOfBootOrRootPartition
  part = Storage.GetEntryForMountpoint("/boot")
  part = Storage.GetEntryForMountpoint("/") if Builtins.isempty(part)

  device = Ops.get_string(part, "device", "")
  Builtins.y2milestone("device:%1", device)

  end_cyl = Region.End(Ops.get_list(part, "region", []))

  cyl_size = 82252800
  target_map = Storage.GetTargetMap
  Builtins.foreach(target_map) do |dev, disk|
    if Builtins.find(Ops.get_list(disk, "partitions", [])) do |p|
        Ops.get_string(p, "device", "") == device
      end != nil
      cyl_size = Ops.get_integer(disk, "cyl_size", 82252800)
    end
  end

  ret = Ops.multiply(end_cyl, cyl_size)

  Builtins.y2milestone(
    "end_cyl:%1 cyl_size:%2 end:%3",
    end_cyl,
    cyl_size,
    ret
  )
  ret
end

- (Object) GptPartitionTable

  • Checks for GPT partition table // FIXME adapt for ELILO if needed



136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
# File '../../src/modules/BootSupportCheck.rb', line 136

def GptPartitionTable
  ret = true
  tm = Storage.GetTargetMap
  devices = [BootStorage.BootPartitionDevice]
  # TODO add more devices
  Builtins.foreach(devices) do |dev|
    p_dev = Storage.GetDiskPartition(dev)
    num = BootCommon.myToInteger(Ops.get(p_dev, "nr"))
    mbr_dev = Ops.get_string(p_dev, "disk", "")
    label = Ops.get_string(tm, [mbr_dev, "label"], "")
    Builtins.y2milestone("Label: %1", label)
    Builtins.y2milestone("Partition number: %1", num)
    if label == "gpt"
      if Ops.greater_than(num, 3)
        Builtins.y2error(
          "Partition number > 3 is being used for booting with GPT partition table"
        )
        AddNewProblem(
          _(
            "Partition number > 3 is being used for booting with GPT partition table"
          )
        )
        ret = false
      end
    end
  end
  ret
end

- (Object) GRUB

GRUB-related check



302
303
304
305
306
307
# File '../../src/modules/BootSupportCheck.rb', line 302

def GRUB
  ret = GptPartitionTable()
  ret = check_BootDevice if ret
  ret = CheckBios_ID() if ret
  ret
end

- (Object) GRUB2

GRUB2-related check



310
311
312
# File '../../src/modules/BootSupportCheck.rb', line 310

def GRUB2
  GRUB()
end

- (Object) GRUB2EFI

GRUB2EFI-related check



315
316
317
# File '../../src/modules/BootSupportCheck.rb', line 315

def GRUB2EFI
  true
end

- (Object) KnownLoader

Check that bootloader is known and supported



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File '../../src/modules/BootSupportCheck.rb', line 68

def KnownLoader
  if !Builtins.contains(
      ["grub", "grub2", "grub2-efi", "elilo", "ppc", "zipl", "none"],
      Bootloader.getLoaderType
    )
    if Bootloader.getLoaderType != "lilo"
      Builtins.y2error("Unknown bootloader: %1", Bootloader.getLoaderType)
      AddNewProblem(
        Builtins.sformat(
          _("Unknown bootloader: %1"),
          Bootloader.getLoaderType
        )
      )
    else
      Builtins.y2error("LILO bootloader: %1", Bootloader.getLoaderType)
      AddNewProblem(_("LILO bootloader is not supported"))
    end
    return false
  end
  true
end

- (Object) main



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File '../../src/modules/BootSupportCheck.rb', line 21

def main

  textdomain "bootloader"

  Yast.import "Bootloader"
  Yast.import "Arch"
  Yast.import "Storage"
  Yast.import "Region"
  Yast.import "BootCommon"
  Yast.import "BootStorage"
  Yast.import "FileUtils"

  # List of problems found during last check
  @detected_problems = []
end

- (Object) PPC

PPC related check



330
331
332
# File '../../src/modules/BootSupportCheck.rb', line 330

def PPC
  true
end

- (Object) RootPartition

Check that the root partition is reachable



297
298
299
# File '../../src/modules/BootSupportCheck.rb', line 297

def RootPartition
  true
end

- (Boolean) StringProblems

Formated string of detected problems Always run SystemSupported before calling this function

Returns:

  • (Boolean)

    a list of problems, empty if no was found



55
56
57
58
59
60
61
62
63
64
# File '../../src/modules/BootSupportCheck.rb', line 55

def StringProblems
  ret = ""
  if Ops.greater_than(Builtins.size(@detected_problems), 0)
    Builtins.foreach(@detected_problems) do |s|
      ret = Ops.add(Ops.add(ret, s), "\n")
    end
  end

  ret
end

- (Boolean) SystemSupported

Check if the system configuraiton is supported Also sets the founds problems into internal variable Always run this function before calling DetectedProblems()

Returns:

  • (Boolean)

    true if supported



338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
# File '../../src/modules/BootSupportCheck.rb', line 338

def SystemSupported
  @detected_problems = []

  # check if the bootloader is known and supported
  supported = KnownLoader()

  lt = Bootloader.getLoaderType
  return true if lt == "none"

  # detect correct bootloader type
  supported = CorrectLoaderType() && supported

  # check whether root partition can be reached
  supported = RootPartition() && supported

  # check specifics for individual loaders
  if lt == "grub"
    supported = GRUB() && supported
  elsif lt == "elilo"
    supported = ELILO() && supported
  elsif lt == "ppc"
    supported = PPC() && supported
  elsif lt == "zipl"
    supported = ZIPL() && supported
  elsif lt == "grub2"
    supported = GRUB2() && supported
  elsif lt == "grub2-efi"
    supported = GRUB2EFI() && supported
  end

  Builtins.y2milestone("Configuration supported: %1", supported)
  supported
end

- (Object) ZIPL

ZIPL related check



325
326
327
# File '../../src/modules/BootSupportCheck.rb', line 325

def ZIPL
  true
end