Showing posts with label grub. Show all posts
Showing posts with label grub. Show all posts

Tuesday, February 24, 2009

Enabling TuxOnIce hibernation with EEEbuntu

Enabling hibernation (suspend to disk) support is a bit tricky, and I never found a good and complete tutorial. Also mine is not, but after several attempts I got hibernation working and now I want to record my steps, to be able to repeat them.
On EEEbuntu, hibernation is possible through "swsuspend" which is told to be slower than "TuxOnIce" (true) which is told to be faster than normal booting without resuming (true, but not impressive).
TuxOnIce needs to be patched into the kernel and compiled, and can completely replace swsuspend without reconfiguration.
My steps were (mixing different guides, an EEEbuntu forum post and TuxOnIce wiki):
  1. check that swsuspend is working;
  2. check that the package hibernate is installed;
  3. open a terminal for the normal user;
  4. become "root":
    # sudo bash
  5. install "git-core":
    # sudo apt-get install git-core
  6. clone the Array kernel for Intrepid:
    # git clone git://git.array.org/array/ubuntu-intrepid.git
  7. enter the directory:
    # cd ubuntu-intrepid
  8. join the split config files to a .config for the kernel:
    # cat debian/config/i386/config debian/config/i386/config.eeepc > .config
  9. check kernel version:
    # uname -r
  10. download a suitable patch from TuxOnIce site;
  11. apply patches:
    # bunzip2 -c path/to/patchname.patch.bz2 | patch -p1
  12. choose TuxOnIce options:
    # make oldconfig
    (press enter on all, except say Y for IGNORE_LATE_INITCALL);
  13. install some tools:
    # sudo apt-get install kernel-package libncurses5-dev fakeroot
  14. choose your config options:
    # make menuconfig
  15. move config where ubuntu looks for it, and make a backup:
    # cp .config debian/config/i386/config.eeepc
    # cp .config config
  16. if you want to change the config later, just do:
    # cp config .config
    # make menuconfig

  17. create a file:
    # sudo nano /usr/share/initramfs-tools/scripts/local-premount/tuxonice_do_resume
    with the following content:
    #!/bin/sh
    PREREQ=""
    prereqs()
    {
    echo "$PREREQ"
    }
    case $1 in
    # get pre-requisites
    prereqs)
    prereqs
    exit 0
    ;;
    esac
    if [ -d /sys/power/tuxonice ]; then
    echo 1 > /sys/power/tuxonice/do_resume
    fi
  18. compile:
    # fakeroot make-kpkg --initrd --append-to-version=-custom kernel_image kernel_headers
  19. in the parent directory there are now two .deb packages to install:
    # cd ..
    # sudo dpkg -i *custom*.deb
  20. reboot using the new kernel and the new initrd;
  21. check the new GRUB entry has the boot kernel option like "resume=swap:/dev/xxx";
  22. check hibernate is working, by typing in a console:
    # sudo hibernate -v3 --no-suspend
  23. check that resuming is possible, because some buggy initramfs building scripts fail to include the tuxonice_do_resume file into the new initrd
    • inspect the new initrd:
      # follow this
    • if not OK, add the file, create an initrd again:
      # follow this
    • and replace it;
  24. check that the hibernate button is visible; if not, use gconf-editor to tick "can_hibernate" property (go to apps -> gnome-power-manager -> can_hibernate);
  25. test hibernating and resuming.
Even if the test succeded, I gave up: too slow. I'll wait for GRUB to boot directly from resume image.

Monday, February 2, 2009

Multi-booting several Windows based OSes

Microsoft itself explains how to make coexist different versions of her OSes on the same disk. The key point is that they have to be installed in age order: the youngest last. Quite uncomfortable, particularly if you already have a consolidated setup and want to add an older version.
I also tried to install WindowsXP (64bit) after Windows2000 professional (32bit) on two different partitions, but then Windows2000 didn't boot anymore. Even if they are on separate partitions the share the C:\ for the bootloader. I don't believe it's a 32-64 bit issue, but I have no time to investigate.
I feel better this way (each OS with its own bootloader):
  1. install (or keep installed) Windows "A" in its proper partition (e.g. the first one);
  2. add a partition to hold Windows "B" (e.g. the second one);
  3. use the preferred tool (e.g. grub) to hide partition "A";
  4. install Windows "B";
  5. install grub on the mbr of the hard drive and make it reading the menu.lst containing:
    title Windows A
    unhide (hd0,0)
    hide (hd0,1)
    rootnoverify (hd0,0)
    chainloader +1
    makeactive

    title Windows B
    unhide (hd0,1)
    hide (hd0,0)
    rootnoverify (hd0,1)
    chainloader +1
    makeactive


Sunday, December 28, 2008

Multi-booting (automatic way) several Ubuntu based distributions

There is a simple way to boot from different ubuntu .iso images saved on the same media, but a manual intervention is needed in order to rename some files before (re)booting.
It is possible to automate it: it's tricky, but it works.

Briefly:
  1. make an usb stick (or hard disk) FreeDOS bootable;
  2. put the .iso images on it;
  3. put the correct pair of kernel and initrd which boots the .isos;
  4. edit (fd)config.sys and autoexec.bat in order to make a menu and a batch that renames some files and boots (using Grub4DOS).

In detail (with the goal of booting the "alternate" distro of kubuntu hardy in either i386 or amd64 flavour):
  1. make your usb device boot any (in principle) OS capable of file manipulation. The plain old DOS is enaugh (and fast to load) but not free. FreeDOS is a good choice and making an usb stick FreeDOS bootable is simple;
  2. make a folder called "hardy" under the root;
  3. download the alternate iso images and put them into the folder "hardy";
  4. rename them "i386-k.iso" and "amd64-k.iso" for short;
  5. under the folder "hardy" make two sub-folders "i386" and "amd64";
  6. download the proper (check here for details) pair of kernel and initrd of each distro and put them into the corresponding folder;
  7. get Grub4DOS and put the dos executable "grub.exe" in the root folder (it will be used to boot the kernel which in turn will run the installer on the .iso image);
  8. make two configuration files for Grub4DOS to load the proper kernels;
    the first "i386-k.lst" (add kernel options as needed):
    default 0
    timeout 1
    title i386
    root (fd0)
    kernel /hardy/i386/vmlinuz root=/dev/ram0 noapic
    initrd /hardy/i386//initrd.gz
    boot

    the second "amd64-k.lst" (add kernel options as needed):
    default 0
    timeout 1
    title amd64
    root (fd0)
    kernel /hardy/amd64/vmlinuz root=/dev/ram0 noapic
    initrd /hardy/amd64/initrd.gz
    boot
  9. in the root folder, make an "fdconfig.sys" file, which acts as menu:
    switches=/F /N
    menudefault=0,30
    menu Kubuntu USB installer
    menu
    menu 0 - Exit to FreeDOS
    menu 1 - Install from kubuntu-8.04.1-alternate-amd64.iso
    menu 2 - Install from kubuntu-8.04.1-alternate-i386.iso
    0?rem
    1?rem
    2?rem
  10. in the root folder, make an "autoexec.bat" file, which manipulates files and invokes the loader:
    rem common preparation
    cd \hardy
    ren *.iso *.isn

    rem select distro
    if "%config%"=="1" ren amd64-k.isn amd64-k.iso
    if "%config%"=="2" ren i386-k.isn i386-k.iso

    rem run distro
    if "%config%"=="1" \grub --config-file=\hardy\amd64-k.lst
    if "%config%"=="2" \grub --config-file=\hardy\i386-k.lst

    cd \

unmount the usb device to be sure all get saved and reboot.

Wednesday, December 10, 2008

Multi-booting from USB stick

While still looking for a better way to boot several OS distributions, I'm writing down the one I use with satisfaction.
There are a lot of how-tos about the topic on the web: they often contain steps which are distribution-specific, like renaming or moving folders to other locations, in order to avoid conflicts, for example. I dont'like it. I like, instead, a more general, systematic way:

  1. suitably partition (FAT filesystem) the usb drive:


    • the first primary partition, with the bootable flag set, reserved to hold some shared data (some operating system do recognize only the first one on removable media), and to hold a bootmanager to deal with the multi-boot scheme;

    • allocate (generally) one partition per distro to avoid conflicts;


  2. copy the distro (generally the content of an .iso image) on its devoted partition;

  3. install syslinux on that partition;

  4. edit "syslinux.cfg" accordingly; if the distro comes from a bootable .iso, most of the time it's enough to:


    • copy the "isolinux" folder over the "syslinux" one;

    • in the new folder "syslinux", rename "isolinux.cfg" to "syslinux.cfg";


  5. install a bootmanager, like Grub4DOS, to the master boot record of the bootable partition;

  6. in the bootmanager menu, add an entry for each partition to chainload its own syslinux.

Tuesday, September 30, 2008

Grub chainloads syslinux and back

Some introductory considerations:
  • Booting from an USB device with GRUB is quite easy (here and there..).
  • Booting from an USB device with syslinux is also quite easy (here).
  • Chainloading GRUB from syslinux seems not to be possible without tricks: syslinux boots from the boot record and sees its own partition only, thus GRUB should reside on the same partition and be packaged as an "xxxx.bin" file to be passed to syslinux via the "kernel /path_to/xxxx.bin" directive. Never tried and I'll never too, until I'll not find somehow useful.
  • Chainloading syslinux from GRUB seems not to be possible without a patch. I don't know about GRUB2. This could be useful for multi-booting (syslinux-based) partitions.
  • Chainloading GRUB4dos from syslinux is possible, because "grub.exe" can reside on the same FAT partition where syslinux is. Only an entry in "syslinux.cfg" with the "kernel /path_to/grub.exe" directive is needed
  • Chainloading syslinux from GRUB4dos (on the same partition) should be possible because GRUB4dos is more flexible than GRUB, but I didn't manage to make it work, even if I tried all combinations of paths, mappings and syntaxes, like here.
  • Chainloading syslinux from GRUB4dos (on different partitions) is possible. I managed it through the mapping, explained (again) here. It solves some problems in multi-booting usb devices.

To load syslinux (on different partitions) from GRUB4dos, my steps were:
  1. take a partitioned device;
  2. take the first primary partition, formatted as FAT;
  3. get GRUB4dos and install it on the master boot record of that partition;
  4. get syslinux and install it on (some of) the other partitions;
  5. edit "menu.lst" in the proper grub4dos folder in order to chainload syslinux with the entry:

    title -your entry title-
    map (hdx,y)+1 (fd0)
    map --hook
    root (fd0)
    chainloader +1
    boot

    where x and y identify the syslinux-based partition in the usual grub-style form.
    I tried to map the syslinux-based partition to an "hd_" device instead of "fd0", but no success: I don't know why.