Fedora Linux 20 on Sony Vaio Y

I recently switched from Debian to Fedora on my laptop, a Sony Vaio VPCY11S1E. A bit of an experiment: I decided that I knew too little of the Red Hat world and because I do admin some RHEL-based boxen I should learn more. And whats the best way to learn? Right, using it. To throw myself in the deep end I also decided the DE of choice would be GNOME 3, which comes by default on Fedora.

To be fair, I’m not totally new to both Fedora and GNOME 3. But the last Fedora I tried was Fedora Core 2, almost 10 years ago, back in the days when I was just getting acquainted with Linux and had little to no clue what everything was. And GNOME 3 I gave a whirl when version 3.0 was just released, which clearly wasn’t a finished product: it was unstable, the workflow was awkward so that left a bad taste in my mouth. I migrated to XFCE and KDE soon after and used those ever since.

In this blog I’m not going to bore you with the installation of Fedora, you can try that yourself. This is more of a log of system tweaks performed after installation, for my own documentation purposes and perhaps to help others out, especially with the brightness issue.

Fixing stuff

Non-functioning Brightness keys

The following fix seems to work for most people:

  1. Edit GRUB2 kernel boot line:

    # vi /etc/default/grub
    

Add acpi_backlight=vendor to GRUB_CMDLINE_LINUX=

  1. Re-create the GRUB2 config:

    # grub2-mkconfig -o /boot/grub2/grub.cfg
    
  2. Reboot to boot with the changed kernel boot parameters

  3. Check if the kernel was actually started with the new parameter:

    # cat /proc/cmdline
    

The output should contain the acpi_backlight=vendor you added earlier.

  1. Test your backlight? If it works now, enjoy! But for my laptop it still did not behave as it should. Seems I’m not most people, and my laptop is not most laptops…

Let’s investigate

What backlight devices do I have?

# ls /sys/class/backlight/
intel_backlight  sony

Seems I have two: One from the Intel i915 module and another from the sony_laptop module. My bet was that the system was now using the sony backlight device

To test this theory I tried to set the brightness using the command line. First I retrieved the current setting, followed by the maximum defined by the module, and setting a value somewhere in between. This should change my brightness… or not…

# cat /sys/class/backlight/sony/brightness 
-1
# cat /sys/class/backlight/sony/max_brightness 
7
# echo 2 > /sys/class/backlight/sony/brightness

Aaaannd… nothing happened.

Let’s have a look at the intel_backlight and try the same thing:

# cat /sys/class/backlight/intel_backlight/brightness 
1992060
# cat /sys/class/backlight/intel_backlight/max_brightness 
1992060
# echo 1400000 > /sys/class/backlight/intel_backlight/brightness

Hey presto! My brightness just lowered. So, this driver works for me… why is my system not using this? How can I instruct it to use this backlight device instead? Telling X.org about it seems like a good place to start. So I started to do some digging, and came across an interesting bit on the Arch Linux Wiki - Intel Graphics.

  1. I created ‘/etc/X11/xorg.conf.d/20-intel.conf’ and filled it with:

    Section "Device"
            Identifier  "card0"
            Driver      "intel"
            Option      "Backlight"  "intel_backlight"
            BusID       "PCI:0:2:0"
    EndSection
    
  2. Reboot once more.

Now I had a working backlight slider and I could control my brightness using the Fn+F5/F6 keys on my (older) Sony Vaio Y (VPCY11S1E) series laptop. Two years after using two shell scripts that were called when I pressed Super+F5/F6 and changed the brightness for me by calculating the current value and lowering/increasing it by a percentage.

The rest of my hardware worked “out-of-the-box”, so I was done fixing stuff. On to tuning!

Performance tweaks

Tune /etc/fstab for an SSD

My SSD supports the TRIM command to clear freed blocks, most SSDs do nowadays, but you can check with: # hdparm -I /dev/sda | grep TRIM. Clearing blocks that have been freed in the file-system helps prevent degradation of the write speed of the SSD.

The Fedora aligns partitions automatically, so there’s no need to worry about that. But you do need to enable the discard option so the kernel and file-system actually use TRIM. Another option you can set is noatime, which disables writing access times to files. You probably do not need those anyway, and if you really do, the default relatime will do. I tend to set noatime for everything but my /home, which I keep on relatime.

Open /etc/fstab with your favorite editor. You can replace vi with your favorite, nano is my recommendation for beginners.

$ sudo vi /etc/fstab

And change the 4th column to reflect these changes. Don’t touch your UUIDs, because those are (or should be) unique to you.

UUID=dde35b21-e6f1-4057-b495-5463b863acab /                       ext4    defaults,discard,noatime        1 1
UUID=b7653d9a-27fd-4e21-96a3-98a2f22c9cbb /boot                   ext4    defaults,discard,noatime        1 2
UUID=30ee7116-69a7-4726-b4d2-4a3d85c1c16e /home                   ext4    defaults,discard,relatime       1 2
UUID=977b62bd-d69d-4e05-a6dc-1646006b33be swap                    swap    defaults                        0 0

Check your changes for mistakes, and if you’re happy save the file. To activate the new settings you can re-mount all the partitions you changed, or you could reboot. I did the first like this:

$ sudo mount -o remount /
$ sudo mount -o remount /boot
$ sudo mount -o remount /home

Run mount to see if the file-systems are mounted with the new options.

Tune the kernel boot parameters for an SSD

By default the kernel’s I/O scheduler is cfq, which stands for Completely Fair Queuing. This is a complex scheduler that favors real-time reads and puts other types of I/O on a queue, to handle them off in an intelligent order when using a conventional hard drive. This all has to do with latency, of which a spinning disk has loads compared to an SSD. If you use only an SSD, like I do, you can change the global I/O scheduler by configuring the kernel boot parameters. I set mine to noop, but you can also try deadline. They do not differ much in terms of performance, and to find minor differences you will have to run benchmarks.

  1. Edit GRUB2 configuration to alter the kernel boot line:

    # vi /etc/default/grub
    

    Add elevator=noop to the GRUB_CMDLINE_LINUX= line, and save the file.

  2. Regenerate the GRUB2 configuration, or do this at the end of this blog:

    # grub2-mkconfig -o /boot/grub2/grub.cfg
    

Next boot the I/O scheduler will be changed to noop. You can also change it on the fly. For example for device /dev/sda:

# echo noop > /sys/block/sda/queue/scheduler

Power saving

Because this is a laptop, I do like to save power where I can do so easily. Which comes down to instructing the kernel and it’s modules to enable certain power-saving options.

A list of the options I use in alphabetical order:

  • i915.i915_enable_rc6=3 , this option enables the use of deep power down states for the GPU. I believe this is on by default for more recent Intel GPUs, but it is not for pre-Sandy Bridge hardware and also not for my onboard Intel GMA X4500MHD (integrated graphics in the Intel GM45 chipset), because it can cause stability issues. I do not experience any issues with this enabled, and it really helps save energy for me. If you have not tried this, start off with setting 1 instead of 3. When 1 works, try 3, when that also works you can try 7. Each enables a deeper sleep state, there are 3 of them, and option 7 enables them all. I use 3 on my laptop, because 7 is not stable for me.

  • i915.lvds_downclock=1 , tries to save power by downclocking the LVDS refresh rate. If your system does not support this, you might experience some screen flicker. Power saved by this is quite marginal, but every little bit helps when you’re working on battery power.

  • snd_hda_intel.power_save=10 , this sets the time out after which the Intel HDA sound system will power down parts of the audio codec and audio bus. Also check if the check for this timeout has been enabled at all with cat /sys/module/snd_hda_intel/parameters/power_save_controller which should return an Y. If you experience a click sound now and then, this can be due to the power saving. If it’s really annoying, you can always disable power saving by setting this value to 0.

I again open the GRUB2 configuration file:

# vi /etc/default/grub

And add these options to my GRUB_CMDLINE_LINUX. Now my complete line looks like this:

GRUB_CMDLINE_LINUX="vconsole.font=latarcyrheb-sun16 $([ -x /usr/sbin/rhcrashkernel-param ] && /usr/sbin/rhcrashkernel-param || :) rhgb quiet acpi_backlight=vendor elevator=noop i915.i915_enable_rc6=3 i915.lvds_downclock=1 snd_hda_intel.power_save=10"

Save the file and regenerate the GRUB2 configuration (again):

# grub2-mkconfig -o /boot/grub2/grub.cfg

And reboot to test the tweaks. Done!

I hope these tweaks are helpful to someone else as well.

blogroll

social