Page 1 of 6

grub2 menu entry

Posted: 28 Dec 2012, 03:28
by francois
Working mostly with grub legacy for the last ten years, I am not much acustomed with grub2. I thought to share the information that I found. For grub legacy see:
http://forum.porteus.org/viewtopic.php?f=62&t=946

The article on grub2 on doimedo is well written and organised (proposed by Donald):
http://www.dedoimedo.com/computers/grub-2.html

A good thread providing examples on how to manage multiple system with grub2:
http://crunchbang.org/forums/viewtopic.php?id=17005

A gui tool to simplify the life of some of us with grub2, grub-customizer. It permits amongst other manipulations to set the order of the linux system for the bootloader:
http://www.howtogeek.com/howto/43471/ho ... -easy-way/

BE SURE TO BACKUP YOU PRECIOUS DATA, BEFORE TRYING THE FOLLOWING. KNOW WHAT YOU ARE DOING. =@
grub2 for slackware (thanks to tome):
http://mirrors.slackware.com/slackware/ ... 6_64-2.txz

GRUB2 FOR SLACKWARE.
grub2 for slackware is provided by djemos of the salix forum (***not yet functional***):
-thread on grub2 salix:
http://forum.salixos.org/viewtopic.php?f=32&t=4934
-grub2 files:
http://people.salixos.org/djemos/salix/grub-slackware/

Here is what I have done:
-installed the files:
grub-2.00-x86_64-2
os-prober-1.63-x86_64-1
-setup.grubconfig and grubconfig scripts contents have been copied with their respective filename into /sbin

setup.grubconfig or grubconfig command error message:

Code: Select all

Path /boot/grub' is not readable by GRUB on boot. Installation is impossible. Aborting.

Code: Select all

/usr/sbin/grub-probe: error: failed  to get canonical path of aufs.
update-grub error message:

Code: Select all

/usr/sbin/grub-probe: error: failed to get canonical path of aufs.
SET ISO FILE.
This has been adressed in the nemesis section. A chroot procedure is provided for arch linux, which is different the chroot procedure below for debian distributions:
viewtopic.php?f=137&t=5105

A. INSTALLING PORTEUS WITHIN THE LINUX DISTRIBUTION USING GRUB2 (porteus will not be recognized by grub2), for example manjaro:
Essentially when you install some other linux distribution, they often install grub2 against your will, it is the most widespread bootloader used in the linux universe. Its not bad to be able to install porteus within grub2, especially if you have a hard time figuring out the menu entry for that new distribution with your usual bootloader.

Porteus could be installed in two steps 1) modify /etc/grub.d/40_custom to add the menu entry for porteus installation and 2) and update these instructions with the update-grub command. In addition, if you want porteus to be loaded automatically, it is good to 3) get grub2 to recognize automatically porteus as the default os and set the timeout at which it will proceed into porteus. This is done within the /etc/default/grub file. After modification of that file, update-grub will have to issued to make the changes to the bootloader effective. The grub.cfg file which is the end result of the menu entries, cannot be modified directly as the menu.lst of grub legacy.

1) Modify /etc/grub.d/40_custom to add the menu entry for your porteus installation. If /etc/grub.d/40_custom does not exist create it.

Here is my entry in /etc/grub.d/40_custom:

1.1 for booting from an iso arch linux or nemesis examples:
viewtopic.php?f=114&t=5059

Code: Select all

#!/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.

# path to the partition holding ISO images (using UUID)
probe -u $root --set=rootuuid
set imgdevpath="/dev/disk/by-uuid/$rootuuid"

menuentry "porteus NEMESIS 64bit_v31  XFCE" {
set root=(hd0,6)
linux /64bit_v31_nemesis/boot/syslinux/vmlinuz changes=64bit_v31_nemesis/nemesis login=guest
initrd /64bit_v31_nemesis/boot/syslinux/initrd.xz
}
menuentry "porteus NEMESIS SDA6  XFCE" {
set root=(hd0,6)
linux /boot/syslinux/vmlinuz changes=/nemesis login=guest
initrd /boot/syslinux/initrd.xz
}
menuentry "porteus NEMESIS 64bit_v31  XFCE" {
set root=(hd0,6)
linux /boot/syslinux/vmlinuz from=/dev/sda6/64bit_v31_nemesis changes=/64bit_v31_nemesis png=nemesis login=guest
initrd /boot/syslinux/initrd.xz
}
menuentry "porteus NEMESIS 64bit_v31  XFCE" {
set root=(hd0,6)
linux /64bit_v31_nemesis/boot/syslinux/vmlinuz from=/dev/sda6/64bit_v31_nemesis login=guest
initrd /64bit_v31_nemesis/boot/syslinux/initrd.xz
}
menuentry "Porteus NEMESIS BASE PMAN x86-64 ISO" {
insmod part_msdos
insmod ext2
set root=(hd0,1)
set isofile="/ISO/nemesis-v3.1-x86_64.iso"
search --no-floppy --file --set=root $isofile
loopback loop $isofile
linux (loop)/boot/syslinux/vmlinuz from=$isofile login=guest changes=/1_nemesis
initrd (loop)/boot/syslinux/initrd.xz
}
menuentry "porteus on sda6 64bit_v31  XFCE" {
set root=(hd0,6)
linux /64bit_v31/boot/syslinux/vmlinuz from=/dev/sda6/64bit_v31 extramod=/mnt/sda6/64bit_v31/xfce changes=EXIT:/64bit_v31/xfce   login=guest
initrd /64bit_v31/boot/syslinux/initrd.xz
}
menuentry "Porteus XFCE x86-64 ISO" {
insmod part_msdos
insmod ext2
set root=(hd0,1)
set isofile="/ISO/Porteus-XFCE-v3.1-x86_64.iso"
search --no-floppy --file --set=root $isofile
loopback loop $isofile
linux (loop)/boot/syslinux/vmlinuz from=$isofile changes=1_porteus login=guest
initrd (loop)/boot/syslinux/initrd.xz
}
menuentry '[loopback]archlinux-2015.09.01-dual.iso' {
   set isofile='/ISO/archlinux-2015.09.01-dual.iso'
   loopback loop $isofile
   linux (loop)/arch/boot/x86_64/vmlinuz archisodevice=/dev/loop0 img_dev=$imgdevpath img_loop=$isofile
   initrd (loop)/arch/boot/x86_64/archiso.img
}
menuentry "Arch Linux Install  ISO" {
  set isoname='archlinux-2015.09.01-dual.iso'
  set isofile=/ISO/$isoname
  echo 'Using ${isoname}...'
  loopback loop $isofile
  linux (loop)/arch/boot/x86_64/vmlinuz img_dev=$imgdevpath img_loop=$isofile archisobasedir=arch archisolabel=ARCH_201509
  initrd (loop)/arch/boot/x86_64/archiso.img
}
menuentry "Porteus XFCE x86-64 ISO" COPY TO RAM{
insmod part_msdos
insmod ext2
set root=(hd0,1)
set isofile="/ISO/Porteus-XFCE-v3.1-x86_64.iso"
search --no-floppy --file --set=root $isofile
loopback loop $isofile
linux (loop)/boot/syslinux/vmlinuz from=$isofile changes=1_porteus login=guest copy2ram
initrd (loop)/boot/syslinux/initrd.xz
}

1.2 for two of my porteus installations;

Code: Select all

#!/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 "on sda5 64bit_v31rc1  extramod KDE" {
set root=(hd0,5)
linux /64bit_v31rc1/boot/syslinux/vmlinuz from=/dev/sda5/64bit_v31rc1 extramod=/mnt/sda5/64bit_v31rc1/kde changes=/64bit_v31rc1/kde login=guest
initrd /64bit_v31rc1/boot/syslinux/initrd.xz
}
menuentry "on sda5 64bit_v31rc1  extramod KDE ALWAYS FRESH" {
set root=(hd0,5)
linux /64bit_v31rc1/boot/syslinux/vmlinuz from=/dev/sda5/64bit_v31rc1 extramod=/mnt/sda5/64bit_v31rc1/kde fsck login=guest
initrd /64bit_v31rc1/boot/syslinux/initrd.xz
}

2) Then in root mode update-grub:

Code: Select all

root@toshiba-Satellite-Z930:/home/fl# update-grub
3) You might want to set porteus to be the default distribution to be booted first and to change the delay time for it to boot. Here is the standard way thru the /etc/default/grub file:
http://linuxpoison.blogspot.ca/2010/11/ ... meout.html
Change default Timeout:
To change the default timeout option in GRUB 2, you just need to change the GRUB_TIMEOUT parameter. The value of this parameter is in sec, change this value as per your requirement.

Change the default boot option:
To change the default boot option in GRUB 2, you just need to change the GRUB_DEFAULT parameter. 0 is the first entry, so if you want Windows to be your default boot option which is, say at, 5th position in the grub menu, then you just need to change the GRUB_DEFAULT value to 4 and save the file and close it.

Save the file after making all the required changes and from the terminal run the following command
sudo update-grub


4) Or better you might want grub2 to save the last selected menu entry for nexbootup, this will not work for porteus entries in the custom_40 file, but only for the other entries:
http://askubuntu.com/questions/148662/h ... ast-choice

You need the following in /etc/default/grub:

Code: Select all

GRUB_DEFAULT=saved
GRUB_SAVEDEFAULT=true
You should use the entry number instead:

Code: Select all

GRUB_DEFAULT="n-1"
n=rank number of the entry

To register the changes:

Code: Select all

sudo update-grub
B. The chroot procedure is handy to modify grub2 from porteus when it has been installed by another linux installation. To enter a 64bt system you have to be in a 64bit system It could be handy to modify some normal guest password that has been forgotten on a ubuntu system for example.

It has to be done with a chroot from that installation. The procedure to chroot for a grub2 installed in the /dev/sda1 modifying the default booting linux installation could be done this way:
mount /dev/sda1 /mnt
mount --bind /dev /mnt/dev &&
mount --bind /dev/pts /mnt/dev/pts &&
mount --bind /proc /mnt/proc &&
mount --bind /sys /mnt/sys &&
chroot /mnt

Code: Select all

root@porteus:~# mount /dev/sda1 /mnt
root@porteus:~# mount --bind /dev /mnt/dev &&
mount --bind /dev/pts /mnt/dev/pts &&
mount --bind /proc /mnt/proc &&
mount --bind /sys /mnt/sys &&
root@porteus:~# chroot /mnt
root@porteus:/# nano /etc/default/grub
root@porteus:/# update-grub
Generating grub.cfg ...
Found linux image: /boot/vmlinuz-3.2.0-61-generic-pae
Found initrd image: /boot/initrd.img-3.2.0-61-generic-pae
Found linux image: /boot/vmlinuz-3.2.0-51-generic-pae
Found initrd image: /boot/initrd.img-3.2.0-51-generic-pae
Found linux image: /boot/vmlinuz-3.2.0-61-generic-pae
Found initrd image: /boot/initrd.img-3.2.0-61-generic-pae
Found linux image: /boot/vmlinuz-3.2.0-51-generic-pae
Found initrd image: /boot/initrd.img-3.2.0-51-generic-pae
done
root@porteus:/# 
To change the password for root (I really like short ones):

Code: Select all

root@porteus:~# passwd
Changing password for root
Enter the new password (minimum of 5 characters)
Please use a combination of upper and lower case letters and numbers.
New password: 
Bad password: too short.  
Warning: weak password (enter it again to use it anyway).
New password: 
Re-enter new password: 
passwd: password changed.
Here using nano the values /mnt/etc/default/grub could be changed to accelerate the booting process by changing grub timeout from 10 seconds to 3 seconds or according to the linuxer choice:

Code: Select all

nano /mnt/etc/default/grub

Code: Select all

...
GRUB_TIMEOUT="3"...

Code: Select all

update-grub
Then exiting chroot procedure with:
exit &&
umount /mnt/dev &&
umount /mnt/dev/pts &&
umount /mnt/proc &&
umount /mnt/sys &&
umount /mnt

Code: Select all

root@porteus:/# exit &&
> umount /mnt/dev &&
> umount /mnt/dev/pts &&
> umount /mnt/proc &&
> umount /mnt/sys &&
> umount /mnt
exit
C. REINSTALLING GRUB2 (for example, when you have installed another bootloader and you decided to change your mind).
Here you can do it from within the os that hosted grub2 or you can proceed externally with the above chroot procedure, from outside the os if you are no more able to boot from within:

Code: Select all

fl@toshiba-Z930:~$ sudo grub-install /dev/sda
Installation finished. No error reported.
fl@toshiba-Z930:~$ sudo grub-install --recheck /dev/sda
Installation finished. No error reported.
fl@toshiba-Z930:~$ sudo update-grub
D. INSTALLING GRUB2 ON PORTEUS (this has to be fine tuned, the procedure is incomplete, help will be appreciated)
To install grub2 on a hdd installation, you need the grub2 on a cd or usb. In contrast to grub legacy you have to be out of the device where you want to install grub2, see:
http://phoxis.org/2010/02/03/installing ... ootloader/
mkdir /mnt/tmp
mount /dev/sdXy /mnt/tmp
grub-install --no-floppy --root-directory="/mnt/tmp" /dev/sdX
(to get to know your sdxy use the fdisk -l command)

Grub2 is available for a usb installation of porteus.Thus, you can install grub2 on any hdd partition of a box where you have one or many partitions from this porteus usb key.

You can download grub2 for slackware 14.1 for porteus 3.0 from slackel:
- 32bit:
http://www.slackel.gr/repo/i486/current ... 86-4dj.txz
- 64bit:
http://www.slackel.gr/repo/x86_64/curre ... 64-6dj.txz

Yet I did not achieved to install grub2 on porteus usb. It does not see the bios!! And even if you get it to see the bios:
http://forum.porteus.org/viewtopic.php?f=48&t=3860
The linux structure is not there to be harnessed by grub2. In porteus the linux structure is compressed.

In addition to be able to install grub2:
-Circumventing the /usr/sbin/grub-probe: error message for the grub-install command:
http://askubuntu.com/questions/207663/c ... n-live-usb



USEFUL THREADS:
For general instructions on grub2:
https://help.ubuntu.com/community/Grub2/Setup

Building custom menu for grub2:
https://help.ubuntu.com/community/Grub2/CustomMenus

Here is a link on how to boot from iso ubuntu with grub2:
https://askubuntu.com/questions/340156/ ... ning-linux

Re: grub2

Posted: 02 May 2014, 19:44
by francois
Funny to find some of your old tricks on the net. This thread is what you need to do if you want to play around with grub 2. In my case I installed elementary os (EOS) on my box (slax's tomas ideal os). As I was not able to find the grub legacy entry for EOS, I use grub legacy as bootloader, I decided to turn at least temporarily to grub 2.

I have updated the above post to give an example of 40_custom entry for porteus 3.0.

Re: grub2

Posted: 02 May 2014, 21:54
by donald
Hi francois
Here is another Site (which I like) not only for the grub2-tutorial

http://www.dedoimedo.com/computers/grub-2.html

Re: grub2

Posted: 03 May 2014, 02:49
by francois
Hello donald, thanks for the thread. I have integrated it in the first post.

Re: grub2 menu entry

Posted: 25 Jun 2014, 21:41
by Bogomips
After burning up quite a few CDs, at last found a distro that can be run from HD. After 3rd build attempt, am putting Porteus through its paces. Using Grub 1:

Code: Select all

title           Porteus Live DVD	7.03.14
root		(hd0,0)
kernel          /por/vmlinuz  copy2ram fsck noauto timezone=Europe/London volume=60%
initrd          /por/initrd.xz
Boot was very helpful in informing that iso could not be found, because it had to be in a 'porteus' top level directory, and gave precise instructions on how to remedy the situation. So the directory containing 'porteus.sgn' file, which the linuxrc script looks for, had to be copied to a top level directory on a partition.

Grub for some unfathomable reason requires a reiserfs partition, in this case sda1, with the iso (/porteus) then residing on an ext2 partition, without unnecessary journalling.

Re: grub2 menu entry

Posted: 29 Jul 2014, 23:08
by francois
Updated some information in the first post. Amongst other, I added the procedure to reinstall grub2.

And I just used the chroot procedure to rescue Elementary OS for which the guest password was wrong. It works great! :D

Re: grub2 menu entry

Posted: 02 Sep 2014, 22:00
by Ed_P
Elementary OS is an interesting ISO. Thanks for mentioning it.

If your interested this is the Grub4DOS menu entry that I'm using.

Code: Select all

title X. Elementary OS  \n 845MB\n amd64.20140810 version
set ISO=elementaryos-unstable-amd64.20140810.iso
find --set-root                       /ISOs/%ISO%
map --heads=0 --sectors-per-track=0   /ISOs/%ISO% (0xff) 
map --hook
root (0xff)
kernel /casper/vmlinuz           file=/ISOs/%ISO% iso-scan/filename=/ISOs/%ISO% boot=casper quiet splash --   
initrd /casper/initrd.lz

Re: grub2 menu entry

Posted: 06 Sep 2014, 22:17
by francois
@bogomips:
Grub for some unfathomable reason requires a reiserfs partition, in this case sda1, with the iso (/porteus) then residing on an ext2 partition, without unnecessary journalling.

I am on ext2 and ext4 partitions for porteus. I use grub legacy too, see grubconfig:
http://forum.porteus.org/viewtopic.php?f=62&t=946

@ed:
I never used grub4dos. Interesting.

I use the grubconfig slackware utility as mentioned above.

In fact, I find grub legacy or grub1, more convenient as it is more easy to manage.

Re: grub2 menu entry

Posted: 13 Sep 2014, 02:34
by francois
updated first post to include installing grub2 from and in porteus.

Re: grub2 menu entry

Posted: 23 Sep 2015, 03:07
by francois
Corrected first post to get porteus boot automatically by setting GRUB_DEFAULT=

I hate grub 2. It needs so many manipulations to be set =@

Comparatively Grub legacyis so easy to change. :)

Re: grub2 menu entry

Posted: 13 Mar 2016, 12:05
by francois
Added set isofile link to first post.

grub2 menu entry

Posted: 28 Oct 2017, 09:48
by Blaze
Can I boot Porteus (/dev/sdb1 (hd1,1)) and Windows 7 (/dev/sda1 (hd0,1) via GRUB 2 from sda1 (hd0,1) with MBR table?

Code: Select all

su
toor
umount /mnt/sda1
mount /dev/sda1 /mnt
grub-install --root-directory=/mnt/ /dev/sda
all ok, but on the step

Code: Select all

grub-mkconfig -o /boot/grub/grub.cfg
I have this error

Code: Select all

/usr/sbin/grub-probe: error: failed to get canonical path of aufs.
I must to tweak /etc/grub.d/40_custom or something? Thanks.

grub2 menu entry

Posted: 28 Oct 2017, 10:28
by burdi01
It has always been beyond me why people try to use a difficult solution to a simple problem: the grub.cfg file need not be complex -- so there is no need for those probers and mkmenus. Just create/edit it with your day-to-day text editor.

Here is my grub.cfg:

Code: Select all

set default=0
set timeout=10
set menu_color_normal=light-gray/blue
set menu_color_highlight=blue/light-gray

menuentry 'Slackware 14.2 Current' {
  set root=(hd0,7)
  linux /boot/vmlinuz root=/dev/sda7 ro
  initrd /boot/initrd.gz
}

menuentry 'Parted Magic / Rescue / Ghost' {
  echo Loading ...
  set rescue=boot/rescue-4.20.4d.iso
  loopback loop /$rescue
  linux (loop)/pmagic/bzImage64 root=/dev/sda5 edd=on loglevel=0 \
    directory=boot iso_filename=$rescue boot=live \
    update_caches=yes cpufreq=performance cgmanager=no nfs=no \
    bluetooth=no cups=no sshd=no zfs=no atop=no
  initrd (loop)/pmagic/initrd.img (loop)/pmagic/fu.img (loop)/pmagic/m64.img
}

menuentry '[10] Xubuntu 16.04.3 "Xenial Xerus"' {
  set root=(hd0,10)
  linux /boot/vmlinuz root=/dev/sda10 ro
  initrd /boot/initrd.gz
}

menuentry '[11] Linux Alternate' {
  set root=(hd0,11)
  linux /boot/vmlinuz root=/dev/sda11 ro
  initrd /boot/initrd.gz
}

menuentry 'Windows 10' {
  set root=(hd1,1)
  chainloader +1
}
The trick for "normal" linux distributions is to symlink /boot/vmlinuz and /boot/initrd.gz (in the distribution) to the "real" files.
As the Windows menuentry shows one can boot from a disk other than the first one.
For live distributions such as Parted Magic the trick is to use the loopback feature. For Porteus this is currently not possible, but could be implemented quite easily -- I expect.

Once you have this running you can think about embellishments -- if any.
:D

Edit Oct 30, 2017: Amended the "tricks" paragraph.

grub2 menu entry

Posted: 28 Oct 2017, 15:08
by Ed_P
Blaze wrote:
28 Oct 2017, 09:48
Can I boot Porteus (/dev/sdb1 (hd1,1)) and Windows 7 (/dev/sda1 (hd0,1) via GRUB 2 from sda1 (hd0,1) with MBR table?.
I use a Windows app named Grub2Win to boot multiple systems on EFI and BIOS machines. No MBR table hacking needed. Some examples for you to work with:

To boot a live distro:

Code: Select all

menuentry " Porteus 4.0 ISO - AF" --class slackware   --class icon-porteus  {

     set linux_folder=/porteus4.0
#     set iso=/ISOs/Porteus-XFCE-v4.0.0-x86_64.iso
#     set iso=/ISOs/porteus-4.0-x86_64-20170717.iso
#     set iso=/ISOs/porteus-4.0-x86_64-20170813.iso
#     set iso=/ISOs/porteus-4.0-x86_64-20170924.iso
     set iso=/ISOs/porteus-4.0-x86_64-20171012.iso
     set boot_parms="volume=33 reboot=cold extramod=$linux_folder/003Modules"
     set gfxpayload=1024x768

     search -f $iso --set=root
     loopback loop $iso
     linux  (loop)/boot/syslinux/vmlinuz from=$iso $boot_parms
     initrd (loop)/boot/syslinux/initrd.xz
     }

To boot a USB drive:

Code: Select all

menuentry "Porteus 3.2.2 - installed" --class slackware   --class icon-porteus  {

     search -f /boot/syslinux/vmlinuz --set=root
     echo "USB root is:          "$root
     set porteus_parms="extramod=/Modules;/Modsavedat volume=33 reboot=cold"  # acpi=off"

     linux /boot/syslinux/vmlinuz $porteus_parms
     initrd /boot/syslinux/initrd.xz
}

grub2 menu entry

Posted: 29 Oct 2017, 10:48
by Blaze
burdi01 wrote:
28 Oct 2017, 10:28
For live distributions such as Parted Magic and Porteus the trick is to use the loopback feature.
Thanks for info. I thought that I can boot Porteus from my second hard drive - where Porteus is installed (not from ISO file). If it's not possible - grub 2 not for me.

Ed_P, I don't like way with change language for Grub2Win - and again I must to use ISO file.
Image