Posts Tagged ‘mount’

Access/Mount a Linux ext2/ext3 filesystem from a Windows XP machine over a LAN/Domain network

Saturday, July 19th, 2008

Purpose: This post will explain how you can mount a Linux filesystem (ext2/etx3) on your Windows XP machine over a network.

Note: If you are looking for how to the reverse - Mount a windows share drive on a linux machine over a network then please refer to my previous blog entry.

Also this blog entry does NOT explain how you can access an ext2/ext3 filesystem on your Windows XP partition on the same hard drive - The typical Dual Boot scenario.

Important Note: Before you read any further I strongly encourage you to do the things that I mentioned in my previous blog as noted above. Your chances of success to follow the instructions on this entry will greatly increase. Therefore I strong encourage you to do all the things mentioned in my previous blog.

My Setup:

1. Debian Linux (4.0) running 2.6.24 kernel with IP address 192.168.0.2 and user accounts: “root” and “kushalk”

2. Windows XP SP2 machine on a network domain called “home.net” with IP address 192.168.0.3 and user account: “kkoolwal”

Step 1: Install Samba Package on your Linux machine

#apt-get install samba

Step 2: Stop the Samba Daemon

It is a good idea to stop the Samba daemon since we will be making changes to the Samba configuration file.

#/etc/init.d/samba stop

Step 3: Edit the Samba file /etc/samba/smb.conf (may be required)

This will require two steps:

a) Make sure that your domain/workgroup name is setup correctly in the variable “workgroup”. Also you need to uncomment the line by removing the “;” or “#” symbol.

workgroup = home.net

Make sure you set the name of your workgroup properly. To find out the name of your workgroup/domain do the following on your Windows machine.

To find out the Workgroup name in Windows follow these steps:
- Go to “START”
- Click “Control Panel”
- Click “System”
- Click on the 2nd tab button named: “Computername” and find out the name of your workgroup/domain.

b) Select which directory you want to share

As per the default setting you will be able to access your home directory on your Windows XP machine i.e. the directory of the user from which you connect. If you want to access any other directory other than your home directory then you need to add the following section anywhere in the smb.conf file:

[src]
comment = My Kernel/Module development sources
path = /usr/src/
read only = Yes

Basically by doing the above you are telling your Samba server that you want to share the ‘/usr/src’ directory.

That’s it. Your smb.conf file should now be configured.

Note: It is a good idea to check your smb.conf file for any syntactic error by giving the following command:

# testparm

Here is my output of the above command:

root@debian:~# testparm
Load smb config files from /etc/samba/smb.conf
Processing section “[homes]”
Processing section “[printers]”
Processing section “[print$]”
Loaded services file OK.
Server role: ROLE_STANDALONE
Press enter to see a dump of your service definitions
[global]
workgroup = home.net
server string = %h server
obey pam restrictions = Yes
passdb backend = tdbsam
passwd program = /usr/bin/passwd %u
passwd chat = *Enter\snew\sUNIX\spassword:* %n\n *Retype\snew\sUNIX\spassword:* %n\n *password\supdated\ssuccessfully* .
syslog = 0
log file = /var/log/samba/log.%m
max log size = 1000
dns proxy = No
wins server = eth0:192.168.0.20
panic action = /usr/share/samba/panic-action %d
invalid users = root
include = /etc/samba/dhcp.conf
[homes]
comment = Home Directories
valid users = %S
create mask = 0700
directory mask = 0700
browseable = No
[printers]
comment = All Printers
path = /var/spool/samba
create mask = 0700
printable = Yes
browseable = No
[print$]
comment = Printer Drivers
path = /var/lib/samba/printers
root@debian:~#

Step 4: Add a user to the Samba user list:

You need to tell the Samba server which user you will be using to connect the to Linux filesystem from the Windows machine. I added myself (user: kushalk) to the Samba server by giving the following commands:

smbpasswd -L -a kushalk
smbpasswd -L -e kushalk

Note: By default, Samba does not allow the user “root” to access the filesystem. You will have to change the setting “invalid users = root” in your smb.conf file. I have not tried this.

Step 5: Restart the Samba server

#/etc/init.d/samba start

Step 6: Access your Linux filesystem/folder from Windows XP machine

Finally go to your Windows machine (assuming you have File Sharing and all configured which I think it should be if you were able to follow the steps in my previous blog successfully) and type the following in your “Explorer Windows” and NOT “Internet Explorer” like this:

Linux Filesystem Windows Mount Login Network

Now enter your username and password - the one that you used in the smbpasswd command in Step 4 above. After that you should be able to see your home directory like this:

Linux Ext3 Share connected Windows Mount

That’s it. As usual, please leave a comment/feedback, if you have any.

Mount a Windows Network Share on Linux using SAMBA/CIFS

Monday, May 19th, 2008

Purpose: This post will explain how you can mount a Windows Network Share on to your Linux machine. Note: If you are looking for how to mount a windows partition on your local hard drive on to your Linux filesystem this post may not be for you.

Example - Setup:

1. You have a computer running Windows XP (or may be Vista) on your home/office network on a workgroup or domain.

2. You have another computer running Linux say Debian Linux.

3. You would like to mount a shared folder/drive on your Windows computer on to your Linux machine say on “/mnt/” folder so that you can access (read/write) that folder/drive.

My setup:

1. Debian Linux (4.0) running 2.6.24 kernel with IP address 192.168.0.2

2. Windows XP SP2 machine on a network domain called “home” with IP address 192.168.0.3

Step 1: Share a Windows folder/drive

You will first need to share a folder/drive on your Windows computer so that it can accessed through network. You can do this by right-clicking on the folder/drive that you would like to share and selecting the “Sharing” option. If you don’t know what I am talking about then you can refer to this MS tutorial which explains how to do that.

Step 2: Make sure your Kernel is configured properly

If you are using a standard Linux Kernel from any distribution then it is mostly like already configured. If not then just configure and compile your Linux Kernel with the following options in bold built-in or as a module.

# cat /boot/config-2.6.24 | grep CIFS
CONFIG_CIFS=y
# CONFIG_CIFS_STATS is not set
# CONFIG_CIFS_WEAK_PW_HASH is not set
# CONFIG_CIFS_XATTR is not set
# CONFIG_CIFS_DEBUG2 is not set
# CONFIG_CIFS_EXPERIMENTAL is not set

# cat /boot/config-2.6.24 | grep SMB
CONFIG_SMB_FS=y
# CONFIG_SMB_NLS_DEFAULT is not set

Step 3: Install necessary packages on your Linux machine

You will need smbfs package and also an optional smbclient package by giving the following commands:

#apt-get update

#apt-get install smbfs smbclient

The above command will also install samba-common package. If you are asked to enter a workgroup/domain name while the above packages are installed just enter the relevant infomration, In my case it was “home” as my domain name. You can enter your domain name or a workgroup name depending on your LAN configuration.

Step 4: Check which shares are available for mount

Now before you mount you can also check which shares (folders/drives) are available on your Windows machine that you can mount by giving the following command:

debian# smbclient -L infohighway -U kushal

where

infohighway = Name (NetBIOS Name) of my computer

kushal = Username on my Windows Machine

Password:

You will get an output similar to this:

Domain=[HOME] OS=[Windows 5.1] Server=[Windows 2000 LAN Manager]

Sharename Type Comment
——— —- ——-
myshare Disk
IPC$ IPC Remote IPC
mydownloads Disk
ADMIN$ Disk Remote Admin
C$ Disk Default share

Domain=[HOME] OS=[Windows 5.1] Server=[Windows 2000 LAN Manager]

Server Comment
——— ——-

Workgroup Master
——— ——-

From the above output you can see that I have shared folders called “myshare” and “mydownloads” on my Windows XP machine as highlighted in bold letters. This means that I can mount these folders on my Linux machine.

Step 5: Mount the Windows Share

Now the real thing. There are two ways to mount: The traditional SMBFS or the newer CIFS. It seems that CIFS is going to replace SMBFS which will soon become obsolete. I will show you both the methods:

SMBFS Method Command:

# mount -t smbfs -o username=kushal,password=******** //infohighway/drivers /mnt/

where

kushal = Username on my Windows Machine

******* = Password for the user ‘kushal’

infohighway = Name (NetBIOS Name) of my computer

drivers = Windows folder shared on my Windows XP machine

/mnt = Target mount directory on my Linux Machine

CIFS Method Command:

# mount -t cifs //infohighway/drivers /mnt/ -o username=home/kushal,password=*********

where

home = DomainName/Workgroup of your LAN network

Rest of the parameters are same as in SMBFS

Note: If you get any error messages after you give the mount command refer to the “Some typical errors” section below.

Now you can access the contents of the Windows share now by giving the command:

# ls /mnt/drivers

debian:~# ls /mnt/
audio INFCACHE.1 network Security storage video
debian:~#

Some typical errors:

You might see some typical error messages as follow in case if you missed any steps above:

Error 1: CIFS VFS: cifs_mount failed w/return code = -22

Solution: apt-get install smbfs

Error 2: smbfs: mount_data version 1919251317 is not supported

Solution: apt-get install smbfs

You can see the above error messages (if they do occur) by giving the following command just after you issue the mount command as mentioned in Step 5 above:

# dmesg | tail

Error 3: mount error 13 = Permission denied

Solution: Give the name of your Domain/Workgroup as shown in bold letter in Step 5 when mounting with CIFS method otherwise you will likely get this error message.