LPD + Samba and Debian
Having spent the entire day getting my Samsung ML-1250 printer working in Debian and then shared using Samba, I thought I would leave some handy hints, so here goes.
This document is specific to Debian and only really for my printer but you never know, it might help!
Part 1 Getting the printer working with Debian
This should be easy. It uses USB. Just plug it in and use the linux drivers that Samsung provide. Unfortunately, Debian doesn't recognise the printer. A quick "grep usb /var/log/syslog" (on most systems this would be "grep /var/log/messages") reveals that Debian thinks I have just plugged in a USB keyboard, not a printer. Oh dear.
So what next? I found the quickest fix (as I don't have a USB keyboard) is to rebuild a kernel with no USB HID support in. For people who have never recompiled a kernel before, it's not actually as hard as you might imagine and it does benefit you system.
Building a new kernel
I suggest you follow THIS GUIDE. However, here's my simple guide.
Firstly, you need the kernel sources. Either install the ones for you current distro (Debian users "apt-cache search kernel source" then "apt-get install" the most recent). Alternatively grab the lastest kernel source from here. I decided to use the source from the Debian system as it's been patched specifically.
If you decide to download, put you source into "/usr/src".
Here is an example
- tar -zxvf linux-2.4.20.tar.gz
- ln -s linux-2.4.20 linux
- cd linux
Configuring you kernel
Next, if you run X, type "make xconfig", otherwise make "menu config". This wil bring up a menu system which will help you configure your kernel. I'm not going to go through all the options, mainly because you've probably got different hardware to me. I would just like to point out a few major pitfalls. Firstly, make sure you compile in or add as modules all your hardware! Secondly, whether you use ext2, ext3 or reiserfs or anything else, remember to build support directly into your kernel or you won't be able to read your hard disks.
To get my printer working, I selected
- General Setup > Support for Hotpluggable Devices
- USB Support > UHCI or OHCI (if you don't know which you need compile them both as modules
- USB Support > USB Printer Support
- USB Support > I DESELECTED USB Human Interface Support as it was interfering
Type "make dep && make clean bzImage modules modules_install" to compile your new kernel and modules. This is going to take a while, especially on a slow computer, so now's a good time to go grab a a drink.
Install your shiny new kernel
If you use lilo then first copy your new kernel to boot by "cp /usr/src/linux/arch/i386/boot/bzImage /boot/bzImage.new". I advise you not to overwrite your old kernel in case of problems ;-)
Now you need to add an entry into "/etc/lilo.conf".
You also need to make sure that you have the option prompt and delay=10. These make sure lilo brings up a menu of available kernels. Please note at this stage I have not made the new kernel the default. I find it's better to test it before doing that!
Reboot, choose NewKern when prompted. If everything works fine, "grep usb /var/log/syslog" will give something like
jupiter kernel: usb.c: ignoring set_interface for dev 6, iface 0, alt 0
jupiter kernel: printer.c: usblp0: USB Bidirectional printer dev 6 if 0 alt 0
If not, are you sure your printer is plugged in and switched on? Did you compile all the options in? Did you boot from the right kernel?
I found that Samsung's drivers didn't work for my printer :- (however I did find a simple way of adding in my printer using a program called "printtool" Debian users can "apt-get install printtool", others can dowload it.
To start printtool, type "printtool". It works best in X but should display using ncurses on the command line.Set the port to "/dev/usb/lp0"
For the input filter, scroll down the list. You want to use the Samsung driver thats PCL5e. It's not the same model but it does work.
You'll need to set the paper size and dpi values. 600x600 and A4 in my case.
Printtool has an inbuilt test system, so print off a test page to make sure it's all working. If it does, congratulations, you have now a working printer using the lpd.
Part 2 Getting Windows Clients to Print
For those who don't know, Samba is a system the allows Unix to talk in smb, which is MS's networking language. I already have a running Samba server which acts like a Windows Primary Domain Controller. I will be writing another guide on setting up PDC sometime soon.
My config file can be viewed Here. The best way to set up your Samba server is to use swat. This is a browser based application. It is called by going to port 901 on the server. So if you server has an ip address of 192.168.0.2 put http://192.168.0.2:901 in you browser. Click the globals option. You should then be shown the various configuration options. You will need to go into advanced mode to see all the printing options. When your finished, don't forget to click "commit changes" to save your settings.
You will be asked for a user name and password. It should be root's password, so enter user "root", password "rootspassword". After that you should be presented with
To get swat working you might have to edit /etc/inetd superserver. Usually this involves removing a # from the line where swat appears
If you can't or don't want to use swat "vi /etc/samba/smb.conf". For the moment the only options you need to worry are about areworkgroup= You must put your server in the same workgroup/domain as your clients usually WORKGROUP or MSHOME
netbios name = JUPITER Sets the Name of the server in windows network neighbourhood
printcap name = /etc/printcap This is the default
printing = bsd you are using lpd not cups right?
There are other options. The defaults should suffice though.
Samba will automatically add printers listed in "/etc/printcap". the only thing you might want to do is add a comment (I added Samsung Laser Printer so you would get the following in your smb.conf;
comment = Samsung Laser Printer
path = /tmp
read only = No
create mask = 0700
printable = Yes
printer name = lp
oplocks = No
At this point you printer is configured. However, there is one more thing. You might want to configure a store directory for printer drivers. Its a hidden directory on the server called "print$" ($ denotes hidden). The print$ directory will store the driver and allow the add printer wizard to function correctly.
First you will need to create a real directory in you local filesystem, I use /var/samba. Create a new directory called printers with subdirectories W32X86 and WIN40
- cd /var
- mkdir samba
- cd samba
- mkdir printers
- cd printers
- mkdir WIN40
Now add the share into your smb.conf
path = /var/samba/printers
write list = root,@ntadmin
guest ok = Yes
Connecting Your Clients
You should now have a working printer, which is shared through samba. The next step is to connect your Windows Clients. Fortunately if you've set everything up correctly, this should be simple.
On you client Windows box (I only have experience with this using NT4.0 and Windows 2000), open the Printers folder and double click Add Printer. A new dialog box should appear. Choose network printer and hit next.
You will then be asked the name of the printer. Choose to type the printer name and enter \\JUPITER\lp. If you have changed the name of your server and/or printer, use the names you have chosen!
After you've clicked next, the computer will pause a moment while it locates the printer. If the location fails, check your computer is in the same workgroup and that samba (smbbd) and nmbd are running on the server.
It should now ask you for the drivers. Choose the approprate ones (available here)
Finally, choose whether or not you want Windows to use it as the default printer, and run off a test page. Hopefully you now have a working network printer.