WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Using samba to network a printer  (Read 6250 times)

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14851
Using samba to network a printer
« on: March 21, 2009, 09:37:36 AM »
You can use tinycore and the samba3 and cups extensions to share a printer for windows machines over a local network and provide the correct printer drivers over the network to the windows machines.

This assumes you already have the printer set up and working locally with cups on the tinycore machine.

As Kingdomcome pointed out, if this is the first time you're using the samba3 extension, you need to create a couple of directories:
Code: [Select]
$ sudo mkdir -p /var/lib/samba
$ sudo mkdir -p /etc/samba/private

You also need to create the samba spooler and set the appropriate permissions:
Code: [Select]
$ sudo mkdir /var/spool/samba
$ sudo chown -R tc:staff /var/spool/samba
$ chmod 0777 /var/spool/samba
$ chmod o+t /var/spool/samba
$ touch /var/spool/samba/placeholder
*no doubt the "chmod" commands could be combined...

Create /etc/samba/smb.conf as follows:
Code: [Select]
[global]
workgroup = WORKGROUP
netbios name = HOSTNAME
hosts allow = 192.168.1.
# security = user
security = share
load printers = yes
printing = cups
printcap name = cups

[printers]
comment = All Printers
path = /var/spool/samba
browseable = yes
public = yes
guest ok = yes
writable = no
printable = yes

[print$]
comment = Printer Drivers
path = /usr/local/share/cups/drivers
browseable = yes
guest ok = no
read only = yes
write list = root

For a windows user to be able to print, their username needs to be added to samba's list of known users. I'm not totally sure, but it seems like for this to work, the users also need to be added to tinycore:
Code: [Select]
$ sudo adduser -G staff username
$ sudo smbpasswd -a username
*to make things easier, this should be the same username and password as used to logon to the windows machines.

Now start the samba daemons:
Code: [Select]
$ sudo smbd
$ sudo nmbd
..note that you can add these to bootlocal.sh to start automatically on boot (as long as the samba extension is loaded on boot and you added the appropriate files to your backup).

The printer should now be visible to the windows machines by entering "\\HOSTNAME" at the windows start/run dialogue.

To make the printer drivers (included in the cups extension) available to the windows machines, change the following in /etc/samba/smb.conf:
Code: [Select]
# security = user
security = share
[change to]
security = user
# security = share

It also seems that you need to add the root password to the samba password list for this to work:
Code: [Select]
$ sudo smbpasswd -a root
then:
Code: [Select]
$ sudo smbd restart
$ sudo nmbd restart
$ cupsaddsmb -H localhost -U root -a -v
note that "-a" adds all printers, if you want to only add one printer, put the printer name in place of "-a".

Now on the windows machines, after entering \\HOSTNAME, you should be able double-click on the printer icon and have it load the drivers. Once your windows machines have loaded the drivers, change /etc/samba/smb.conf back to the original and re-start the daemons.

To have all of this persist across re-boots, the following need to be added to /opt/filetool.lst:
Code: [Select]
etc/samba/smb.conf
etc/samba/private
var/spool/samba/placeholder
var/lib/samba
etc/shadow
etc/shadow-
etc/passwd

Edit 1: Updated with suggestions from 3rail - thanks
« Last Edit: May 15, 2009, 10:34:38 PM by Juanito »

Offline jpeters

  • Restricted
  • Hero Member
  • *****
  • Posts: 1017
Re: Using samba to network a printer
« Reply #1 on: July 14, 2009, 12:24:50 PM »
If the printer is connected to the windows machine (windows server), I just needed to start cups for it to work, so none of this was necessary (I don't even have a samba spooler, or need to start samba (smbd, nmbd).  Surprisingly, I didn't need to edit smb.conf even for installing the cups printer....just copied smb.conf.default so something was there.   

Offline jpeters

  • Restricted
  • Hero Member
  • *****
  • Posts: 1017
Re: Using samba to network a printer
« Reply #2 on: July 19, 2009, 02:25:55 AM »