Saturday, July 11, 2015

CD-ROM won't mount, I/O error dev sr0 sector

Some CD's I have burnt myself do not mount in Sabayon Linux. dmesg shows the following errors:
end_request: I/O error, dev sr0, sector nnnnnnn
Buffer I/O error on device sr0, logical block nnnnnnn

 Specifying the type (iso9660) and uid & gid allows the CD's to mount:
sudo mount -t iso9660 /dev/sr0 /media/cd -o uid=`id -u`,gid=`id -g`

Not sure if this is a result of the media (Imation) or Linux/Windows burning - suspect it is the Gnome Disk Utility - Disk Image Writer.

Friday, June 5, 2015

Plymouth splash not correct in Sabayon

After a Sabayon 13 update in May 2015, new artwork is locked in the initrd file system.  Dracut builds of the initramfs kernal image file system are not used by the system.

To repair Plymouth functionality:

  • Remove dracut
  • Install updated gcc package
  • Install genkernel-next
  • Set the preferred theme in /etc/plymouth/plymouth.conf
  • Backup the current initramfs file
  • Run genkernel initramfs
  • Reboot

Saturday, May 30, 2015

xdg-su not decorated with theme

LXDE on OpenSuse 13.2 uses xdg-su ass the GUI frontend to run applications using sudo. If it can't load gnomesu or kdesu then it presents a bland undecorated xterm window. This can be neatened by simply installing libgnomesu which is small with only 1 dependancy (it doesn't need a full gnome desktop!).

Install Screengrab for screenshots on OpenSuse

LXDE doesn't have a default screenshot grabber. Here's how to install Screengrab from source on OpenSuse 13.2:

Download the source code from:
  • http://screengrab.doomer.org/download/
Install dependencies to make the binaries:
  • libqt4-devel
  • gcc
  • gcc-c++
  • cmake
 Compile and install:
  • cd ~/Downloads/Source/screengrab*
  • mkdir build
  • cd build
  • cmake ../
  • make
  • sudo make install
The binaries are installed to /usr/local. 
A bug puts the libraries in the wrong location, we need to correct it:
  • sudo mv /screengrab /usr/local/
The source package does not create a start menu shortcut, we need to create it manually:
  •  leafpad ~/.local/share/applications/screengrab.desktop
[Desktop Entry]
Name=Screengrab
Comment=Capture screenshots
GenericName=Screengrab
Exec=screengrab
Icon=screengrab
Terminal=false
StartupNotify=true
Type=Application
Categories=Graphics;


Enjoy!

Saturday, April 25, 2015

Remember screen brightness running Linux on MacBook

Running Sabayon Linux, with systemd, on a MacBook, the LCD backlight always resets to maximum brightness after reboot. This is an annoyance as it becomes necessary to adjust the brightness every time it is necessary to reboot the laptop.

To get the system to remember the brightness setting:
  1. Create a script that can save or restore the setting when called with a parameter.
  2. Create a (systemd) service that calls the script to save the setting on shutdown and restore the setting on startup.
Script: /usr/local/bin/my-settings.sh
#!/bin/sh
# Saves and restores settings for LCD and keyboard backlights.
if [ -z $1 ]; then
    echo "Usage: my-settings.sh [save|restore]"
fi
# Set variables:
export LCD_BRIGHTNESS="/sys/devices/virtual/backlight/apple_backlight/brightness"

# Save setting:
case $1 in
 "save")
    echo Saving settings...
    # if the settings folder does not exist, create it
    if [ ! -e /etc/my-settings ]; then
     mkdir /etc/my-settings
    fi
    # if the LCD_BRIGHTNESS file exists, then save a copy:
    if [ -e $LCD_BRIGHTNESS ]; then
     cat $LCD_BRIGHTNESS > /etc/my-settings/lcd
    fi
    ;;

 "restore")
    # if saved setting exists, if LCD_BRIGHTNESS exists, echo the contents into the system device:
    if [ -e /etc/my-settings/lcd ]; then
     if [ -e $LCD_BRIGHTNESS ]; then
      cat /etc/my-settings/lcd > $LCD_BRIGHTNESS
     fi
    fi
    ;;
esac

===============

Systemd service: /usr/lib/systemd/system/my-settings.service:

[Unit]
Description=Load/Save Keyboard & LCD backlight settings

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/bin/sh -c "/usr/local/bin/my-settings.sh restore"
ExecStop=/bin/sh -c "/usr/local/bin/my-settings.sh save"

[Install]
WantedBy=multi-user.target

================

Enable the script and service:
chmod +x /usr/local/bin/my-settings.sh
systemctl enable my-settings.service
systemctl start my-settings


Sunday, December 28, 2014

Monitor fans on HP Proliant ML150 G3 running Debian Lenny Linux

(This blog is in reference to a Debian Lenny AMD64 system)
hp-health is the package that is supposed to provide access to the fan status on HP Proliant servers.  It is not easy to install hp-health on Debian Lenny.  The ISO can be located by searching the HP website.

On my system the existence of 2 files for UPS monitoring software Winpower causes ldconfig error messages:
  • /usr/lib/libjspTru64Alpha.so
  • /usr/lib/libjspAixPpc.so
 - you can try to temporarily move the files during installation/removal of hp-health, but this didn't help due to the following errors.

Having VMware Server 2 installed confuses the hp-health init script (/etc/init.d/hp-health), which is designed to have different behaviour for ESX servers.  Applying an exit workaround in the procedure causes the script to appear to behave correctly, but the daemon fails to start.

Uninstallation of hp-health is also fraught with difficulty. It is necessary to alter the exit code on the init script just to get the script to continue with removal.  The script will fail to remove /opt/hp/hp-health (and will attempt to remove /opt !).  If you need to manually change the installation status you will need to edit /var/lib/dpkg/status to remove the hp-health section.


After doing all the work above it was found that ipmitool could easily be installed:
apt-get install ipmitool
modprobe ipmi_msghandler
modprobe ipmi_devintf
modprobe ipmi_si
 And the fan RPM's are shown with:
ipmitool sdr type fan
(it takes a few seconds to probe).

Wednesday, August 13, 2014

Automate PDF printing from batch file command line

Adobe Reader is not suitable for printing PDF files using a batch file because it remains open after the print is done and there is no simple, safe & reliable mechanism to close it.  Instead use Ghostscript commandline as shown below:

gswin32c -dPrinted -dBATCH -dNOPAUSE -dNOSAFER -q -dNumCopies=1 "C:\test.pdf"

*Must be a recent version of Ghostscript, e.g. 9.x