Samba problems with Ubuntu 9.04

I was trying to set up samba with a new Ubuntu 9.04 (“Jaunty Jackalope”) box, and was frustrated when windows failed to connect to the [homes] share I had enabled.

It turns out that even if you comment out all the printer configuration in /etc/samba/smb.conf, smbd will still try to connect to CUPS, and quietly die.

After setting smb.conf to log to syslog, I saw:

smbd[30539]: printing/print_cups.c:cups_connect(103)
smbd[30539]:   Unable to connect to CUPS server localhost:631 - Connection refused

The solution? Add this to the [global] section:

load printers = no

and pick up the new setting by running

/etc/init.d/samba restart

Installing Ubuntu from a USB Drive

I just bought a new green server (25-30 watts at full load!) and wanted a brand-new Jaunty experience.

The MSI Wind Nettop doesn’t come with an optical disk drive, nor does it come with IDE support, so my old CDROM drives wouldn’t work — I needed to boot from an old 1gb USB drive.

I found usb-creator was already available on my to-be-decommissioned Ubuntu Gutsy box, but it won’t work unless you clear off enough free space beforehand. I ended up repartitioning my USB drive with cfdisk, then running mkfs against the new partition, then restarting usb-creator.

The actual installation was quite smooth and quick. Thanks to the development team!

Preventing an external hard drive from idling on ubuntu

I got a Seagate FreeAgent Pro external hard drive for backups (JWZ has a very straightforward article about this). It happily reformatted to ext3, and I kicked off an rsync of /home.

Because rsync figures out what files need copying before it copies them, and there are hundreds of thousands of files in my /home, there was more than a couple minutes of grinding on the local hard drive building a list of files to copy over. While this happened, the external drive idled into a “sleep” mode that ubuntu can’t seem to awaken it from.

This was slashdotted with an sdparm hack, but I believe this solution is better. Copy this new udev rule into /etc/udev/rules.d/50-local.rules (this is a new file that you will be creating):

# Seagate FreeAgent allow_restart fix (i/o errors)
SUBSYSTEMS=="scsi",DRIVERS=="sd",ATTRS{vendor}=="Seagate*",ATTRS{model}=="FreeAgent*",RUN+="/bin/sh -c 'echo 1 > /sys/class/scsi_disk/%k/allow_restart'"

Secure VNC with ssh port forwarding

Need to help out a damsel in distress (username “damsel”) sitting on a remote debian/ubuntu box (“remotehost”)? Have you set up ssh on a non-standard port (port 12345) already? Great. Keep reading.

Step 1: Install x11vnc on the remote machine:

ssh remotehost
sudo apt-get install x11vnc

Step 2: Spin up x11vnc on the remote host:

ssh remotehost
sudo -u damsel x11vnc -noxdamage -speeds dsl -solid -display :0 -passwd SECRET

Keep this ssh running. -speeds dsl -solid makes vnc more responsive.

Step 3: Forward the remotehost’s vnc port, 5900, to your local host using ssh:

ssh -p 12345 -L 5900:127.0.0.1:5900 remotehost

Step 4: Start up your VNC viewer application, pointing to localhost.

Tightvnc is a great vncviewer and is installable through macports:

sudo port install tightvnc

Then run:

vncviewer localhost

Verifying file integrity with debsums

After upgrading my Ubuntu server, some security applications grumped about changed contents of some common binaries.

Just to be safe, I wanted to verify them explicitly with debsums, but debsums looks for package names, not paths to binaries. Here’s a script that validates chattr, find, perl, and lsattr–the “-s” option to debsums is “silent”, so no news is good news:

for i in /usr/bin/chattr /usr/bin/find /usr/bin/perl /usr/bin/lsattr ; do
  echo $i
  debsums -as $(dpkg -S $i | cut -d':' -f1 | sort -u)
done

Running a command for all files whose name matches…

I found a stray image named “img_1234.jpg” on a laptop and wanted to see if I already had it on my server.

On my Mac I could use spotlight’s nifty “kind:image” filter along with quicklook. Macworld has a great article about advanced spotlight usage.

On Ubuntu, it’s almost as easy:

locate -i img_1234.jpg | xargs -d'\n' feh -F -d
  • The locate -i says “find img_1234.jpg without case sensitivity. Locate likes to separate filenames (that might have spaces) with a newline.
  • The xargs -d'\n' says “expect filenames that are are separated by newline
  • The feh -F -d tells feh, a great little image viewer, to reduce the image to fit to the screen and draw the filename.

Installing VMware Player on Ubuntu Gutsy

Please note that these instructions are for Ubuntu 7.10. Newer versions of Ubuntu can just follow the normal installation instructions at http://www.vmware.com/download/player/.

So it turns out that the current release of Ubuntu (at least for another four days), “Gutsy Gibbon”, gave VMware Player the big cold shoulder and removed it as an installable package.

To top it off, the email-capture marketing application that VMware uses is broken, so you can’t download vmware-player through their website now. (How is this acceptable? Shame on both companies–eloqua for downtime with something as simple as a form capture, and vmware for not canceling their service).

Some sleuthing came up with the direct URL to the download for VMware Player 2.0.3.

While that downloads, go install the required packages:

sudo apt-get install \
  build-essential linux-headers-generic \
  linux-headers-$(uname -r)

Uncompress the archive:

sudo mkdir -p /opt/vmware-player
sudo chown $(whoami) /opt/vmware-player
cd /opt/vmware-player
tar xvzf ~/Desktop/VMware-player-2.0.3-80004.i386.tar.gz

Then start the install. I’d recommend not putting the binaries into /usr/bin (as this will be a non-.deb installation, and it will make the uninstalling easier):

sudo ./vmware-install.pl
...
In which directory do you want to install the binary files?
[/usr/bin] /opt/vmware-player/bin
...

From here on out, take the default values.

DegradedArray event on /dev/md0:gronk

Due to an unscheduled powercycle on my linux server, I got a very troubling page from mdadm, the multi-disk administrator, saying it had marked one of the disks as failed.

This, presumably, was due to a flaky SATA controller that didn’t make /dev/sda available by the time the kernel was mounting /dev/md0, so software raid turned it off.

It was easy enough to get the drive back into play:

sudo mdadm /dev/md0 --add /dev/sda1

And easy enough to monitor progress:

mrm@gronk:~$ cat /proc/mdstat
Personalities : [raid6] [raid5] [raid4]
md0 : active raid5 sda1[3] dm-2[1] dm-1[0]
580074880 blocks level 5, 64k chunk, algorithm 2 [3/2] [UU_]
 [====>................]
recovery = 22.0% (63875072/290037440)
finish=178.1min speed=21154K/sec

Recursive sort-by-modification-time

This certainly isn’t rocket science, but it also is certainly not something you want to type more than once.

find . -type f -printf '%T@\t%p\n' | sort -n | cut -f2

And an application using feh:

find . -type f -printf '%T@\t%p\n' | sort -n | cut -f2 | xargs feh -F

And if you want the newest-written-to .log files, searching from the current working directory:

find . -name \*.log -type f -printf '%T@\t%p\n' | sort -rn | cut -f2 | head -30 | xargs -n 1 ls -lh