Tiny Core Extensions > TCE Tips & Tricks
Howto make a legacy bios/uefi dual boot usb stick with grub2
jazzbiker:
Hi, all Core explorers!
I want to propose the small workaround, which can be usefull for those, who uses the same 32-bit rootfs under 32-bit or 64-bit kernels, depending on the hardware being booted. In Juanito's perfectly working grub.cfg You need to choose manually among Core and Core64 entries. But grub2 shell implements "cpuid" builtin command, which can make this dirty job for You.
I've added to original Juanito's grub.cfg the next entry:
--- Code: ---
if cpuid -l
then
set KNAME="vmlinuz64"
set MNAME="modules64"
else
set KNAME="vmlinuz"
set MNAME="modules"
fi
menuentry "core auto" {
linux /boot/"$KNAME" quiet tce=UUID="<Your boot disk UUID>" waitusb=10:UUID="<Your boot disk UUID>"
initrd /boot/rootfs.gz /boot/"$MNAME".gz
}
--- End code ---
Have a nice Core!
jazzbiker:
Let me make remarks here concerning avoiding of extraneous writes to flash, as it was not mentioned in this thread yet.
1. Making ext4 filesystem without journal. Proposed in the initial post
--- Code: ---$ sudo mkfs.ext4 /dev/sdc1
--- End code ---
can be modified adding option
--- Code: ---$ sudo mkfs.ext4 -O ^has_journal /dev/sdc1
--- End code ---
2. Remounting boot device with forbidden files' and directories' access time updates.
The next commands can be added to bootlocal.sh:
--- Code: ---TCEDEV=$(readlink /etc/sysconfig/tcedir | sed 's_/mnt/\(.*\)tce.*_\1_')
mount -o noatime -o nodiratime -o remount /dev/"$TCEDEV"
--- End code ---
3. Number of blocks written to Your device can be monitored with
--- Code: ---cat /proc/diskstats | awk '/sdc1/{print $10}'
--- End code ---
if Your flash partition is /dev/sdc1.
jazzbiker:
EDIT to privious post.
2. Remounting boot device with forbidden files' and directories' access time updates.
The next commands can be added to bootlocal.sh:
--- Code: ---TCEDEV=$(readlink /etc/sysconfig/tcedir | sed 's_/mnt/\([^/]*\).*_\1_')
mount -o noatime -o nodiratime -o remount /dev/"$TCEDEV"
--- End code ---
jazzbiker:
Hi, Core people!
One more post about grub2 and TinyCore. Using multiple TC versions, building custom rootfs-es, kernels, having need for different bootcodes' batches makes someone tired of constant editing (manual!) of grub,cfg according to the newly appeared environments. Trying to avoid grub.cfg manual editing I've made a universal grub.cfg, which, once stored in /EFI/BOOT/grub directory, don't need to be cared and make all the job of creating grub2 menu entries during boot process by itself lonely. Of course this assumes, that the structure and content of the boot device follows certain rules.
Boot device contains a directory tree with distribution files (vmlinuz, vmlinuz64, rootfs.gz, rootfs64.gz, modules.gz, modules64.gz) placed in various directories. Also boot device directory tree contains "bootcodes" files. The normal way to use "bootcodes" files is to place the single
--- Code: ---BOOTCODES="<something>"
--- End code ---
definition, which will be sourced to the grub2 shell while creating the corresponding menu entry.
Boot menu entries are created only for the terminal nodes - dirctories, which doesn't have subdirs. Each terminal node has unique path from the root directory. Distribution files are collected along this path exclusively, means if on the way from / to /10/4/6/7 more than one "vmlinuz" will be found, the latest (closest to the terminal node) will be used. "bootcodes" assignments are accumulated in BOOTCODES_FULL variable, which immediately is used for creating menu entry itself.
For every terminal node entries tried to be created depends on the set of distribution files collected along the path and CPU bitness.
Directory names, visible for script, can only be natural numbers (see NATURALS constant in the source code). Directories alternatively named don't influence on entries cretion process.
First subdir in BOOT_ROOT is considered to be the version number and all the down-level subdirs' created entries will share the same TCE<version> working directory. So distribution files of TC10.0 version, placed in /10/0 and TC10.1 files placed in /10/1 will share the same /TCE10 directory for roots and /TCE10-64 for rootfs64. Boot and TCE devices may be separate ones.
So final grub.cfg is "cat"-ed of the definition header (grub.cfg.def) and grub.cfg.template and is placed in /EFI/BOOT/grub/ on the EFI device, according to initial Juanito's post.
Additional tool for making menu entries understandable are "title" files. For example, if /10/1 contains 32-bit distributionn files, /10/1/2 contains "bootcodes" with
--- Code: ---BOOTCODES="noswap nodhcp"
--- End code ---
then corresponding boot menu entry will be named "core-10-1-2". But if You'll place in /10/1/2 the file "title", containing
--- Code: ---TITLE="mysettings1"
--- End code ---
then corresponding entry becomes named "core-10-1-mysettings1".
Important note: TITLE value string must not contain spaces.
This is brief description of the grub.cfg.template possibilities. Of course, it is not fully tested, so You can use it with care.
Have a nice Core!
jazzbiker:
Update: added protection against spaces in TITLE value definition. They will be replaced with '_' symbols.
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version