LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-22-2015, 11:19 AM   #1
powerplyer
Member
 
Registered: Mar 2012
Posts: 31

Rep: Reputation: Disabled
Centos 7: Customize GRUB2 menu to include options to boot GUI or CLI


Hello I have created a USB with CENTOS 7. I use this for work to do testing on various systems. Sometimes I need GUI and sometimes I need to use pure CLI (Console) environment.

I know you can hit the "e" button at the GRUB menu and change Run Level to 3 by adding a 3 at the end of the "linux" line, it has been tested and works.

I would like know if there is a way to add an entry for GUI or CLI off the same kernel from the grub menu. As a bonus change the time out to 60sec. The default boot would be GUI.

Any help would be greatly appreciated.
 
Old 11-22-2015, 02:10 PM   #2
TxLonghorn
Member
 
Registered: Feb 2004
Location: Austin Texas
Distribution: Mandrake 9.2
Posts: 702

Rep: Reputation: 231Reputation: 231Reputation: 231
That is easy. I just tested it and it works.
Open /boot/grub/grub.cfg in your text editor (mine is gedit - I don't know what your CENTOS 7 uses...)
Code:
gksu gedit /boot/grub/grub.cfg
Go the the first "menuentry" line, and copy that menuentry.
This is what mine looks like:
Code:
menuentry 'Linux Mint 17.2 Cinnamon 64-bit, 3.16.0-38-generic (/dev/sda2)' --class ubuntu --class gnu-linux --class gnu --class os {
	recordfail
	savedefault
	gfxmode $linux_gfx_mode
	insmod gzio
	insmod part_msdos
	insmod ext2
	set root='hd0,msdos2'
	if [ x$feature_platform_search_hint = xy ]; then
	  search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos2 --hint-efi=hd0,msdos2 --hint-baremetal=ahci0,msdos2  a2cd308e-2307-4bb4-8382-b54b792b8a79
	else
	  search --no-floppy --fs-uuid --set=root a2cd308e-2307-4bb4-8382-b54b792b8a79
	fi
	linux	/boot/vmlinuz-3.16.0-38-generic root=UUID=a2cd308e-2307-4bb4-8382-b54b792b8a79 ro   radeon.dpm=1
	initrd	/boot/initrd.img-3.16.0-38-generic
}
Now open /etc/grub.d/40_custom in your text editor.
Paste your menuentry at the end of the file.
Add CONSOLE ONLY to the title line:
Like this:
Code:
menuentry 'Linux Mint 17.2 Cinnamon CONSOLE ONLY (/dev/sda2)'
You can always change the text inside the quote marks any way you like.
Then edit the line that starts with "linux"
Remove "quiet splash" if that is there. Add "text"
Like this:
Code:
linux	/boot/vmlinuz-3.16.0-38-generic root=UUID=a2cd308e-2307-4bb4-8382-b54b792b8a79 ro   radeon.dpm=1 text
Save and exit the text editor and update grub
Code:
sudo update-grub
Reboot to test

Last edited by TxLonghorn; 11-22-2015 at 02:29 PM.
 
Old 11-22-2015, 02:25 PM   #3
TxLonghorn
Member
 
Registered: Feb 2004
Location: Austin Texas
Distribution: Mandrake 9.2
Posts: 702

Rep: Reputation: 231Reputation: 231Reputation: 231
Change the menu timeout to 60 seconds:
Code:
gksu gedit /etc/default/grub
Change:
GRUB_TIMEOUT=5
To:
GRUB_TIMEOUT=60
Save
Code:
sudo update-grub
 
Old 11-22-2015, 02:30 PM   #4
powerplyer
Member
 
Registered: Mar 2012
Posts: 31

Original Poster
Rep: Reputation: Disabled
Thank you for the quick reply, however it did not work. This is grub2 in CENTOS7

Here is the what I put in the file as you mentioned, I copyed it from

Code:
/etc/grub.d/40_custom

Code:
#!/bin/sh
exec tail -n +3 $0
# 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.
menuentry 'CentOS Linux 7 (Core), 3.10.0-229.20.1.el7.x86_64 CONSOLE ONLY' --class rhel fedora --class gnu-linux --class gnu --class os --u$
        load_video
        set gfxpayload=keep
        insmod gzio
        insmod part_msdos
        insmod xfs
        set root='hd1,msdos2'
        if [ x$feature_platform_search_hint = xy ]; then
          search --no-floppy --fs-uuid --set=root --hint-bios=hd1,msdos2 --hint-efi=hd1,msdos2 --hint-baremetal=ahci1,msdos2 --hint='hd1,ms$
        else
          search --no-floppy --fs-uuid --set=root 0262adbd-2bcc-4240-82cf-1058554a291d
        fi
        linux16 /vmlinuz-3.10.0-229.20.1.el7.x86_64 root=/dev/mapper/cl-root ro rd.lvm.lv=cl/root rd.lvm.lv=cl/swap rhgb text
        initrd16 /initramfs-3.10.0-229.20.1.el7.x86_64.img
}
Saved

Then ran:
Code:
grub2-mkconfig -o /boot/grub2/grub2.cfg
Code:
[root@localhost ~]# grub2-mkconfig -o /boot/grub2/grub2.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-3.10.0-229.20.1.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-229.20.1.el7.x86_64.img
Found linux image: /boot/vmlinuz-3.10.0-229.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-229.el7.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-1331952b60bf446786f843579d50b98e
Found initrd image: /boot/initramfs-0-rescue-1331952b60bf446786f843579d50b98e.img
done

Then Reboot (No new menu item)

Last edited by powerplyer; 11-22-2015 at 02:32 PM.
 
Old 11-22-2015, 03:49 PM   #5
colorpurple21859
Senior Member
 
Registered: Jan 2008
Location: florida panhandle
Distribution: slackware64-current, arch, ubuntu, others
Posts: 3,442

Rep: Reputation: 549Reputation: 549Reputation: 549Reputation: 549Reputation: 549Reputation: 549
looks like your missing the
Code:
{
in the menuentry line.
 
Old 11-22-2015, 04:04 PM   #6
powerplyer
Member
 
Registered: Mar 2012
Posts: 31

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by colorpurple21859 View Post
looks like your missing the
Code:
{
in the menuentry line.
Sorry it failed to "compile", I am not a code expert. I put the "{" right above the menuentry line.


Code:
#!/bin/sh
exec tail -n +3 $0
# 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.
{
menuentry 'CentOS Linux 7 (Core), 3.10.0-229.20.1.el7.x86_64 CONSOLE ONLY' --class rhel fedora --class gnu-linux --class gnu --class os --u$
        load_video
        set gfxpayload=keep
        insmod gzio
        insmod part_msdos
        insmod xfs
        set root='hd1,msdos2'
        if [ x$feature_platform_search_hint = xy ]; then
          search --no-floppy --fs-uuid --set=root --hint-bios=hd1,msdos2 --hint-efi=hd1,msdos2 --hint-baremetal=ahci1,msdos2 --hint='hd1,ms$
        else
          search --no-floppy --fs-uuid --set=root 0262adbd-2bcc-4240-82cf-1058554a291d
        fi
        linux16 /vmlinuz-3.10.0-229.20.1.el7.x86_64 root=/dev/mapper/cl-root ro rd.lvm.lv=cl/root rd.lvm.lv=cl/swap rhgb text
        initrd16 /initramfs-3.10.0-229.20.1.el7.x86_64.img
}
Error Message:
Code:
[root@localhost ~]# grub2-mkconfig -o /boot/grub2/grub2.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-3.10.0-229.20.1.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-229.20.1.el7.x86_64.img
Found linux image: /boot/vmlinuz-3.10.0-229.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-229.el7.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-1331952b60bf446786f843579d50b98e
Found initrd image: /boot/initramfs-0-rescue-1331952b60bf446786f843579d50b98e.img
error: syntax error.
error: Incorrect command.
error: syntax error.
Syntax error at line 136
Syntax errors are detected in generated GRUB config file.
Ensure that there are no errors in /etc/default/grub
and /etc/grub.d/* files or please file a bug report with
/boot/grub2/grub2.cfg.new file attached.
done
 
Old 11-22-2015, 05:01 PM   #7
yancek
LQ Guru
 
Registered: Apr 2008
Distribution: PCLinux, Slackware
Posts: 8,605

Rep: Reputation: 1772Reputation: 1772Reputation: 1772Reputation: 1772Reputation: 1772Reputation: 1772Reputation: 1772Reputation: 1772Reputation: 1772Reputation: 1772Reputation: 1772
Quote:
I put the "{" right above the menuentry line
It should go at the end of the menuentry line, not before it. Check your other entries in the grub.cfg file.
 
Old 11-22-2015, 07:59 PM   #8
powerplyer
Member
 
Registered: Mar 2012
Posts: 31

Original Poster
Rep: Reputation: Disabled
Thank however when I put "{" vs "}" which was copied directly from grub2. I get an "compile"error.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating a GRUB2 Menu that will Dual Boot CentOS and Win7 desertcat Red Hat 7 05-04-2015 05:10 AM
Kickstart customize boot menu creation jameslinux0301 Linux - Server 1 08-04-2011 01:48 AM
[SOLVED] Kickstart customize boot menu creation jameslinux0301 Linux - Kernel 1 08-04-2011 01:47 AM
GRUB2 - FreeBSD-8.0 does not show up in triple boot menu, dual boot menu it does.. wiliweld *BSD 7 05-03-2010 01:05 PM
LiveCD goes straight to GUI in Centos, need CLI! slozzy Linux - Hardware 6 09-15-2008 02:49 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:23 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration