# Howto TuxOnIce and Fbsplash: Yet Another Perfect Way

## ketetefid

I have some spare time, so I thought it would be nice to share some information and make a mini-howto for the nice OS; to post something in the forum after around 6 years.   :Wink: 

The goal: To setup a working fbsplash-enabled system for a tuxonice kernel in all power transitions including startup, shutdown, hibernation and resume.

But you might think that it is already supported and is working well. Yes, it is supported but there are some difficulties to get the fbsplash working in a perfect way and I will explain the problems later. 

Step 1. Get the gentoo-sources, preferably. If you would like the tuxonice-sources, that is no problem, but they are not very uptodate. Furthermore, we want to have only the supported kernel (!). So keyword the latest gentoo-sources and install it, if you have not already done. The latest available version is 3.8.8. Another option is to install pf-sources which already has tuxonice, but, well, is not supported.

```
 emerge gentoo-sources 
```

Step 2. Then, go to http://tuxonice.net/downloads/all/ and download the appropriate patch for your kernel. If there is not one, get the closest and patch the kenel:

```
cd /usr/src/linux

patch -p1 </path/tuxonice-for-linux-3.8-8-2013-04-24.patch --dry-run # To check that everything will work or not, and if it showed no problem, then:

patch -p1 </path/tuxonice-for-linux-3.8-8-2013-04-24.patch

```

Now, using the http://en.gentoo-wiki.com/wiki/TuxOnIce,  configure your new kernel and install it. Remember, when setting "Default userui program location", use "/sbin/tuxoniceui -f". This is very important. If you set it to something else, you might not have the eyecandy. The wiki is a little out of date and should be updated.

Step 3. Keyword (if needed) and install the latest tuxonice-userui package.

```

emerge tuxonice-userui
```

OK. Up to this point, you have the gear installed. Boot the new kernel.

At this time, we want to setup fbsplash. There are two clear options and neither of them work perfectly:

Option No. 1. Make an initramfs using the splashutils as discussed in http://en.gentoo-wiki.com/wiki/Fbsplash. While startup and shutdown processes would work, you would encounter some problems in hibernation/resume processes. In the resume process it would start late and it would plague you with "Failed to launch userspace program '/sbin/tuxoniceui': Error -2". And you will be wondering while it is right there, why it cannot find it. The answer is that the initramfs needs a customized init script. Wow.

Option No. 2. Keyword and install dracut: http://wiki.gentoo.org/wiki/Dracut. It is a very nice tool to make custom initrd images. Using "gensplash" module is supposed to give you fbsplash, but you will get nowhere, since it will not bring what you wanted to you. Not only there is not a "tuxonice" module for dracut yet (and someone please bring it to the portage from https://github.com/milo000/dracut-tuxonice and add it to dracut's optional modules), but also the new initrd image will boot late. Far later than ideal.

OK. Before getting panic, follow the next step to make "a custimized initrd for fbsplash and tuxonice".

Step 4. Keyword and install dracut. Do *not* enable gensplash. Like this:

```
emerge -pv dracut

[ebuild   R   ~] sys-kernel/dracut-027-r1  USE="optimization -debug -device-mapper -net (-selinux)" DRACUT_MODULES="-biosdevname -bootchart -btrfs -caps -cifs -crypt -crypt-gpg -crypt-loop -dmraid -dmsquash-live -gensplash -iscsi -livenet -lvm -mdraid -multipath -nbd -nfs -plymouth -ssh-client -syslog -systemd"

```

The optimization flag is not important, but you can enable it like what I did. It feels like it will give you a better image since it does not produce warnings, unlike when you have not enabled it. If you have a different setup (like lvm, etc.), then manage it and enable the needed modules accordingly.

Then, create the needed directory and the file /usr/lib/dracut/modules.d/40tuxonice/module-setup.sh with the following contents:

```
#!/bin/bash

check() {

    return 0

}

depends() {

    return 0

}

install() {

    dracut_install /sbin/tuxoniceui

}
```

It was as easy as cake to include tuxonice in the dracut initrd image, wasn't it? 

Make it executable:

```
chmod +x /usr/lib/dracut/modules.d/40tuxonice/module-setup.sh 
```

Now you can produce the first half of the needed image:

```

dracut -Hf
```

It will make an initrd image full of nice things, including tuxonice userspace program but devoid of fbsplash. Since the image has other useful things by default, it might be a little heavy and will boot a little late. And if you are like me who always compares gentoo with Ferrari Enzo, and you want everything as fast as possible and yet stable, edit the file /etc/dracut.conf and change the appropriate line to include only a minimal environment for the image:

```
# Exact list of dracut modules to use.  Modules not listed here are not going

# to be included.  If you only want to add some optional modules use

# add_dracutmodules option instead.

dracutmodules+="rootfs-block tuxonice" 

```

Now, rebuild the image with dracut -Hf. The image will automatically be put in /boot/initramfs-3.8.8-gentoo.img.

Step 5. Follow http://en.gentoo-wiki.com/wiki/Fbsplash and install splashutils. At this point we just want to include fbsplash in the generated initrd. Thus, use the append feature of splash_geninitramfs and:

```
splash_geninitramfs --verbose --res 1366x768 --append  /boot/initramfs-3.8.8-gentoo.img livecd-2007.0
```

Replace livecd-2007.0 with your desired theme that *has* your desired, supported resolutions. Replace 1366x768 with your desired, *supported* resolution by your framebuffer device. Some devices cannot have even normal resolutoins like 1920x1080, since the framebuffer does not support it.

```
cat /sys/class/graphics/fb0/modes
```

And pick one. You might have to pick another one, if the splash_geninitramfs did not find the specific config for that resolution. I hope somebody will include these in the wiki so nobody will get into problems.

Now do the following:

```
ln -s /etc/splash/livecd-2007.0/ /etc/splash/tuxonice/
```

Change the theme if you want.

If you feel you have missed something, check the tuxonice and fbsplash wikis. Don't forget to append an initrd line in your grub.conf.

OK. At this point you have a fully working initrd image. It won't lag or won't be able not to find the needed programs.

However, However, However,.....

If you click on hibernate button in kde for example, you will be greeted with a blank screen with a blinking cursor during hibernation or resuming! All of this is because kde and gnome rely on pm-utils. And that needs more tweaking. 

OK. Just continue: Install hibernate-script.

```
emerge hibernate-script
```

and

```
rc-update add hibernate-cleanup boot
```

Do the following for tuning tuxonice to get it completely ready:

- The file /etc/hibernate/tuxonice.conf should look like this:

```
# Example tuxonice.conf file.

# 

# See hibernate.conf(5) for help on the configuration items.

#

# NOTE: TuxOnIce is an improved version of suspend-to-disk which currently

#       requires patching your kernel. For more information, see www.tuxonice.net

# 

#       If you do not wish to patch your kernel but still be able to suspend to

#       disk, see disk.conf instead.

### TuxOnIce

UseTuxOnIce yes <--------------------------------------------------Pay attention here

Reboot no

EnableEscape yes

DefaultConsoleLevel 1

Compressor lzo  <---------------------------------------------------Pay attention here

Encryptor none

# ImageSizeLimit 200

## useful for initrd usage:

# SuspendDevice swap:/dev/hda2

## Powerdown method - 3 for suspend-to-RAM, 4 for ACPI S4 sleep, 5 for poweroff

# PowerdownMethod 5

## Any other /proc/software_suspend setting can be set like so:

# ProcSetting expected_compression 50

## Or traditionally like this:

# TuxOnIceAllSettings 0 0 2056 65535 5

## Or even from the results of hibernate --save-settings with this:

# TuxOnIceAllSettingsFile /etc/hibernate/suspend-settings.conf

## For filewriter:

# FilewriterLocation /suspend_file 1000

# VerifyFilewriterResume2 yes

## Specify a userui like this:

ProcSetting userui_program "/sbin/tuxoniceui -f" <--------------------------------------Pay extreme attention here

# Scale CPU to full speed to make sure we suspend as fast as possible.

FullSpeedCPU yes

Include common.conf

```

- The file /etc/hibernate/hibernate.conf should look like this (The order is important I think):

```
TryMethod tuxonice.conf

TryMethod disk.conf

TryMethod ram.conf

```

Some other options might be needed to be enabled in the  /etc/hibernate/hibernate.conf file (e.g. for nvidia/ati). The other files in /etc/hibernate should be OK, though they might need more tweaking. 

Now you can test your *perfect* installation by executing:

```
hibernate
```

There should be no lag and fbsplash should be present until late shutdown and at early boot. A little flickering, when the process is transmitted from the initrd to the openrc layout, is OK and cannot be avoided.

But why kde can't do this? As was said earlier, kde and gnome use pm-utils and pm-utils has its own behavior. The creator of tuxonice has built hibernate-script package with better integrity with tuxonice. The point is that you have to make kde and gnome use hibernate-script commands instead of their own ones. And that is quite easy. The last step:

Step 6. Tweak the following files to force the DE to use hibernate-script executables:

-The file /etc/pm/config.d/gentoo should look like this:

```

HOOK_BLACKLIST="01grub 90clock"

SLEEP_MODULE="tuxonice"
```

-The file /usr/lib/pm-utils/module.d/tuxonice must be edited as follows:

```
if [ -z "$HIBERNATE_MODULE" -a -n "$TUXONICE_LOC" ] && \

        [ -f "${TUXONICE_LOC}/do_hibernate" ]; then

        HIBERNATE_MODULE="tuxonice"

        do_hibernate()

        {

            toi_maybe_chvt

            echo 5 > "${TUXONICE_LOC}/powerdown_method"

            #echo anything > "${TUXONICE_LOC}/do_hibernate"    <---------------------------Look for this line in the file and comment it, as I did

            /usr/sbin/hibernate     <------------------------------------------------------------------Add a new line like this

        }

fi
```

Now, everything must work perfectly. Enjoy the fully splash-enabled system.

I have not created any methods here, so the credit goes to those nice people who provided these and I cannot enumerate them. I just put them together here.

I hope I will have enough time to post another mini how to about a *perfect* power management in laptops. It will enable the user to get at least the advertised work hour from their battery, though I get even more than the advertised value with 65% backlight. So, stay tunned....

Comments are completely welcome. I hope I have not missed anything.

I am sorry if some things looked funny here or if my logic was wrong. I am just a user.

----------

## simon_irl

thanks for this howto...i'm working through it now. just one question: is there a reason for installing gentoo-sources and patching it manually rather than just installing tuxonice-sources? according to the package description sys-kernel/tuxonice-sources is "TuxOnIce + Gentoo patchset sources", so my interpretation of that is that it's basically the same result as installing gentoo-sources and patching it...?

[edit]...LOL...doh, i just had another look and it answers my own question...tuxonice-sources is still at v. 3.7.1, whereas the 3.8.8 patch from tuxonice applied with no problems to gentoo-sources 3.8.10...so that's all good...i'll keep working through your guide...looking forward to the results   :Wink: 

[edit2]...hmm...although the fact that it takes all of five seconds to download the tuxonice patch and five more to patch gentoo-sources does raise the question, WHY is tuxonice-sources still at 3.7.1?? on the one hand it doesn't really matter (since patching gentoo-sources *is* so quick and easy), but still, if it's there in portage, it might as well be kept in sync with gentoo-sources.  /me shrugs

----------

## Hypnos

This would make a nice article on wiki.gentoo.org , maybe link to it from the Dracut article.

----------

