PDA

View Full Version : Linux to WinBlows File sharing cmd - explanation needed



zavec
01-27-2004, 07:23 AM
Hi there from Perth, Western Australia first up ;)

I have been using Debian for about a week and finding it quite a learning curve indeed! Setup was a breeze and with the help from a friend over the internet, i redirected my sources.list from the default German? site, to a local FREE provider of traffic.... d/l and installed the updates fine to.

Then came the time when i wanted to connect to my WinBlows machine and view my movies and mp3's etc etc.... So i started off by reading the document at http://www.knoppix.net/docs/index.php/FaqSambaQuick and following the instructions...... After a few trys and thought i came to connect to my WinBlows machine with the following command:

mount -t smbfs -o username=administrator,password=flippers //Karma/C$ /mnt/myshare

WHAT I WANT TO KNOW IS: What does this mean lol? I would like an explanation on what each section of that command means and why it is like that order if possible?

Nothing worse than doing something, it working, and then wondering what it means...
Thanks to anyone who replies.

tearinghairout
01-27-2004, 11:49 AM
If you type 'man mount' on the command line, you will see the following

MOUNT(8) Linux Programmer's Manual MOUNT(8)

NAME
mount - mount a file system

SYNOPSIS
mount [-lhV]

mount -a [-fFnrsvw] [-t vfstype] [-O optlist]
mount [-fnrsvw] [-o options [,...]] device | dir
mount [-fnrsvw] [-t vfstype] [-o options] device dir

DESCRIPTION
All files accessible in a Unix system are arranged in one big tree, the file
hierarchy, rooted at /. These files can be spread out over several devices. The
mount command serves to attach the file system found on some device to the big
file tree. Conversely, the umount(8) command will detach it again.

The standard form of the mount command, is
mount -t type device dir
This tells the kernel to attach the file system found on device (which is of
type type) at the directory dir. The previous contents (if any) and owner and
mode of dir become invisible, and as long as this file system remains mounted,
the pathname dir refers to the root of the file system on device.

The synopsis shows you all the general forms of the command, in your case you typed the last one, which is explained in the last paragraph I included of the description.

In order to help you understand this, you need to realize the different ways in which Windows and UNIX/Linux/Knoppix handle filesystems.

Under Windows, just as an example, if you have two hard disk, each with one partition on, then the first disk will appear as C: and the second will appear as D:. If you put a CD in your drive, it will appear as E:. Any folders shared from other computers that you attach can appear as any letter from F: to Z:.

Under UNIX/Linux/Knoppix, we don't use drive letters. Instead your first filesystem is always known as the root filesystem, and is denoted as /. All other filesystems are then 'mounted' or attached at some point within the directory structure underneath /.

The last two arguments of your mount command - the device and dir ones - basically say "take the filesystem that is contained on this device and make it appear at this directory under root".

Now, the mount command is general purpose, and is used to mount everything including hard disks, cd's, floppy disks and also folders shared from other computers. Obviously each kind of filesystem needs to be handled differently, so one of the first things you need to tell mount is which kind of filesystem it is dealing with. This is the -t command and the smbfs argument says that it is a Windows SMB share.

Each type of filesystem also needs additional options which are specific for that type. These come after the -o flag. For Windows shares, we need to specify a username and password, which are just as you have shown them.

Now in the case of a shared folder, the device is not really an actual device at all, but rather what I think MS calls a UNC or something, which - as you are probably aware - looks like \\machinename\sharename.

So, if we break down your command into its constituent parts....

mount invoke the mount command

-t smbfs tell if we want to attach a share from a Windows machine

-o username=administrator,password=flippers options specific to this share, the username and password for the remote machine.

//Karma/C$ the "device" we want to attach, in this case actually the share C$ on the machine called Karma

/mnt/myshare we want all of the files and directories in the remote share to appear as though the are in the directory called /mnt/myshare on the local machine.

arkaine23
01-27-2004, 05:54 PM
In linux there is usually more than one way to accomplish the same thing. Here's a variation that also works to mount a remote share-

smbmount //$hostname/$sharename /mnt/netdrive -o username=$username

Just change this command so that $hostname is the host you want to connect to, $sharename is the name of the share, and $username is the name of a user who can access the share.

To avoid confusion and permission problems I make a user called knoppix on the windows computer and set $username as knoppix when running the script.

You'll then be prompted for $username's password, and the share will be mounted to /mnt/netdrive.