Monday, 27 February 2017

Batch service load threshold too low

In openSUSE Leap 42.2, the batch service doesn't start a job if the load average is above a threshold. This defaults to 0.8 in the source. This means that even if you have a multi-core multi-thread CPU which can handle the load, a job will not start until the CPU is fairly quiet.

Fortunately there is a command line setting to raise this threshold, see man 8 atd. What you have to do is

systemctl edit atd

and enter these lines:

[Service]
ExecStart=
ExecStart=/usr/sbin/atd -f -l 2


Then do

systemctl restart atd

A ps ax should show atd running with the new threshold. The first ExecStart resets the command line, and the second is the one that overrides the service that will be started by systemd. I have 4 cores so I chose 2. You might choose a different load threshold.

If you are running another distro that uses systemd, you should get the ExecStart command from the existing unit file, probably /usr/lib/systemd/system/atd.service and add the -l load to suit.

It would be nice if openSUSE could provide a setting for the threshold in /etc/sysconfig/atd in future.

Saturday, 28 January 2017

Declaring the correct OS type to VMWare Player/Fusion matters

I built a pair of CentOS 6 VMs.

The first was constructed from an OVA file exported from VirtualBox. When it was booted, there was no network adapter detected. A little search showed that I had to add the line:

ethernet0.virtualDev = "e1000"

to the .vmx file. After that it worked.

The second was built from the installation DVD. I expected to have to edit the .vmx file again, but an e1000 network adapter was provisioned for the VM.

Looking at the two VMs the major difference was the first had an OS type of Other, while the second was declared as RHEL 6 (which CentOS 6 is equivalent to). This was probably because I had imported from an OVA file.

It seems that Player/Fusion is smart enough to provide a virtual e1000 adapter with the correct OS type declaration.

I expect that I will discover other aspects, such as the client tools, that will depend on this declaration when I continue with the configuration next week, so I will be fixing up the OS type of the first VM.

Friday, 20 January 2017

How to rerun @reboot crontab entries without a reboot

Vixie cron and its descendants have a feature where an entry with the special time specification @reboot in place of the first five date and time fields indicates a one-shot action to be run when the machine is first booted.

But how do you test such entries without actually having to reboot the machine? My thinking was that somewhere crond must note the information that it already has been run once at boot.

Indeed a quick search of the filesystem found the zero length file /var/run/cron.reboot used as a flag that @reboot jobs have already been done.

So, to rerun @reboot jobs:

rm -f /var/run/cron.reboot

followed by:

systemctl restart crond

for systemd systems or

/etc/init.d/crond restart

for SysVinit systems.

Tuesday, 10 January 2017

Configure Postfix to relay to Gmail with noanonymous

I am the only user on my home machine, so although I could configure my mail user agents, Thunderbird and alpine, to relay to Gmail directly, I preferred to set up Postfix as a relay.

There are many tutorials on how to do this, for example this one from Howtoforge so I will not go over familiar territory. However if you find that Gmail is giving you an authorization required error in your Postfix logs, you need this setting:

smtp_sasl_security_options = noanonymous

A lot of tutorials fail to mention this.

Also if you find in the logs that Postfix is attempting to connect to the IPv6 address of Gmail, and you don't have a IPv6 capable connection with your ISP, then you might want to set this:

inet_protocols = ipv4

You may not notice this without looking at the logs because Postfix retries with IPv4 after giving up on IPv6, so there will be a delay relaying the mail.

Thursday, 5 January 2017

Installing the Brother HL2130 printer driver on Linux

I recently upgraded to openSUSE Leap 42.2. Since I did a fresh install, one of the things I had to get working again was my Brother HL2130 laser printer. It's a very basic model but does what I want and is cheap to run. It connects to the host computer with USB.

Brother supplies drivers for Linux as both RPM and DEB packages, do a web search to find a download server. These are actually filters that convert Postscript to Brother printer language. They integrate with the CUPS or the old LPD spooler systems.

After I did the install, nothing would print. The log showed the printer connecting and disconnecting from the USB port.

I looked at the files installed by the Brother packages and found in the directory /usr/local/Brother/Printer/HL2130/cupswrapper/ the file cupswrapperHL2130-2.0.4 I ran this manually with sh -x cupswrapperHL2130-2.0.4 -i and noticed that it ran a lpinfo towards the end to get some information. I ran lpinfo manually and found that it didn't detect the printer. I switched on the printer and this time the printer was detected with the path: usb://Brother/HL-2130%20series?serial=XXXXXXXX I reran the install script and this time the installation worked. This time it had edited /etc/cups/printers.conf with the correct DeviceURI.

So the short solution is: Switch on the printer before installing the Brother driver packages so that detection and configuration of the printer can happen.

This probably also applies to other Brother printer models using USB connectivity.

Later on a search showed somebody with the same problem and a manual solution.

Thursday, 10 November 2016

Reverting UEFI boot to MBR boot for CentOS/Redhat 6 on the HP z230

Why would you want to do this? In my case it is because the HP z230 workstation I am maintaining has two disks in software RAID1 and while /boot can be on a RAID1 array, and the boot loader can be installed in the MBR of both disks, so that boot can continue even if one disk fails, UEFI doesn't (as far as I know) provide this redundancy. If you know different, please write that up.

I had already configured UEFI boot on the workstation. This is what I had to do to change to MBR boot when I discovered that UEFI doesn't provide redundancy.

First do all the required kernel updates and check that UEFI boot works.

Then copy the contents of /usr/share/grub/x86_64-redhat to /boot/grub. The OS installer doesn't install the grub helper files when it detects that UEFI boot is active.

Next copy /boot/efi/EFI/redhat/grub.conf to /boot/grub. This is the reason for doing the kernel updates first so that grub.conf is up to date.

Shutdown and go into the BIOS and disable UEFI so the boot method is Legacy MBR.

Boot with the CentOS install DVD and select rescue mode. You'll need to let the rescue OS mount the root filesystem on /mnt/sysimage so that you can run grub-install. Get a shell and do chroot /mnt/sysimage, then run grub-install /dev/sda and grub-install /dev/sdb to install the boot loader on both disks.

Reboot and remove the DVD before startup. Now GRUB should boot from the hard disk. It also wanted to do a selinux relabel so plan for some downtime in case this happens.

Addendum 2016-11-10: Also ensure that /etc/grub.conf is a symlink to ../../boot/grub/grub.conf and not to the one in the EFI boot partition, otherwise kernel package updates will update the wrong grub.conf.

The instructions are for the HP z230 but may be applicable to your workstation. This assumes that your BIOS supports the legacy MBR boot method in addition to UEFI.

Thursday, 11 August 2016

Adventures with USB to SATA/PATA bridges

If you have a spare SATA hard drive or DVD burner, or a PATA DVD burner lying around, you may be tempted, like me, to connect it to your computer using a USB adaptor, to function as an outboard drive, using one of the many identical adaptors you can buy on eBay for a few dollars. You will need an external power supply of course, and I'm assuming you have one lying around too. All these experiments were done on a Raspberry Pi 2.


The first one I bought looked like this. It also came with a SATA cable and a Molex to SATA power adapter cable. Note the there are two PATA interfaces, one for 3.5 inch HDs and DVDs and one for 2.5 inch HDs on opposite sides. For the 2.5 inch HDs no power supply is needed, as the power comes from USB.

The lsusb command shows that this uses the JMicron 20337 chip:

ID 152d:2338 JMicron Technology Corp. / JMicron USA Technology Corp. JM20337 Hi-Speed USB to SATA & PATA Combo Bridge


There are a couple of quirks with it. The first is that the chip will not be detected unless the HD/DVD side is plugged in and powered up. The other is that the 40 pin (3.5 inch) PATA side can be plugged into the HD/DVD offset by one pin if you are not careful, because the plug is slightly narrower than the socket, and the key is also a bit smaller than the slot. The second is that the Molex power connector may jam against the PATA connector. In fact this is a cause of accidental offset if you plug the Molex connector in first. The problem is a wing on the connector near the wire end that makes it take up more room. I snipped off one wing with cutters.

Using this adaptor with a DVD burner was fine, the drive appeared as /dev/sr0, and I was able to use brasero to burn optical media. However experience with 3.5 inch SATA HDs was unsatisfactory. If data rates are too fast, the chip is apt to disconnect and then the Linux driver tries to reset the USB interface but this never works. It seemed to work ok with 2.5 inch laptop PATA drives. The disk appears as /dev/sda, as the SD card drive is /dev/mm-something.


I bought a second USB adaptor, this time only for SATA devices. This one came as a rather fat USB dongle with SATA and e-SATA sockets on the side. You may have to use a hub if it blocks other USB sockets on your computer from being used. The lsusb command shows that this uses the JMicron 20329 chip.

ID 152d:2329 JMicron Technology Corp. / JMicron USA Technology Corp. JM20329 SATA Bridge

There is an intriguing message in the system log:

Quirks match for vid 152d pid 2329: 8020

I haven't looked at the driver source, but the message seems to suggest that the driver copes with this one better. When I used it with a SATA HD, there were no disconnects and resets. So this is the one I will use to interface to the HD, using the 20337 only for the DVD drive.

You may see USB adapters that plug directly onto the back of the drive. Those are for 2.5 inch drives only as the power comes from USB.

All the devices mentioned here are USB 2.0. USB 3.0 adapters are available, and only worth it for SATA HDs, but I don't have a great need for speed so I'll let them get cheaper before I buy one.