Wednesday, June 9, 2010

Processes keeping your device busy while Unmounting

Many a times, when you are trying to unmount your usb device, you find it busy and can't figure out what process is keeping it busy. Some of the commands which can help you in this matter are "fuser" and "lsof". fuser displays the PID of processes using specified files or file systems. lsof  list the open files.  Just observe the output of my lsof command:


[Wed Jun 09|swg@insane:intel]$ lsof |grep Transcend
bash       8619        swg  cwd       DIR       8,17     4096      470 /media/Transcend/intel
lsof      13006        swg  cwd       DIR       8,17     4096      470 /media/Transcend/intel
grep      13007        swg  cwd       DIR       8,17     4096      470 /media/Transcend/intel
lsof      13008        swg  cwd       DIR       8,17     4096      470 /media/Transcend/intel


Transcend is my usb device which I want to unmount and it is giving me a 'device busy' error. I find that "current working directory" is accessing the this device apart from the other two commands about which I am aware of.  Hence, I need to come out of this directory called "/media/Transcend/intel" and do an unmount on the usb device.

Monday, June 7, 2010

Printing to a Samsung SCX-4300 printer shared on Windows XP from Debian Lenny

I got a Samsung SCX-4300 multi-function printer at my office. Currently, it is connected to a windows machine through a USB cable. I wanted to be able to use it as a network printer for my Debian laptop. After a bit of search on google, I could find a solution that worked for me. I must thank Anupam for helping me out during this process. I derived my understanding from this page and this article summarizes the steps that I followed.


  1. Install  "smbclient (including Samba)" and "cups" related packages using APT.
  2. I share the printer on windows machine as "EE-Print". I connect to it through samba client using following command:

    $ smbclient -L EE-Print
    Enter swg's password:
    Domain=[EE-PRINT] OS=[Windows 5.1] Server=[Windows 2000 LAN Manager]

    Sharename       Type      Comment
    ---------       ----      -------
    E$              Disk      Default share
    IPC$            IPC       Remote IPC
    print$          Disk      Printer Drivers
    SharedDocs      Disk    
    G$              Disk      Default share
    Printer3        Printer   HP LaserJet P2050 Series PCL6
    Printer4        Printer   Network Printer
    Printer5        Printer   HP LaserJet 5
    F$              Disk      Default share
    ADMIN$          Disk      Remote Admin
    C$              Disk      Default share
    Samsung         Printer   Samsung SCX-4300 Series

    Domain=[EE-PRINT] OS=[Windows 5.1] Server=[Windows 2000 LAN Manager]
    Server               Comment
    ---------            -------
    Workgroup            Master

  3. Now we open the browser and open the CUPS web-interface by typing in the following URL:
    http://localhost:631/

  4. Now add a new printer, give a name to it and Set the device type to "Windows Printer via SAMBA".

  5. Set the URI which includes the name that was listed earlier by smbclient, for example something like "smb://EE-Print/Samsung". If the printer is passworded, you would use something like "smb://username:password@EE-Print/Samsung".

  6. You need to install linux driver for the printer "Samsung SCX-4300". The linux driver can be downloaded from the Samsung's official site. Untar the pack and run the "autorun" script file as a root. It has a gui interface which guides through various installation process. Currently install it as a local usb based printer.

  7. Once you have installed the driver, restart the CUPS server and click on "modify properties" option for the printer. When it asks for a driver, then select "Samsung scx-4300 series" from the drop down menu. It will now ask for the root username and password. Remember to enter "root" in the username field and give root password in the password field.

  8. Now you should be able to print your test page.