PDA

View Full Version : [SOLVED] Howto generate text file of Boot menu - output of grub.cfg



Hakunka-Matata
August 31st, 2011, 10:10 PM
Hi, I'd like to have a text file of the boot menu generated by /boot/grub/grub.cfg. Haven't figured out how to make grub.cfg run and use pipe to a file.

Thanks in advance

Edit: Oh, I already know, shouda put a question mark in the Subject line!

oldfred
August 31st, 2011, 10:32 PM
I always just run boot script. In fact is it part of my rsync backup so I always have a current one even though it does not change that much.

If you just want titles:

List of grub menu:
grep menuentry /boot/grub/grub.cfg
or numbered list:
grep menuentry /boot/grub/grub.cfg | cut -b 1-11 --complement | cut -d "'" -f1 | cut -d "\"" -f 1 | nl --starting-line-number=0


fred@fred-MavericDT:~$ grep menuentry /boot/grub/grub.cfg | cut -b 1-11 --complement | cut -d "'" -f1 | cut -d "\"" -f 1 | nl --starting-line-number=0
0 Ubuntu, with Linux 2.6.35-30-generic
1 Ubuntu, with Linux 2.6.35-30-generic (recovery mode)
2 Ubuntu, with Linux 2.6.35-28-generic
3 Ubuntu, with Linux 2.6.35-28-generic (recovery mode)
4 Ubuntu, with Linux 2.6.35-23-generic
5 Ubuntu, with Linux 2.6.35-23-generic (recovery mode)
6 Memory test (memtest86+)
7 Memory test (memtest86+, serial console 115200)
8
9 Microsoft Windows XP Professional (on /dev/sda1)
10
11 Kubuntu, Natty 11.04 (on /dev/sdc11)
12 Ubuntu, Oneiric 11.10 (on /dev/sdc16)
13 Ubuntu, Natty 11.04 (on /dev/sdc13)
14
15 Ubuntu, Lucid 10.04 (on /dev/sdc7)
16 Karmic 9.10 on sdc5 (on /dev/sdc5)
17 Puppy 511
18 Chainboot hd2
19
20 Chainboot hd1
21 Chainload Other Systems Grub Menu on sdc1
22 Kubuntu 11.04 Natty ISO 64bit
23 gparted (Boot ISO Image via Grub2)
24 Reboot
25 Halt
fred@fred-MavericDT:~$

sisco311
August 31st, 2011, 10:33 PM
Something like

awk -F[\'\"] '/^menuentry/{print $2}' /boot/grub/grub.cfg
?


awk -F[\'\"] '/^menuentry/{print $2}' /boot/grub/grub.cfg > ~/grub.menu

Hakunka-Matata
August 31st, 2011, 11:01 PM
Thanks to both of you: oldfred & sisco311. That was quick and painless. I have some command lines and switches to figure out too now!