Tuesday, July 17, 2012

Tip: Fixing "gnome-screenshot" (No such file or directory) on CentOS 6.3

While pressing Prnt Scrn to take a window screenshot I got awarded with "cool" Metacity message window stating the following:

  1. There was an error running gnome-screenshot:Failed to execute child process "gnome-screenshot" (No such file or directory)

I'm running a fresh CentOS 6.3 system installed using the x86_64 Live CD which shortly after installing it noticed that it didn't came with Disk Usage Analyzer. Putting the error message and the missing application points the problem to the package that provides both gnome-utils.

To fix the problem and also install the other missing applications:
 
  1. $ su
  2. # yum install gnome-utils -y

And that's it!

Tip: Blacklisting kernel modules on CentOS 6.3

While trying the kernel-ml from the ELRepo repository I noticed that it ships with the pcspkr.ko kernel module which is in my opinion pretty annoying. 

To unload a kernel module, for instances pcspkr.ko, simply issue the rmmod command with the kernel module as argument. However this will only take place for the current session, the next time you reboot the machine hte kernel module will load. To prevent this we need to blacklist it by adding it to /etc/modprobe.d/blacklist.conf.

Putting everything together:

  1. $ su
  2. # rmmod -v pcspkr
  3. # echo "blacklist pcspkr" >> /etc/modprobe.d/blacklist.conf

On step 1 we've changed to superuser, on step 2 the kernel module (pcspkr was selected as an example) was removed from the current session and on step 3 we've prevented it from loading at boot.

As a side note, to list the currently loaded kernel modules run lsmod.

Sunday, July 15, 2012

Tip: Remove xen-runtime from kernel-xen repository

Lately I've been messing with Xen.

In the process of using the kernel-xen repository I came across the following situation while attempting to uninstall xen-runtime:
  1. # yum remove xen-runtime
    Loaded plugins: fastestmirror, refresh-packagekit, security
    Setting up Remove Process

    Resolving Dependencies

    --> Running transaction check
    ---> Package xen-runtime.x86_64 0:4.1.2-8.el6 will be erased
    --> Finished Dependency Resolution
    Dependencies Resolved
    ==================================================================
      Package Arch Version Repository Size
    ================================================================== Removing:
      xen-runtime x86_64 4.1.2-8.el6 @kernel-xen 8.0 M

    Transaction Summary
    ==================================================================
    Remove 1 Package(s)

    Installed size: 8.0 M
    Is this ok [y/N]: y
    Downloading Packages:
    Running rpm_check_debug
    Running Transaction Test
    Transaction Test Succeeded
    Running Transaction
    Error in PREUN scriptlet in rpm package xen-runtime
    xen-runtime-4.1.2-8.el6.x86_64 was supposed to be removed but is not!
      Verifying : xen-runtime-4.1.2-8.el6.x86_64 1/1

    Failed:
      xen-runtime.x86_64 0:4.1.2-8.el6
    Complete!
  2. # rpm -e xen-runtime
    /var/tmp/rpm-tmp.LcPd6z: line 5: /bin/systemctl: No such file or directory
    error: %preun(xen-runtime-4.1.2-8.el6.x86_64) scriptlet failed, exit status 127

To remove the little bastard the --nopreun needs to be passed down to rpm -e. By doing so the execution of the %preun scriptlet is turned off thus allowing rpm to uninstall the offending package, like so:
  1. # rpm -e --nopreun xen-runtime

Done!

Now I can go back to messing with Xen ;)

Saturday, July 14, 2012

HowTo: Install Adobe Flash Player using Repoforge on CentOS 6.3

To install Adobe Flash Player on RHEL or CentOS 6.3 using the Repoforge repository, you'll need to change to root, import repository's GPG key, install the repository file and install the Adobe Flash Player package.

If you're running a 32 bits system:
  1. $ su
  2. # rpm --import http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt
  3. # rpm -Uvh http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.i686.rpm
  4. # yum install flash-plugin

On the other hand, if you have a 64 bits install issue the following commands:
  1. $ su
  2. # rpm --import http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt
  3. # rpm -Uvh http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm
  4. # yum install flash-plugin

Launch Mozilla Firefox and in the address bar enter about:plugins. An Shockwave Flash entry should be available.

If you point to System -> Preferences you'll notice that a new entry named Adobe Flash Player is now available.

You can test if the plugin is working by visiting http://www.adobe.com/software/flash/about or by firing up a random Youtube clip.

If you'd prefer to using Adobe's own YUM repository follow the steps described in http://linux-bsd-sharing.blogspot.pt/2012/05/howto-install-adobe-flash-player-on.html and http://linux-bsd-sharing.blogspot.pt/2012/04/howto-install-adobe-flash-player-on.html for 64 and 32 bit systems, respectively.

Monday, July 9, 2012

HowTo: Enable Wake-on-LAN on CentOS / SL 6.3

Wake-on-LAN also know as WOL is the ability to switch on a computer that is connected to a network (local or not) by means of a special network message called a magic packet. This magic packet contains the MAC address of the destination computer. If the destination computer has a network interface card that support WOL then the system wakes up.

In this post I'll describe how to setup a CentOS destination computer so that it can be turned on from another computer. This procedure is also applicable to RHEL and its clones such as Scientific Linux and Oracle Unbreakable Linux.

For sake of simplicity I've broken down the procedure into a few steps:
1) Enable WOL in BIOS
2) Collect network interface information
3) Enable WOL for the next shutdown
4) Make WOL always enabled
5) Wake up the computer from local network
6) Wake up the computer from internet
7) Troubleshooting

1) Enable WOL in BIOS

These days pretty much all integrated or otherwise NICs support Wake-on-LAN, however more often than not you'll need to enable it in the BIOS. There are literally hundreds of BIOS around but look for the typical options: "Enable Wake-on-LAN", "Enable Wake on PCI" and "Enable Power of PCIE Devices".

2) Collect network interface information

Start by checking if the destination computer network card support Wake-on-LAN with ethtool:
  1. $ ifconfig
    eth0      Link encap:Ethernet  HWaddr 00:11:AA:22:BB:22 
              inet addr:192.168.1.5  Bcast:192.168.1.255  Mask:255.255.255.0
              inet6 addr: fc70::151:8daa:fbab:f14a/64 Scope:Link
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              RX packets:563668 errors:0 dropped:0 overruns:0 frame:0
              TX packets:317604 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1000
              RX bytes:813741621 (776.0 MiB)  TX bytes:68592900 (65.4 MiB)
              Interrupt:22 Base address:0xa000

    lo        Link encap:Local Loopback 
              inet addr:127.0.0.1  Mask:255.0.0.0
              inet6 addr: ::1/128 Scope:Host
              UP LOOPBACK RUNNING  MTU:16436  Metric:1
              RX packets:8 errors:0 dropped:0 overruns:0 frame:0
              TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:0
              RX bytes:480 (480.0 b)  TX bytes:480 (480.0 b)
  2. $ su
  3. # ethtool eth0
    Settings for eth0:
        Supported ports: [ MII ]
        Supported link modes:   10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
        Supports auto-negotiation: Yes
        Advertised link modes:  10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
        Advertised pause frame use: No
        Advertised auto-negotiation: Yes
        Speed: 100Mb/s
        Duplex: Full
        Port: MII
        PHYAD: 1
        Transceiver: external
        Auto-negotiation: on
        Supports Wake-on: g
        Wake-on: d
        Link detected: yes

The "Supports Wake-on: g" string means that the NIC does in fact support Wake-on-LAN while "Wake-on: d" is a sign that the feature is not turned activated in the operating system.

Do notice that the target of ethtool was eth0 which is my destination computer's network interface name.

To use Wake-on-LAN we need to identify the NIC MAC address to which end ifconfig can be used:
  1. # ifconfig | grep HWaddreth0 Link encap:Ethernet HWaddr 00:11:AA:22:BB:22
 

3) Enable WOL for the next shutdown

To command the operating system to enable WOL for the eth0 network interface run:
  1. # ethtool -s eth0 wol g

Issuing ethtool again now returns "Wake-on: g" so now we have WOL enabled:
  1. # ethtool eth0
    Settings for eth0:
        Supported ports: [ MII ]
        Supported link modes:   10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
        Supports auto-negotiation: Yes
        Advertised link modes:  10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
        Advertised pause frame use: No
        Advertised auto-negotiation: Yes
        Speed: 100Mb/s
        Duplex: Full
        Port: MII
        PHYAD: 1
        Transceiver: external
        Auto-negotiation: on
        Supports Wake-on: g
        Wake-on: g
        Link detected: yes

4) Make WOL always enabled

To have WOL always enabled the operating system needs to be told that eth0 (this is my NIC's interface name, don't forget to change according to your own system) WOL is supposed to be active.

There are 2 methods to achieve this, one employs adding ethtool -s eth0 wol g command to /etc/rc.d/rc.local while the other consists in creating a network script and enabling the network service.

Choose one of the methods, personally I'd go for the /etc/rc.d/rc.local method as it requires less typing ;)

Method A

  1. #echo '/usr/sbin/ethtool -s eth0 wol g' >> /etc/rc.d/rc.local

Method B
  1. # vim /etc/sysconfig/network-scripts/ifcfg-eth0
    DEVICE=eth0
    TYPE=EThernet 
    ONBOOT=yesETHTOOL_OPTS="wol g"
  2. # chkconfig network on

5) Wake up the computer from local network

From the computer that will be used to send the magic WOL packet, install and run wakelan:

  1. # yum install wakelan
  2. # rehash
  3. # wakelan 00:11:AA:22:BB:22

6) Wake up the computer from internet

This involves enabling port forwarding of UDP port 9 to the destination computer in the router's administration webpage. To fully benefit from WOL you should configure a dynamic DNS service.

Afterwards to issue the wake up command you can use websites such as http://wakeonlan.me, Android applications (Wake on Lan) or any other Wake-on-LAN application (every Unix-like system as an alternative available). Just make sure to use your dynamic DNS provided address and the destination computer's MAC.

7) Troubleshooting

While troubleshooting Wake-on-LAN I've noticed that if you use GRUB without timeout set and poweroff the computer while on the operating system selection menu, the next time you try to use Wake-on-LAN it won't work. So make sure you have GRUB with a timeout set (which is the case will all default installation of GRUB).

If the computer is disconnected from the power supply you'll need to boot the computer and turn off again so that the NIC assumes the WOL definitions.