Resizing/formatting logical volumes for dual install

Questions about Grub, UEFI,the liveCD and the installer
Forum rules
Before you post please read how to get help
random_jc
Level 1
Level 1
Posts: 49
Joined: Sun Jun 01, 2014 10:30 am

Re: Resizing/formatting logical volumes for dual install

Post by random_jc » Sat Sep 14, 2019 7:59 am

Good morning :) Yes the system does load Grub on startup, and I can choose between the newly installed Mint OS (which works great) and the original CentOS one (which last time I tried did not work). Btw, please don't feel under pressure to reply rapidly. I appreciate your help a lot, and really don't mind how long it takes.

rene
Level 12
Level 12
Posts: 4415
Joined: Sun Mar 27, 2016 6:58 pm

Re: Resizing/formatting logical volumes for dual install

Post by rene » Sat Sep 14, 2019 9:01 am

Somewhat surprisingly ("Enterprise Linux") CentOS 7 can not in fact be installed with /boot on an LVM logical volume it seems, meaning I can't quickly check things in the VM using your partition/lv layout. It does indeed also use "regular" Grub normally though.

Let's first just look at things. From the Mint system you should be able to mount the CentOS root on /mnt with

Code: Select all

sudo mount /dev/mapper/vg_box102-lv_root /mnt
If indeed that works, you supposedly have /mnt/etc/fstab, /mnt/etc/default/grub and /mnt/boot/grub/grub.cfg or /mnt/boot/grub2/grub.cfg. Could you attach those files to a reply? It might be the case that we "need" the CentOS- rather than Mint-grub in charge of booting but let's first see if there's a minimal route...

I'm playing "What Remains of Edith Finch" in the meantime, so, yes, I might take a bit to reply...

rene
Level 12
Level 12
Posts: 4415
Joined: Sun Mar 27, 2016 6:58 pm

Re: Resizing/formatting logical volumes for dual install

Post by rene » Sat Sep 14, 2019 10:08 am

rene wrote:
Sat Sep 14, 2019 9:01 am
I'm playing "What Remains of Edith Finch" in the meantime, so, yes, I might take a bit to reply...
Much recommended...

And, oh, wait, that was what your 500M "msftdata" marked yet XFS-formatted /dev/sda2 was all about. The 500M and "msftdata" are rather W10-generic so I mentally ignored it. I.e., you'll only have a /mnt/boot/grub or /mnt/boot/grub2 after additionally (i.e., after other mount)

Code: Select all

sudo mount /dev/sda2 /mnt/boot
It also means it's likely there's less custom setup going on than I was momentarily "fearing" so let's see the fstab and grub files from the original system and just keep the Mint-grub in charge for now...

random_jc
Level 1
Level 1
Posts: 49
Joined: Sun Jun 01, 2014 10:30 am

Re: Resizing/formatting logical volumes for dual install

Post by random_jc » Sun Sep 15, 2019 7:16 am

So I mounted the two volumes you said, and then here is the fstab file:

Code: Select all

#
# /etc/fstab
# Created by anaconda on Thu Sep 12 17:14:39 2019
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/vg_box102-lv_root /                       xfs     defaults        0 0
UUID=ed6aaee3-2c50-4ec9-b25a-dfa30aa52b3d /boot                   xfs     defaults        0 0
UUID=CFEE-741E          /boot/efi               vfat    defaults,uid=0,gid=0,umask=0077,shortname=winnt 0 0
/dev/mapper/vg_box102-lv_scratch /scratch                xfs     defaults        0 0
/dev/mapper/vg_box102-swaplv swap                    swap    defaults        0 0
the /mnt/etc/default/grub file:

Code: Select all

GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=vg_box102/lv_root rd.lvm.lv=vg_box102/swaplv rhgb quiet rd.shell=0"
GRUB_DISABLE_RECOVERY="true"
and the /mnt/boot/grub2/grub file:

Code: Select all

#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by grub2-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#

### BEGIN /etc/grub.d/00_header ###
set pager=1

if [ -s $prefix/grubenv ]; then
  load_env
fi
if [ "${next_entry}" ] ; then
   set default="${next_entry}"
   set next_entry=
   save_env next_entry
   set boot_once=true
else
   set default="${saved_entry}"
fi

if [ x"${feature_menuentry_id}" = xy ]; then
  menuentry_id_option="--id"
else
  menuentry_id_option=""
fi

export menuentry_id_option

if [ "${prev_saved_entry}" ]; then
  set saved_entry="${prev_saved_entry}"
  save_env saved_entry
  set prev_saved_entry=
  save_env prev_saved_entry
  set boot_once=true
fi

function savedefault {
  if [ -z "${boot_once}" ]; then
    saved_entry="${chosen}"
    save_env saved_entry
  fi
}

function load_video {
  if [ x$feature_all_video_module = xy ]; then
    insmod all_video
  else
    insmod efi_gop
    insmod efi_uga
    insmod ieee1275_fb
    insmod vbe
    insmod vga
    insmod video_bochs
    insmod video_cirrus
  fi
}

terminal_output console
if [ x$feature_timeout_style = xy ] ; then
  set timeout_style=menu
  set timeout=5
# Fallback normal timeout code in case the timeout_style feature is
# unavailable.
else
  set timeout=5
fi
### END /etc/grub.d/00_header ###

### BEGIN /etc/grub.d/00_tuned ###
set tuned_params=""
set tuned_initrd=""
### END /etc/grub.d/00_tuned ###

### BEGIN /etc/grub.d/01_users ###
if [ -f ${prefix}/user.cfg ]; then
  source ${prefix}/user.cfg
  if [ -n "${GRUB2_PASSWORD}" ]; then
    set superusers="root"
    export superusers
    password_pbkdf2 root ${GRUB2_PASSWORD}
  fi
fi
### END /etc/grub.d/01_users ###

### BEGIN /etc/grub.d/10_linux ###
menuentry 'CentOS Linux (3.10.0-957.27.2.el7.x86_64) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-957.27.2.el7.x86_64-advanced-8890046d-5871-48fd-96bd-1bd61fe83ef7' {
	load_video
	set gfxpayload=keep
	insmod gzio
	insmod part_gpt
	insmod xfs
	set root='hd0,gpt2'
	if [ x$feature_platform_search_hint = xy ]; then
	  search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt2 --hint-efi=hd0,gpt2 --hint-baremetal=ahci0,gpt2 --hint='hd0,gpt2'  ed6aaee3-2c50-4ec9-b25a-dfa30aa52b3d
	else
	  search --no-floppy --fs-uuid --set=root ed6aaee3-2c50-4ec9-b25a-dfa30aa52b3d
	fi
	linux16 /vmlinuz-3.10.0-957.27.2.el7.x86_64 root=/dev/mapper/vg_box102-lv_root ro crashkernel=auto rd.lvm.lv=vg_box102/lv_root rd.lvm.lv=vg_box102/swaplv rhgb quiet rd.shell=0 
	initrd16 /initramfs-3.10.0-957.27.2.el7.x86_64.img
}
menuentry 'CentOS Linux (0-rescue-527cbbf7cc6d4d9cad9f7d7996e96399) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-0-rescue-527cbbf7cc6d4d9cad9f7d7996e96399-advanced-8890046d-5871-48fd-96bd-1bd61fe83ef7' --users "" {
	load_video
	insmod gzio
	insmod part_gpt
	insmod xfs
	set root='hd0,gpt2'
	if [ x$feature_platform_search_hint = xy ]; then
	  search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt2 --hint-efi=hd0,gpt2 --hint-baremetal=ahci0,gpt2 --hint='hd0,gpt2'  ed6aaee3-2c50-4ec9-b25a-dfa30aa52b3d
	else
	  search --no-floppy --fs-uuid --set=root ed6aaee3-2c50-4ec9-b25a-dfa30aa52b3d
	fi
	linux16 /vmlinuz-0-rescue-527cbbf7cc6d4d9cad9f7d7996e96399 root=/dev/mapper/vg_box102-lv_root ro crashkernel=auto rd.lvm.lv=vg_box102/lv_root rd.lvm.lv=vg_box102/swaplv rhgb quiet rd.shell=0 
	initrd16 /initramfs-0-rescue-527cbbf7cc6d4d9cad9f7d7996e96399.img
}
if [ "x$default" = 'CentOS Linux (3.10.0-957.27.2.el7.x86_64) 7 (Core)' ]; then default='Advanced options for CentOS Linux>CentOS Linux (3.10.0-957.27.2.el7.x86_64) 7 (Core)'; fi;
### END /etc/grub.d/10_linux ###

### BEGIN /etc/grub.d/20_linux_xen ###
### END /etc/grub.d/20_linux_xen ###

### BEGIN /etc/grub.d/20_ppc_terminfo ###
### END /etc/grub.d/20_ppc_terminfo ###

### BEGIN /etc/grub.d/30_os-prober ###
### END /etc/grub.d/30_os-prober ###

### BEGIN /etc/grub.d/40_custom ###
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.
### END /etc/grub.d/40_custom ###

### BEGIN /etc/grub.d/41_custom ###
if [ -f  ${config_directory}/custom.cfg ]; then
  source ${config_directory}/custom.cfg
elif [ -z "${config_directory}" -a -f  $prefix/custom.cfg ]; then
  source $prefix/custom.cfg;
fi
### END /etc/grub.d/41_custom ###

rene
Level 12
Level 12
Posts: 4415
Joined: Sun Mar 27, 2016 6:58 pm

Re: Resizing/formatting logical volumes for dual install

Post by rene » Sun Sep 15, 2019 8:21 am

OK. We first of all see from /etc/fstab that my previous worry of the lv_scratch fs being mounted via (the now changed) UUID was not necessary; it's mounted via device specifier, so all good.

If we indeed want to keep the Mint-grub in charge, what needs doing is basically lifting the original system's grub.cfg bit:
random_jc wrote:
Sun Sep 15, 2019 7:16 am
### BEGIN /etc/grub.d/10_linux ###
[ ... ]
### END /etc/grub.d/10_linux ###
into the Mint systems' /etc/grub.d/40_custom. Given, that is, that Grub appears to quite unhelpful as to allowing setting different parameters for different kernels from /etc/default/grub. And more than "basically" in fact, I just did so on my test-install while expecting I'd need to adjust some details later, but everything just works.

I have attached a 40_custom file to this message that IS the 10_linux part of your grub.cfg pasted onto teh end of the default 40_custom. You'd on your Mint system open a shell and

Code: Select all

$ sudo chmod -x /etc/grub.d/30_os-prober
$ sudo cp /where/ever/Downloads/40_custom /etc/grub.d/
$ sudo chmod +x /etc/grub.d/40_custom
$ sudo update-grub
Chances seem pretty good you'd then also on reboot get to boot into your CentOS install again. Your local BOFH added the rd.shell=0 bit so as to keep you from shenanigans; should appreciate you adding it back...

But, one thing... come to think of it a bit further it IS probably best to keep/set CentOS in charge of Grub lest a say upgrade to the (ancient) CentOS kernel interferes again with at least your ability to boot into CentOS. Unfortunately, while my local CentOS' install os-prober finds Mint no problem when executed from CentOS itself, I can not for now not get it to do so when generating a new grub config for CentOS from within Mint -- and you have no admin access to YOUR CentOS so can not use it from there.

As such, do first of all try the above so as to allow Mint's grub to boot CentOS, but we may in fact just want to give you admin access on CentOS so as to have you generate the grub.cfg from there and keep the CentOS Grub in charge. Let me experiment a bit...

[EDIT] The board software wouldn't allow me to attach a file without an extension (Windows much?) so it's renamed 40_custom.txt. Install as sudo cp /where/ever/Downloads/40_custom.txt /etc/grub.d/40_custom. Also edited in a chmod +x above.

[EDIT] I disabled 30_os-prober in the above due to it generating a non-functional entry for you but it seems a side-effect is the Grub menu no longer displaying by default when using an otherwise default Grub setup on Mint. You might actually like that --- it booting into Mint directly by default and allowing you to keep down Left-Shift at the right time when you'd want to see the menu --- but that "right time" is a little finicky. If you want the menu back, edit /etc/default grub on the Mint system to have

Code: Select all

GRUB_TIMEOUT_STYLE=menu
rather than =hidden and rerun sudo update-grub.
Attachments
40_custom.txt
(2.15 KiB) Downloaded 2 times

rene
Level 12
Level 12
Posts: 4415
Joined: Sun Mar 27, 2016 6:58 pm

Re: Resizing/formatting logical volumes for dual install

Post by rene » Sun Sep 15, 2019 10:16 am

OK, as to putting the CentOS-grub back in charge, let's not. Mounting the lv_mint somewhere before running os-prober/grub2-mkconfig on CentOS lets it actually find Linux Mint but a reboot with the original CentOS-grub installed to /dev/sda has it then run into SELinux. On my VM trying to fix that by reinstalling selinux policies then runs afoul of VirtualBox services -- which might be specific to the VM setup, but given that I can't test your actual setup I won't advise going there.

Simply disabling selinux with a kernel parameter works but implies a change that again an update to the original system might reset, so, well, whatever: I'd stay with the above setup from the Mint install, assuming that indeed it works for you to boot into either system.

random_jc
Level 1
Level 1
Posts: 49
Joined: Sun Jun 01, 2014 10:30 am

[SOLVED] Resizing/formatting logical volumes for dual install

Post by random_jc » Sun Sep 15, 2019 3:15 pm

Everything works!! I'm really super happy about this :D I've done just what you said and now each OS is working nicely (and shuting down nicely). I also added the grub menu back following your instructions. This is really wonderful. I hope I can invite you for dinner if we happen to be in the same town one day! I'll send you some peronal info in a PM.

rene
Level 12
Level 12
Posts: 4415
Joined: Sun Mar 27, 2016 6:58 pm

Re: Resizing/formatting logical volumes for dual install

Post by rene » Sun Sep 15, 2019 3:23 pm

Very good. Note; if a system-side update (i.e., through your institution) at some point either reverts to the CentOS grub (removing the Linux Mint choice) or updates the CentOS kernel (making it not boot again), holler. It's easy to fix, but would need to be done from the Live system so let's keep detailed advise until/if in fact ever needed.

Post Reply

Return to “Installation & Boot”