Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

my girlfriend bought Lenovo Essential G500 i5-3230 and I installed Linux Mint 16 on it with full disk encryption. It is standard installation with encryption using dmcrypt and LUKS. But there is a problem with screen brightness, it is set to 0 before it even ask for password to encrypted partitions. I partly fixed it by adding:

echo 50 > /sys/class/backlight/acpi_video0/brightness

to /etc/rc.local but it fixes brightness after typing correct password to mount encrypted partitions. I want to fix brightness before that, so I can see the password input field. /etc/rc.local is loaded after mounting encrypted disk so I think I need to somehow force kernel to change brightness just after it loads itself and before mounting.

Is there a way to tell kernel to adjust brightness just after boot?

Graphic cards on laptop are: AMD® Radeon HD 8570M + Intel HD Graphics 4000

UPDATE

I've tried solution sugested by @derobert. I created initramfs script /etc/initramfs-tools/scripts/init-premount/local-backlight-brightness

#!/bin/sh
PREREQ=""
prereqs()
{
    echo "$PREREQ"
}

case $1 in
    prereqs)
        prereqs
        exit 0
    ;;
esac

. /usr/share/initramfs-tools/hook-functions
# Begin real processing below this line

echo 50 > /sys/class/backlight/acpi_video0/brightness

And after this:

$ sudo chmod a+rx /etc/initramfs-tools/scripts/init-premount/local-backlight-brightness
$ sudo update-initramfs -u
$ sudo reboot

But it don't work, screen is almost black when asking for password. I'm not even sure if this script was executed. How can I check if it was executed? Maybe I should add some requirements in PREREQ="" to make it work?

UPDATE 2 FINALLY WORKING

Ok, I decided to read manual for initramfs-tools again to check if everything was good and it looks like I used wrong boilerplate for my script. The correct one is:

#!/bin/sh
PREREQ=""
prereqs()
{
    echo "$PREREQ"
}

case $1 in
prereqs)
    prereqs
    exit 0
    ;;
esac

. /scripts/functions
# Begin real processing below this line

echo 50 > /sys/class/backlight/acpi_video0/brightness

The problem was with . /usr/share/initramfs-tools/hook-functions. This line was used for hook scripts that are not included in intramfs image. It should be . /scripts/functions. After changing it, brightness works like I wanted.

I'm marking @derobert answer as correct because it directed me to correct solution.

share|improve this question
    
The easy way to make sure it was executed (if you can read the screen at all) is to use echo and print out some messages. E.g., put echo "SETTING SCREEN BRIGHTNESS" above the other echo line. –  derobert Mar 25 at 20:27
    
I think it would not be possible because there is playmouth image with linux mint logo. Can I somehow write some message to a boot log file if there is such file? –  piotrekkr Mar 25 at 20:37
    
Ah, I didn't realize it was graphical... any chance you can turn that off temporarily? Other that, there should be some command to write to the graphical screen. Not sure what it is... all mine are text-mode :-/ –  derobert Mar 25 at 20:38
    
I see that there are some functions for logging: log_success_msg, log_failure_msg etc. I'm not sure if they will print anything to screen when playmouth image is displayed. I'll try them tomorrow. –  piotrekkr Mar 25 at 20:49

1 Answer 1

up vote 3 down vote accepted

You need to add that script to your initramfs. On Debian (I suspect Mint is the same), it appears that the password prompt comes from /usr/share/initramfs-tools/scripts/local-top/cryptroot. That script arranges itself to be called last out of the local-top scripts. There is a parallel set of directories in /etc intended for local customization. So you just need to plop a file that looks something like:

#!/bin/sh
PREREQ=""
prereqs()
{
     echo "$PREREQ"
}

case $1 in
prereqs)
     prereqs
     exit 0
     ;;
esac

echo 50 > /sys/class/backlight/acpi_video0/brightness

into either /etc/initramfs-tools/scripts/local-top or /etc/initramfs-tools/scripts/init-premount. The file name doesn't matter, though I'd pick something like local-backlight-brightness to make sure it doesn't conflict with some package-provided script. (The prereqs boilerplate comes straight from the initramfs-tools manpage.)

Then, run update-initramfs -u.

share|improve this answer
    
What happens when I update my kernel using update manager or synaptic? Will this script be automatically added to initramfs or do I need to run update-initramfs -u after each update? I'll try your answer this weekend. –  piotrekkr Feb 26 at 19:19
    
@piotrekkr It'll be automatically added. Your kernel update actually runs update-initramfs behind the scenes (in fact, when you run update-initramfs the messages it prints out should look familiar). –  derobert Feb 26 at 19:21
    
I've tried your solution but it didn't work. See my updated question. –  piotrekkr Mar 25 at 20:26
1  
I was using wrong boilerplate. Your solution is good after using boilerplate from linux mint initramfs manual. Thank you. –  piotrekkr Mar 25 at 21:23

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.