This wiki assumes you are migrating from grub-legacy to grub2, which is a completely different bootloader.
TRY IT AT YOUR OWN RISK. It would be nice if you know how to use a live cd if you find you have any issues. I suggest you try it out first in a virtual machine, then onto a USB stick.
Grub2 uses some similar command names to grub-legacy.
Especially grub-install
sudo find / -name grub-install
If found, remove grub-0.97-splash.tcz from any onboot.lst, using either the cPanel or root powers to edit the file, then reboot with backup (to save the change) and start afresh please.
Checking your MBR. This is OPTIONAL. Although there are ways of checking using qemu….I have not used qemu for years so prefer a quicker test.
I install binutils which gives access to command strings
sudo dd if=/dev/sda bs=512 count=1 | strings |
change sda to hda etc
Legacy MBR may look like this
root@box:~# sudo dd if=/dev/sda bs=512 count=1 | strings ZRiI D|f1 GRUB Geom Hard Disk Read Error 1+0 records in 1+0 records out
while grub2 in MBR may look like this
root@box:~# sudo dd if=/dev/sda bs=512 count=1 | strings ZRi= '|f1 \|f1 GRUB Geom Hard Disk Read Error 1+0 records in 1+0 records out
TIP….If you have TWO x f(s) you have grub2
Leaping ahead, when you install any grub2 package, use cPanel to ensure no grub2 packages persist over reboot please. The way the package maintainer has designed the grub2 for TC, is to act the same way as grub-legacy. That means, it used grub.cfg as an “absolute” config file and not generated by any scripts. Therefore, the only files that should persist for grub2, are those installed under boot/grub which relate to your backup of the tce directory.
As grub2 depends on grep, replacing busybox grep, my /bin/true command now works. Please read this carefully. It's a safer option.
Firstly your MBR remains grub-legacy.
Secondly I suggest you use the cPanel and tab to Ondemand and allow your grub2 packages to be “on demand” rather than persist as “installed”.
Then click your menu to ondemand install grub2.tcz into the ram system. Or install grub2 if you prefer it the traditional way.
As no installer scripts were activated by your install or ondemand activity, we have more to do. We manually install grub2 packages into your grub folder…adjust for your persistent tce directory please.
sudo grub-install --no-floppy --boot-directory=/mnt/sda1 --grub-setup=/bin/true /dev/sda
TIP I prefer you copy and paste from web browser to your terminal…and adjust the –boot-directory for your persistent partition if needed……to avoid typos please. The option –boot-directory was called –root-directory in release 1.98 and earlier.
The references link explains, this tricks grub2 into thinking by the bin/true switch….that it is actually installed in MBR when it is NOT! core.img does not exist in the grub2.tcz, it has to be created by the above command.
Test with the dd command will confirm that your legacy grub is still in MBR.
But you now have populated your tce dir boot/grub with lots of grub2 files.
Then create or copy and paste the grub.cfg into that boot/grub folder.
Next we amend your legacy menu.lst to add a new title, using root powers
title grub2 core kernel /boot/grub/core.img
Please note…there is no initrd line.
Reboot to test…..Choosing new menu item should jump you to a grub2 menu.
I show a basic grub-legacy menu.lst
title Tiny Core 3 kernel /boot/bzImage tce=sda1 initrd /boot/tinycore.gz title grub2 core kernel /boot/grub/core.img
If you wish to test wallpaper or locale, you can install those packages or install OnDemand as well.
If grub legacy menu successfully jumps to the grub2 menu….and successfully boots for you, then you can install grub2 into MBR if you like it.
Check where your /boot/grub is, it may be /mnt/hda1 or somewhere else. TIP…… turn off all non-essential devices and remove non-essential USB devices…..unless you are installing to an USB device.
sudo grub-install --no-floppy --root-directory=/mnt/sda1 /dev/sda
Please note that TC is different from “traditional distros”.
Jason W reports that grub2 scripts can not generate a grub.cfg as grub2 is looking for boot/grub under / and not a different folder.
Feel free to correct this wiki anywhere that I am wrong please.
So we still need to place an effective grub.cfg under grub folder. See the grub.cfg section for more information please.
Please run
sudo fdisk -l
and confirm your target usb device….if hard drive is sda…usb is likely to be sdb….and its relevant partition number.
For those people with IDE drives, that TC reports as hdx, your USB device may be detected as sda.
The cheatcode waitusb=5 becomes an issue, if you have an USB 1.1 device or USB 3.0 device. My device is 2.0 standard so vary your time depending on whether you see any errors. One of the easiest tests …from the forum…was a check that your backup device is correct.
cat /opt/.backup_device
The other concern is how your bios detects the boot order on reboot. My bios treats hard drives as internal or usb….and I then choose which is the first drive detected. So if USB is not inserted…it falls back to internal…….YMMV See also the next section for suggestions on keeping your hard drive as first bootable device with USB inserted.
Install with….
sudo grub-install --no-floppy --root-directory=/mnt/sdb1 /dev/sdb
TC tools create /etc/fstab in internal to external device order. That means that while I initially thought if my bios was usb first, usb should appear as sda….it was actually sdb. This affects our cheat codes which may be
max_loop=256 tce=sdb1 waitusb=5
If you elected to have persistent home and opt, you may reduce some files in the backup as per forum suggestions.
A cut down grub.cfg without any wallpaper becomes
menuentry USB { linux /boot/bzImage max_loop=256 tce=sdb1 waitusb=5 initrd /boot/tinycore.gz }
In the core.img section, we needed some kind of persistence of grub2, in order to perform the install into MBR commands.
Once you are happy that grub2 is in MBR and working, there is no need to persist those packages any longer. Therefore use the cpanel, Apps Audit to delete them from any OnDemand Maintenance or OnBoot Maintenance lists.
Feel free to ignore this suggestion but the only true persistence needed are files that populate boot/grub.
If your bios boot order remains internal then USB, and usb device is detected at BIOS stage then, edit your internal drives config/menu file to allow the second device to either be chainloaded or booted direct.
internal drive = hd0 (legacy or grub2 bootloader) external drive = hd1 (grub2 in USB MBR) = usb device - ######## LEGACY - ########## title chainload to usb root (hd1) chainloader +1 title boot usb direct root (hd1,0) kernel /boot/bzImage max_loop=256 tce=sdb1 waitusb=5 initrd /boot/tinycore.gz - ####### GRUB2 - ####### menuentry "chainload to usb" { set root=(hd1) chainloader +1 } menuentry "boot usb direct" { set root=(hd1,1) linux /boot/bzImage max_loop=256 tce=sdb1 waitusb=5 initrd /boot/tinycore.gz }
Note I placed in a code box for wiki format reasons. If you need a menu, copy and paste only the relevant section(s)….this is not meant to be a full copy paste because if you mix up your “menus” you risk borking your system.
Our install has only got grub2 in MBR we also need a correct grub.cfg file.
Either create your own or copy and paste this section in the code box please. Wiki Version 1 may change while wiki is under construction. Once wiki is published please up the version number so people know its changed please.
- This is wiki version 1 - grub2 counts from 0 for all things except partition numbers which count from one - Remove hash from set default line and - change default number to where ever your boot partition is please - set default=2 - Remove hash from set timeout line and - change 5 to a different number of seconds if needed - set timeout=5 - ##################### wallpaper scripts starts here ################## - unicode.pf2 font is from package called grub2-unicode-font.tcz if loadfont /boot/grub/unicode.pf2 ; then set gfxmode="800x600x24" insmod gfxterm insmod vbe if terminal_output gfxterm ; then true ; else # For backward compatibility with versions of terminal.mod that don't # understand terminal_output terminal gfxterm fi fi insmod jpeg if background_image /boot/wallpaper.jpeg ; then set color_normal=black/black set color_highlight=magenta/black else set menu_color_normal=cyan/blue set menu_color_highlight=white/blue fi - ########## locale settings are here ############################### - non-en locale need grub2-locale.tcz to be installed and actioned - as per wiki section for locale set locale_dir=/boot/grub/locale set lang=en - Change en to ast, ca, de, fi, fr, hu, id, it, nl, ru, sv, zh_CN - if needed - ############### menuentries below ############################### menuentry hda1 { linux /boot/bzImage max_loop=256 tce=hda1 initrd /boot/tinycore.gz } menuentry sda1 { linux /boot/bzImage max_loop=256 tce=sda1 initrd /boot/tinycore.gz } menuentry "USB sdb1" { linux /boot/bzImage max_loop=256 tce=sdb1 waitusb=5 initrd /boot/tinycore.gz } menuentry "USB sda1" { linux /boot/bzImage max_loop=256 tce=sda1 waitusb=5 initrd /boot/tinycore.gz } menuentry hda5 { set root=(hd0,5) linux /boot/bzImage max_loop=256 tce=hda5 initrd /boot/tinycore.gz } menuentry "base norestore" { linux /boot/bzImage max_loop=256 base norestore initrd /boot/tinycore.gz } menuentry "Chainload to 2nd drive" { set root=(hd1) chainloader +1 } menuentry "Chainload to Partition 5" { set root=(hd0,5) chainloader +1 } menuentry sda1-old { set root=(hd0,1) linux /boot/bzImage-old max_loop=256 tce=sda1 initrd /boot/tinycore.gz-old } menuentry sda1-remastered { set root=(hd0,1) linux /boot/bzImage-remastered max_loop=256 tce=sda1 initrd /boot/tinycore.gz-remastered } - ##### menuentries using LABEL menuentry LABEL { linux /boot/bzImage max_loop=256 tce=LABEL=sata2 initrd /boot/tinycore.gz } menuentry "USB LABEL" { linux /boot/bzImage max_loop=256 tce=LABEL=usbone waitusb=5 initrd /boot/tinycore.gz } - #### chainload back to grub-legacy for - #### those using the core image way menuentry "grub-legacy" { set root=(hd0) chainloader +1 }
If you do not create a grub.cfg or copy paste above, on reboot you will drop to the grub prompt and be forced to use command to boot your system or run a live cd to rescue your system.
On reboot you may get this, if you have no wallpaper found. Image may differ from current grub.cfg
If we upgrade our kernel and use different version numbers, my config file will not update unless you modify it manually. Alternatively, sym link the old kernel to bzImage-old and the new one to bzImage and then you don't need to change your config unless you need to run more than 2 kernels.
Sorry. Please use root powers to edit before rebooting. Remember the only change from grub-legacy in counting is grub2 counts partions from ONE.
So if you need to chainload to partition 7 edit partition 5 to (using root powers)
menuentry "Chainload to Partition 7" { set root=(hd0,7) chainloader +1 }
I have disabled the set default settings and timeout. If you like one of my entries, uncomment those lines and edit with root powers to adjust the default number…..remember grub2 counts menuentries from zero.
This is my attempt to not have to change my grub.cfg every time there is a new TC iso. Use root powers to symbolically link old kernels and initrds to bzImage-old tinycore.gz-old then add your new bzImage and tinycore.gz to filesystem.
You are welcome to ignore this suggestion.
eg
sudo su cd /mnt/sda1/boot ln -s bzImage bzImage-old ln -s tinycore.gz tinycore.gz-old mkdir /tmp/z mount -o loop tinycore-latest.iso /tmp/z cp /tmp/z/boot/bzImage /mnt/sda1/boot cp /tmp/z/boot/tinycore.gz /mnt/sda1/boot
This section is optional but resolves most confusions in the USB section on whether to use sda1 or sdb1 etc….as labels are a viable and easy solution. It is just as easy to use it for hard drive booting.
The other wiki refers to using UUID. http://wiki.tinycorelinux.com/Boot+codes+explained
I prefer you install package e2fsprogs_apps.tcz …………which gives access to command e2label.
The first time you run it, you check if your partition already has a label with
sudo e2label /dev/hda1 (if the response is a blank line, you had no label set) (To label or change label run) sudo e2label /dev/hda1 newlabelname (repeat first command to see if label has been set correctly sudo e2label /dev/hda1
Change hda1 to your target partition if applicable please.
If you like labels, check that all of your new menuentries boot correctly, before deleting any /dev style entries. There is no need to delete anything, but some people do ….to keep it simple.
This means the minimum grub.cfg you would have is:
set default=0 menuentry LABEL { linux /boot/bzImage tce=LABEL=partalpha initrd /boot/tinycore.gz } menuentry DEV { linux /boot/bzImage tce=sda2 initrd /boot/tinycore.gz }
I have removed other cheatcodes to focus your mind on the label versus dev entry.
Unless you know what you are doing, please do not have any settings that are called
savedefault or hiddenmenu.
IMHO it can lead to some people getting into difficulty.
savedefault can interfere with the setting default.
hiddenmenu ……arch wiki says you need to hold the shift key to UN-hide it, which IMHO is non-intuitive.
Firstly check the current grub.cfg wiki entry to see if your locale is currrently supported. Then install grub2-locale.tcz
Next do this please
sudo cp -a /tmp/tcloop/grub2-locale/usr/local/share/locale /mnt/sda1/boot/grub
(We do not use /usr/local pathway to ensure we are only using locales supported by grub2.)
Change sda1 to where ever your grub/ folder partition is please.
Check that your boot/grub/locale exists for your locale and then edit with root powers the grub.cfg to change locale.
I prefer you do at least one reboot using English to make sure that the config works….before trying out a different locale.
grub-legacy defined stuff without equals signs but grub2 needs them, except in some scripts.
set default=0 …. means if countdown clock reaches zero boot the first menuentry. Also if highlight colors are used, it means make that the active menu line as per above image.
set timeout=5….countdown in seconds (5) to boot the default menuentry. (Even if you have only one entry, I prefer you keep those above lines in your config.)
set root=(hd0,5) is the same as grub-legacy hd0,4 because grub2 counts partitions from 1. All other counts in grub2 start from 0 including counting MBR's and menuentries.
grub-legacy title is now menuentry but we need { } to enclose our grub2 commands.
Some grub2 configs now like you to place “” around TC to make “TC” but appears only necessary if the string is too long.
linux = grub-legacy kernel command
initrd remains unchanged.
kernel cheatcodes remain unchanged.
So if your grub-legacy title was
My kernel with wireless built June 1999
……………………………………that is too long and will need to be enclosed with “ at both ends.
Also please have a gap between the string in your menuentry and the curly bracket so grub2 would be
menuentry "My kernel with wireless built June 1999" { blah blah }
The locale settings default is always en. Changing it will only work if (a) you have before reboot copied the locale folder to boot/grub, (b) used root powers to edit to a known locale and I have no way of testing non-en settings. Good luck!
I changed the default location of locale to boot/grub so we do not need to have any files backed up. See the locale section on how to install it.
Grub2 needs US spelling of color. I am Aussie so watch out for my spelling please.
For these lines in our grub.cfg
set menu_color_normal=cyan/blue
set menu_color_highlight=white/blue
These are the color options
black blue light-blue brown cyan light-cyan dark-gray light-gray green light-green magenta light-magenta light-red white yellow
In previous image of grub2 at menuentry stage…I pressed the down arrow to stop the countdown clock so I could take a snapshot. Otherwise hda1 would have been the booted option.
Feel free to use above colors to change your grub.cfg . I request you do at least one boot with no changes to colors just to make sure everything is working under my “old” config please.
If you decide to change your resolution from the default of 640×480….at menu you press C for command mode and type command
vbetest
When you press enter the second time….vbetest will test your graphics are bit harder…then press enter again to end the test.
At command mode
grub > set pager=1 # means turn on pager function like less allows scroll paging grub > vbeinfo
These are virtualbox shots…my monitor can actually do bigger resolutions…(optional) that is for you to find out for yours. My actual result against my monitor showed result: 0x169 1680x1050x32…..and those strings like 0x169 are known as vbemode, if you read other wikis.
If you add a wallpaper, I have set it to /boot and not /boot/grub so its easier spot. Please arrange:
chown root:staff wallpaper.jpeg chmod 755 wallpaper.jpeg
I prefer to change wallpaper canvas size using mtpaint….but feel free to leave unaltered and see what effects you can enjoy. Basically background images and displayed counting 0,0 as top left hand corner of your monitor.
If you like mtpaint here is a quick guide to how to resize…..Open the image with mtpaint…..Pulldown Image…..Click on “scale canvas” not the resize canvas please.
Ideally we set the image canvas to the same vbemode (gfxmode)….but kernel font is a different matter.
The bigger the canvas size…the smaller the menuentry font size appears to be. Lets change that now.
First use root powers to edit grub.cfg to use a smaller canvas ….gfxmode=“800x600x24” (If you set the color depth lower…you get uglier image)
(B) If you are unsure what your current wallpaper is….for the specs, you may need to install ImageMagick and you can then pulldown File in mtpaint…actions….view image info OR in a terminal run the command.
identify wallpaper.jpeg
Mtpaint has index info but I am not sure how to use it.
ImageMagick can also use a command to resize canvas and color depth. So then use a graphics application to resize canvas to the same gfxmode and depth.
The above image still needs tweaking….we could go back to 640×480 especially if you need to E (for) EDIT and can't read the size of fonts. Also I would be tempted to change the highlight color to a stronger contrast.
Now that you have the idea, as a general rule….. disk space sizes (at same canvas size) run from smallest jpeg - png - and largest tga.
If you want a wallpaper, you need to install separate package called grub2-unicode-font.tcz
There is no installer script. Instead you decide where your persistent boot/grub partition is and install it manually
sudo cp -p /usr/local/share/grub2/unicode.pf2 /mnt/sda1/boot/grub
Change /mnt/sda1 to where ever your persistence is please.
The grub.cfg shows that the font file is under boot/grub but we have your wallpaper under boot/ because you may like to find the wallpaper and change it.
I am not a script guru.
The wiki grub.cfg first script attempts to test if you have a grub2 font called unicode.pf2 which is obtained from a separate TCZ. The reason for the separation is to allow users to just get a grub2 ….text menu…as unicode is over 1 MB download. If the font exists, the terminal…the screen border and its text etc…are defined.
If the font exists, gfxmode is then set at the appropriate canvas size and (optional) color depth.
However, generally speaking its better to define color depth.
The larger the depth and canvas size…..the slower the image will take to load.
The bottom script inserts a jpeg module. Grub2 can also use png or tga formats but please change insert module command and filename to match. If the wallpaper file is found…placed in boot/ to make it easier to find….then the –/black acts as a transparency to NOT interfere with the wallpaper shining through for you to enjoy. My magenta and the image shows what is the active text that I have either arrowed down to or set by the default command.
If no wallpaper is found….then the scripts sets the more basic color set for a blue background etc.
Check that your grub-install command has populated your persistent boot/grub with lots of files.
(Optional….Check your MBR has changed using the dd command above)
Check that you have created a grub.cfg under boot/grub or copy and pasted from the wiki. Menuentry must have a gap between your “title” and {
Menuentry must be enclosed in ” “ if too long and
end it with }
Either shutdown or reboot with the tce backup directory box ticked please.
Good luck!
Before you reboot, make notes on how to revert to legacy if things go wrong and post to the forum please. Do not try to solve issues unless you are comfortable using grub2 command mode or grub rescue command mode.
Grub2 can chainload. See the latest grub.cfg for examples. Remember grub2 counts hard drives (or bootable USB devices) from zero just like grub-legacy but now counts partitions from ONE.
You may find yourself at the grub prompt…with no menu. You can use commands to boot your TC.
The key differences between your config file and command mode are (a) You may need to define where your /boot partition if you have multiple systems and (b) last command is boot then press enter.
So if you have multiple systems prefix your linux and initrd commands with something like
set root=(hd0,7)
Plus, ls command must show that partition exists for grub2 to be able to use it!
Please note that I have tested a number of modules and (a) we do not include .mod in inserting and (b) you can insert all modules with no apparent harm…YMMV….The problem is ….grub2 does not always complain …if inserting something is useless or failed.
If you can't remember where your /boot partition is…in grub2 terms you could try simple then search commands
simple…ls returns drives detected and partitions detected.
If you can't remember a special kernel cheatcode…try cat command to view your existing config file
Note that I have pressed the TAB key….which also works for grub-legacy to “autocomplete” or suggest files that match current string
Also, grub2 should detect the correct number of available drives and show that the normal module is loaded. Normal.mod is the basic module that helps to give you the text menu.
The bottom of above image shows….using the “absolute” pathway to a file….to discover if it exists….for normal.mod to show a positive result and for grub.cfg showing a negative result. However, you can also use a normal pathway as per below image
In above image I have used the TAB key to search for files beginning with gr. But in this test case….I deliberately made an typo instead of copying and pasting the command from the install section that lead to me having grub.cfg1 instead of grub.cfg1.
According to arch wiki, you may have a module not correctly installed…the “normal.mod” or grub2 can not find a grub.cfg or can not find a correctly syntaxed grub.cfg.
Try to prevent this by using copy and paste command to copy the grub.cfg into your boot/ folder and check its there. However, I have limited the number of partition entries, so you may had to edit that file (with root powers) and borked it. Remember, grub2 counts MBR, drives, menuentries from zero and the only change from grub-legacy is partitions start from ONE.
So let us pretend you see the grub rescue prompt. We try commands to get back our text module called normal.mod
set prefix=(hdx,y)/boot/grub insmod (hdx,y)/boot/grub/normal.mod normal (hopefully grub rescue> changes to grub> )
Change (hdx,y) to the correct syntax for your boot/ partition is grub2 terms please eg (hd0,5) If you have only one distro installed, likely to be first partition, you may not need the absolute pathway using (hdx,y)
Below I deliberately renamed my normal.mod to normal.mod1 to force grub2 into rescue prompt….Do not try please.
It is unlikely you are going to destroy that module, but what I can not show you, unless its a movie….after pressing enter after typing normal, grub rescue prompt changes to grub….and then you can use manual commands to boot your system….as per…. if you have a grub prompt section.
The file not found ….in the first image in this section….does refer to normal.mod. If you still can't find it, boot up TC cd and either re-install grub2 or revert to grub-legacy
Of interest to me, is that if you can not load normal, can you set (fix) the way grub2 will look for files? as per image
If you can do this, you are likely the to succeed repeating the “normal” module insertion but if you can not, its time to cut losses.
Ok further tests show that if you delete certain modules, you can get to same grub prompt.
Deleting lvm, raid* and crypto* causes no errors (YMMV unless you need them) but deleting gcry* causes borking of my system.
So if you are short of disk space pls take care on what you delete please.
This is currently not solvable for me.
disk not found means you will not be able to define a pathway to your modules.
You may want to revert to legacy.
If so, you have grub-legacy in MBR and do not need to do anything. If you feel like, you can delete all contents of boot/grub and use grub-0.97-splash.tcz to populate boot/grub and create your menu.lst.
Or, you could remove the core.img menuentry.
Either as internal hard drive install or USB device we can follow the commands showing in the command box. We can do the following as my grub-install did not delete your menu.lst so we move it out before deleting all other files and then install a fresh grub-legacy with your menu.lst moved back into position for grub-legacy to find it. Feel free to just delete all files under grub/ and doing a fresh install of grub-legacy and manually create your menu.lst.
Hopefully your boot partition is already mounted, if not, mount it please.
sudo su fdisk -l (to check your target device ....lets pretend its /dev/sda1) cd /mnt/sda1/boot/grub mv menu.lst .. (optional) find / -name menu.lst (will report /mnt/sda1/boot/menu.lst (one folder higher) rm -f * cd .. mv menu.lst grub/
Note the 2 periods or full stops in above command. If your prefer do it longer try mv menu.lst /mnt/sda1/boot (and the other line) cd /mnt/sda1/boot
Now connect to Apps Browser and install grub-legacy. Go back to root terminal and
cp -p /usr/lib/grub/i386-pc/* /mnt/sda1/boot/grub/ grub root (hd0,0) setup (hd0) quit
Please change the hd(numbers) if your target boot partition is not on the first partition and you do not want grub-legacy in MBR of first drive please.
Then boot your TC cd and follow almost the same steps as above but we still need to take care which device we are going to revert.
But you will need to mount your hard drive boot/ partition.
Its more critical to run fdisk -l.
TinyCore forum users especially maro and Jason W for the build script and packages.
http://wiki.archlinux.org/index.php/GRUB2 for heaps of stuff
http://www.linuxfromscratch.org/hints/downloads/files/grub2.txt my source for using /bin/true
https://help.ubuntu.com/community/Grub2 especially the set pager=1 tip
grub-legacy in hard drive MBR
……chainload to grub2 in MBR of USB device
…….direct boot USB device which has grub2 installed
………core.img test
grub2 in hard drive MBR
………direct boot hard drives
……..chainload to grub2 in MBR of USB device
……..direct boot USB device which has grub2 installed
grub2 in USB MBR
…….bios set to boot this device first
Unable to test USB keyboards and non-English locales. Ditto raid or lvm partitons, GPT and non-msdos setups.