21 August 2012

223. Moving disks, devices from one box to another -- issues with network interfaces

Long story short: edit /etc/udev/rules.d/70-persistent-net.rules

Long story:
I have a very small beowulf cluster keeping my office warm in these antipodean winter months. For some silly reason I was using the front node, a six core + 8 Gb box, as my daily desktop. That of course meant I wasn't really using it for computations. In addition to the front node I have a four core i5-somethingorother with 8 Gb RAM (fast!) and a slovenly AMD X3 /4 Gb to actually run the jobs. They are connected via a gigabit switch (192.168.1.0/24) for nfs exports and a 10/100 router (192.168.2.0/24) for WAN access.

I finally decided that 1) I didn't need a six-core box to prepare latex documents, run octave jobs and make pretty gnuplot plots and that 2) having a slow 3-core AMD box to run heavy nwchem jobs was not fast enough. On the other hand, I didn't want to set up/reinstall/move all my stuff from one harddrive to another.

Linux is wonderful in that it's often just a case of ripping out a harddrive and moving it to a different physical. Windows will scream bloody murder, but linux normally does it pretty well. Same here.

The main issue was the three network cards that I wanted to set up (three separate subnets) and which I configure via /etc/network/interfaces. I simply couldn't call the networks cards what I wanted.

Well, as is obvious in hindsight, you should pay a visit to /etc/udev, and more specifically, /etc/udev/rules.d/70-persistent-net.rules

It looks something like this:

# This file was automatically generated by the /lib/udev/write_net_rules# program, run by the persistent-net-generator.rules rules file.## You can modify it, as long as you keep each rule on a single# line, and change only the value of the NAME= key.
# PCI device 0x10ec:0x8168 (r8169)SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:YY:XX:96:XX:32", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:XX:YY:83:0a:48", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:XX:YY:64:0b:46", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth2"
# PCI device 0x1814:0x3062 (rt2860)SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="c8:YY:XX:cf:1f:5d", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="ra*", NAME="ra0"
# USB device 0x:0x (rt2800usb)SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="c8:YY:XX:c8:91:e6", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="wlan*", NAME="wlan0"






Basically, make sure you can figure out the mac addresses of the different network cards (ip addr helped me more than ifconfig) you can simply go in and edit the ATTR{address}=="" statements and the NAME="" variables. Make sure that there are no conflicts, obviously.

After that, everything should be fine.

If you are using network-manager (i.e. stock GNOME setup) then you will want to pay attention to the /etc/NetworkManager/system-connections/ as well -- open and edit suspiciously named files like e.g. eth0.

They'll look like this:

[802-3-ethernet]
duplex=full
mac-address=00:YY:XX:96:93:32
[connection]
id=eth0
uuid=fa5YYYY-XXXX-43a3-8502-f8ba2d28ZZZZ
type=802-3-ethernet
timestamp=1326324509
[ipv6]
method=auto
[ipv4]
method=auto




20 August 2012

222. Fighting and, eventually, installing HP laserjet P1102w on debian.

This printer is great when it works. It's just always a pain to set up, and it seems to be down to the way the install scripts are written. Setting up the printer was easy in the end -- but getting there? Not so much. Obviously, part of the reason is my own stupidity. Summary: it works on linux, but you'll need a bit of time and patience.

Update: here's an interesting post on the same topic: http://downfromthetrees.com/linux-installing-a-proprietrary-hp-printer-driver.html The only thing I would add is that instead of using sudo as described in that post you may have to use gksu in order to avoid the Magic Cookie error.

The short guide:
You NEED a binary plugin. It blows, but you do. Blowing harder: there's a lot of references to letting hp-setup download it for you -- but I'm willing to bet that it will fail for you.

Anyway, do this:
wget http://www.openprinting.org/download/printdriver/auxfiles/HP/plugins/hplip-3.12.6-plugin.run
chmod +x hplip-3.12.6-plugin.run
gksudo ./hplip-3.12.6-plugin.run

Hopefully that's good enough to take you through to system-config-printer and/or hp-setup. I did a lot of things, but it was the gksudo ./hplip-3.12.6-plugin.run that did it in the end.

And don't forget to add yourself to the lpadmin and perhaps lp groups:

cat /etc/group|grep lp
lp:x:7:verahill
lpadmin:x:111:verahill
I don't know how necessary it is, but heck, why not?


Here's the full, painful (and probably embarrassing) route I took:
It should not be this difficult to get a bloody printer to work. With older printer models it's been quick and easy, without having to download any 'binary plugins'. This is just effing ridiculous. Guess who's not buying another HP printer...

I reorganised my office, and as part of that decided to move my printer from my desktop to one of my networked boxes to free up some space on my desk. My desktop is running GNOME, while the target box is running KDE.

If you install the hplip packages in debian you end up with a very helpful script called hp-setup. You can run that as a user, but try running it as root via sudo, and you get

Invalid MIT-MAGIC-COOKIE-1 keyhp-setup: cannot connect to X server :0

OK, so you can run it as user. Everything looks great, BUT...you'll find that in this case the install will fail at the step of downloading the magical, mythological 'binary plugin'.

Also, as a user you're unlikely to be able to be able to put files in the places where they belong anyway, so there's that (see e.g. the first comment below).

You then do a bit of googling for hplip-3.12.6-plugin.run, and end up here: https://aur.archlinux.org/packages.php?ID=44646

You do
wget http://www.openprinting.org/download/printdriver/auxfiles/HP/plugins/hplip-3.12.6-plugin.run
chmod +x hplip-3.12.6-plugin.run
./hplip-3.12.6-plugin.run

This opens a gui where you get to accept the T&C. Not much seems to happen beyond that though. Oh, and you can't do the sudo-thingy because, well, you get the magic cookie error.

OK, take a step back.

sudo lpstat -a

global-mfp accepting requests since Mon 20 Aug 2012 10:46:48 EST
HP-LaserJet-Professional-P1102w-2 accepting requests since Mon 20 Aug 2012 13:49:19 EST
lpoptions -d HP-LaserJet-Professional-P1102w-2

lpq
HP-LaserJet-Professional-P1102w-2 is ready

Test it:
lp /etc/fstab
request id is HP-LaserJet-Professional-P1102w-2-1 (1 file(s))

 lpq
HP-LaserJet-Professional-P1102w-2 is ready and printing
Rank    Owner   Job     File(s)                         Total Size
active  (null)  1       untitled                        2048 bytes
Printing my foot it is.

Hmm...
cat /etc/group|grep lpadmin
lpadmin:x:114:
OK, edit /etc/group and add myself to lpadmin.

I can open system-config-printer, but I can't 1) delete any printers (which would've been nice) or 2) start it with sudo.

I can use http://localhost:631, but as a user I'm somehow not allowed to remove printers, and I use sudo -- there's no 'root' password.

At this point I was getting frustrated and nuked all printers clear of my system.

sudo lpadmin -x HP-LaserJet-Professional-P1102w-2

sudo apt-get install system-config-printer-kde

Now I had both 'printing' (= vanilla CUPS system-config-printer) and 'Printer Configuration' in the KDE menu.

Still no dice.

OK, another step back.
mkdir hp
./hplip-3.12.6-plugin.run --target hp
cd hp/
sudo cp 86-hpmud-sysfs_hp_laserjet_professional_p1102w.rules /etc/udev/rules.d

Still no effing luck.

Tried one last desperate thing:
gksudo ./hplip-3.12.6-plugin.run
Clicked the agreement. Said done.
Hit 'print test page' and...it printed!

So...you need to be root...but the MIT magic cookie issue combined with the requirement to have a friggin' gui (why???) made that painful. Well, I guess that's why we're told to use gksu whend oing graphical stuff...

OK, only things remaining: network sharing. Should be simple. Opened up all ports on print-host box to accept traffic from my desktop (and desktop only). No luck.

gksu system-config-printer
Click on server, settings -> check Publish shared printers connected to this system.

On my desktop it was then just add a matter of adding the printer in GNOME (ipp://192.168.1.101:631/printers/HP-LaserJet-Professional-P1102w)

Sweet.

SOLVED.


16 August 2012

221. First steps with Moodle (the .deb version) in Debian

This is a very brief, very basic outline.

Looking online the general recommendation seems to be to install moodle yourself and avoid the debian package version. While not a stranger to rolling my own, I just want to play with moodle for learning purposes because that's what my uni uses.

Anyway, do
sudo apt-get install moodle

Once it's installed, look at
ls /etc/apache2/sites-enabled

If there's nothing moodly, then do
sudo cp /etc/moodle/apache2.conf /etc/apache2/sites-enabled/moodle.conf
sudo service apache2 restart

Navigate to http://localhost/moodle

The actual installation takes ages, so go get yourself a cup of tea/coffee to prevent your mouse finger from getting itchy. In other words, just wait until you get a list showing that all steps have completed and that you may continue.

You need to allow cookies.


Fill out the admin stuff - country, password, city etc etc.



At this point you can log in, create a class and start exploring. Have fun.