Skip to content
This repository has been archived by the owner on May 22, 2019. It is now read-only.

Commit

Permalink
check generated grub.cfg for correct root UUID and fix if necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
lots0logs committed May 13, 2014
1 parent 83649b1 commit b3c7c1f
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions src/installation/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -940,19 +940,20 @@ def auto_fstab(self):
else:
for i in self.ssd:
if i in self.mount_devices[path]:
opts = 'defaults,relatime'
opts = 'rw,defaults,noatime'
# As of linux kernel version 3.7, the following
# filesystems support TRIM: ext4, btrfs, JFS, and XFS.
# If using a TRIM supported SSD, discard is a valid mount option for swap
if myfmt == 'ext4' or myfmt == 'jfs' or myfmt == 'xfs' or myfmt == 'swap':
opts += ',discard'
elif myfmt == 'btrfs':
opts += ',rw,compress=lzo,ssd,discard,space_cache,autodefrag,inode_cache'
opts += ',compress=lzo,ssd,discard,space_cache,autodefrag,inode_cache'

no_check = ["btrfs", "f2fs"]
if path == "/" and myfmt not in no_check:
chk = '1'

if path == "/":
self.settings.set('ruuid', uuid)
all_lines.append("UUID=%s %s %s %s 0 %s" % (uuid, path, myfmt, opts, chk))
logging.debug(_("Added to fstab : UUID=%s %s %s %s 0 %s"), uuid, path, myfmt, opts, chk)

Expand Down Expand Up @@ -985,6 +986,22 @@ def install_bootloader(self):
else:
self.install_bootloader_grub2_efi(bootloader)

# Check grub.cfg for correct root UUID
cfg = os.path.join(self.dest_dir, "boot/grub/grub.cfg")
ruuid = self.settings.get('ruuid')

if ruuid not in open(cfg).read():
with open(cfg) as grub_cfg:
lines = [x.strip() for x in grub_cfg.readlines()]
for i in range(len(lines)):
if lines[i].startswith("linux /vmlinuz-linux root="):
old_line = lines[i]
p1 = old_line[68:]
p2 = old_line[:26]
lines[i] = p1 + ruuid + p2
with open(cfg, 'w') as grub_file:
grub_file.write("\n".join(lines))

def modify_grub_default(self):
""" If using LUKS, we need to modify GRUB_CMDLINE_LINUX to load our root encrypted partition
This scheme can be used in the automatic installation option only (at this time) """
Expand Down

0 comments on commit b3c7c1f

Please sign in to comment.