Difference between revisions of "Network Shared Drive FAQ"


From Knoppix Documentation Wiki
Jump to: navigation, search
(New page: __TOC__ ---- ---- ==== Q: How to setup NFS between knoppix machines via NFS ? ==== A: Here is a step by step approach to show you how to use NFS between 2 knoppix machines. I use Knopp...)
 
 
Line 500: Line 500:
 
----
 
----
 
----
 
----
 +
 +
----
 +
[[Category : FAQ Page]]
 +
[[Category: Networking]]

Latest revision as of 04:43, 18 January 2009



Q: How to setup NFS between knoppix machines via NFS ?

A: Here is a step by step approach to show you how to use NFS between 2 knoppix machines. I use Knoppix 5.1.1 in this test and both machines are booted from the knoppix 5.1.1 cd.


The information here may not be 100% correct, but it works for me. However, if you find something is wrong. Please let me know. Thank you.

chip_ling@yahoo.ca

Chip Ling 1st Jan 2008 (Happy New Year!)


Server machine: Machine 192.168.1.101 boot from the knoppix 5.1.1 cd will act as the server machine, it will open the /testroot directory to all machines within the subnet 192.168.1.*.

Client machine: Machine 192.168.1.102 boot from the knoppix 5.1.1 cd will act as one of the client machines, it will mount the server directory /testroot to it's local mount point /nfsmnt.


Exception Directories Handling: I tried a couple of directories on the server machine following the same steps as the /testroot case but failed.

For example: /ramdisk and /UNIONFS

Here is the error I got when I tried to mount the /ramdisk and /UNIONFS from the client

 $ sudo mount -t nfs 192.168.1.101:/ramdisk /nfsramdisk
 mount: 192.168.1.101:/ramdisk failed, reason given by server: Permission denied
 $ sudo mount -t nfs 192.168.1.101:/UNIONFS /nfsunionfs
 mount: 192.168.1.101:/unionfs failed, reason given by server: Permission denied

The work-around:

I found a work-around to these directories. From the server side, I created two symbolic links under /testroot which point to /ramdisk and /UNIONFS with the identical names.

 $ sudo ln -s /ramdisk /testroot/ramdisk
 $ sudo ln -s /UNIONFS /testroot/UNIONFS

Then when I went through all the steps below, on the client machine, I can always access the server's /ramdisk and /UNIONFS directories by going to /nfsmnt/ramdisk and /nfsmnt/UNIONFS.


1. On the server machine 192.168.1.101

1.1 Create the directory /testroot and set it to read/write/execute to all users

 $ sudo mkdir /testroot
 $ sudo chmod 777 /testroot

1.2 Create the file /etc/exports

 $ sudo vi /etc/exports
 /testroot 192.168.1.0/255.255.255.0(ro,sync,no_subtree_check)

Be careful that there is only one space on the above line.

Save the file.

1.3 Start the NFS related daemons on the server side

 $ sudo /etc/init.d/portmap start
 $ sudo /etc/init.d/nfs-common start
 $ sudo /etc/init.d/nfs-kernel-server start

2. On the client machine 192.168.1.102

2.1 Start the NFS related daemons on the client side

 $ sudo /etc/init.d/portmap start
 $ sudo /etc/init.d/nfs-common start

2.2 Create a directory /nfsmnt on the client machine as the mount point

 $ sudo mkdir /nfsmnt
 $ sudo chmod 777 /nfsmnt

2.3 Mount the server directory /testroot as /nfsmnt on the client machine

 $ sudo mount -t nfs 192.168.1.101:/testroot /nfsmnt

2.4 Done. Now you can access the /nfsmnt mount point as a local directory.



Q: How to setup Samba on Knoppix and share it's drive to other Windows XP machines ?

A: It maybe my problem, however, I can hardly find the information I want from the Samba site so I decided to write some simple steps here and hopefully can help someone.


Objective

I have two Windows XP machines on my network, I want to boot knoppix live CD 5.1.1 on the first machine. Make two locations on the first machine as shareable. Then I try to map these two locations as network drives on the second Windows XP machine.

The following two locations will be made shareable:

 1. The whole C drive
 2. D: drive directory \mp3

I do not want everybody can access my c: drive, so I will limit it to those with the samba account. However, I will open the d:\mp3 location to everybody.


The following steps were tested using Knoppix 5.1.1


The information here may not be 100% correct, but it works for me. However, if you find something is wrong. Please let me know. Thank you.

chip_ling@yahoo.ca

Chip Ling 5th Sep 2008


1. Boot up the first machine to Knoppix

Boot the first machine with Knoppix Live CD 5.1.1. Check for it's IP address by open up the console terminal (the black TV screen like icon on the bottom of the screen) and type in the following command:

 $ ifconfig

To make it easier to follow, I assume the IP address of the Knoppix machine is 192.168.1.101


2. Boot the second machine to Windows XP

Boot the second machine to Windows XP and write down it's IP address. To obtain the machine's IP address. Open up the command prompt (DOS box) and enter the following command:

 C:\> ipconfig

I assume the IP address of the Windows XP machine is 192.168.1.102


3. Make sure the two machines talk to each other

From the Knoppix machine, try to ping the Windows XP machine, on the console terminal, enter the following command:

 $ ping 192.168.1.102

You should get lines response back saying it got reply from 192.168.1.102, hit Control+C to exit.


From the Windows XP machine, from the DOS box, try to ping the Knoppix machine:

 C:\> ping 192.168.1.101

You should get 4 lines response and it will stop by itself.

Now you are sure these two machines can talk to each other.


4. Mount the c: drive and d: drive to the Linux file system on the first machine

Since I boot up the Knoppix from Live CD so both drive c: and drive d: are not mounted by default. In order to share them to other machines on the network, I have to mount it first.

I have a SATA hard drive divided into two partitions (c: drive and d: drive). So my device name in Linux will be sda1 and sda2.

I have other machines with the old IDE hard drive with the same partition setting which will show in Linux as hda1 and hda2. So according to your own setting, use the correct device name. Here I will use sda1 and sda2 as an example.

Both the c: drive and d: drive are formatted to NTFS format.

From the knoppix machine, the console terminal, enter the following commands:

 $ su
 # mount -t ntfs /dev/sda1 /media/sda1
 # mount -t ntfs /dev/sda2 /media/sda2

OK, now I have both c: drive and d: drive mounted as read-only on mount points /media/sda1 and /media/sda2

Note: If your drive is formatted as FAT32, change the "-t ntfs" to "-t vfat" on the above mount commands.


5. Create a Samba user called "knoppix" with password

Enter the following commands from the console terminal of the knoppix machine:

 # smbpasswd -x knoppix
 # smbpasswd -a knoppix

To stay on the safe side, I remove the user "knoppix" first and then add him back in. It will ask you twice for a password, in this example, I use the password "12345678".


6. Edit the /etc/samba/smb.conf

Use the editor of your choice to edit the /etc/samba/smb.conf file. I only know vi so I do the following from the console terminal on the knoppix machine:

 # vi /etc/samba/smb.conf

Append the following lines to the file and save it.

 [drivec]
 path=/media/sda1
 browseable = no
 read only = yes
 
 [mp3]
 path=/media/sda2/mp3
 browseable = yes
 read only = yes

Some explanations here:

"[drivec] and [mp3]" will be the share drive names that Windows will see and use later on.

"path=/media/sda1" means the c: drive, the root directory (i.e. the whole c: drive).

"path=/media/sda2/mp3" means the d:\mp3 folder.

"browseable = no" means not all users can connect to this location. Only those with a Samba user account can access this location.

"browseable = yes" means all users can connect to this location.

"read only = yes" means read-only.


7. Restart the Samba to make the new change effective

From the console terminal on the knoppix machine, enter the follow commands:

 # /etc/init.d/samba restart


8. Map the share drive [drivec]

From the Windows XP machine

==> open the window explorer

==> click on Tools

==> click on Map Network Drive

==> Pick a drive id: ==> I select Z: here

==> On the Folder field, enter:

 \\192.168.1.101\drivec

==> click Finish

Another dialog box pops up asking for user-name and password: enter user=knoppix and password=12345678 and then click OK.

Another window explorer window pops up and connects to the remote knoppix box drive c:\ as the network drive Z:.


9. Map the share drive [mp3]

From the Windows XP machine

==> open the window explorer

==> click on Tools

==> click on Map Network Drive

==> Pick a drive id: ==> I select Y: here

==> On the Folder field, enter:

 \\192.168.1.101\mp3

==> click Finish

This time it will not ask for user id and password.

Another window explorer window pops up with and connects to the remote knoppix box drive d:\mp3 as the network drive Y:.


Voila. So we are done now.

From the Windows XP machine, we can access the two locations on the knoppix machine via the network drive id Z: and Y:.

Welcome to the Samba world in Knoppix and have fun.

By changing the read only parameter from yes to no and modify the step 4 mount to read/write will open the location for write access but I suggest to use it with really really great care. You don't really want someone to delete all your c: drive content by mistake, right? Don't say I did not warn you...



Q: How to automate Samba setup on Knoppix 5.1.1?

A: There maybe a lot of solutions but here I wrote a bash shell script to achieve the goal.

Chip Ling 23 Sept 2008


Objective

To avoid typing all the steps every time we reboot the knoppix machine. By creating a script on c:\ or /media/sda1, we only need to run the script once after each reboot.


Network set up

This FAQ is based on the setting of the previous FAQ question. So please revisit the previous FAQ to get a complete picture.


1. Boot up the Knoppix machine

Insert the Knoppix 5.1.1 Live CD and boot the system up on the first machine.


2. Mount the c: drive as read/write

Click on the konsole icon (the black TV screen at the bottom) and then enter the follow command.

 $ sudo mount -t ntfs /dev/sda1 /media/sda1 -o rw

Again if your PC is using IDE harddisk, then replace all the sda1 by hda1. If your hard disk is formatted as FAT32 instead of NTFS, replace "-t ntfs" by "-t vfat".


3. Create the autosmb.sh on /media/sda1

Use the editor of your choice to create the autosmb.sh on /media/sda1. (i.e. it is on the c:\, so if you create the file under windows, it SHOULD work as well. Let me know if it is not, I never try it myself from the windows side.)

 #!/bin/bash
 ####################################################
 ### autosmb.sh by Chip Ling
 ####################################################
 if [ ! -e /media/sda1/autosmb.sh ]; then
   sudo mount -t ntfs /dev/sda1 /media/sda1
 fi
 sudo mount -t ntfs /dev/sda2 /media/sda2
 
 sudo smbpasswd -x knoppix > /dev/null
 sudo smbpasswd -a -s knoppix <<EOF
 12345678
 12345678
 EOF
 
 sudo chmod 666 /etc/samba/smb.conf
 cat >> /etc/samba/smb.conf <<EOF
 
 [drivec]
 path=/media/sda1
 browseable = no
 read only = yes
 
 [mp3]
 path=/media/sda2/mp3
 browseable = yes
 read only = yes
 EOF
 
 sudo chmod 644 /etc/samba/smb.conf
 
 sudo /etc/init.d/samba restart
 
 ipaddr="\\\\$(ifconfig eth0 | head -2 | tail -1 | cut -f2 -d':' | cut -f1 -d' ')"
 msg1="\nPlease map to ${ipaddr}\\drivec"
 msg2="\nand           ${ipaddr}\\mp3"
 
 dialog --title "Samba restarted" --msgbox "${msg1}${msg2}" 7 60


Save the file.

The script basically replicates what we manually did on the previous FAQ. Please be careful about the spacing on the "if ... then" statement. Cut and paste is not a bad idea.


Then from the konsole, change the file attribute to executable

 $ sudo chmod 777 /media/sda1/autosmb.sh

And we are done.

Please note that I do not need to perform the above step on my machine. I check the file attribute and it is set to 777. I put the command here just in case.

Now, we can reboot the knoppix machine again and see how it works.


4. The real thing

First reboot the knoppix from the Live CD.


Then mount the c: drive to the file system.

For GUI user: single click the "Hard Disk [sda1]" icon on the desktop. The icon will then have a green tag appears at the lower right hand corner (means mounted) and Konqueror pops up.

For command line user: from the konsole, enter

 $ sudo mount -t ntfs /dev/sda1 /media/sda1


Now run the auto-samba setup script:

For GUI user: single click on the autosmb.sh file icon inside Konqueror.

For command line user: run the autosmb.sh script in konsole

 $ /media/sda1/autosmb.sh

The script should setup the samba configuration and then display the share drive mapping information from a dialog box.

 Please map to \\192.168.1.101\drivec
 and           \\192.168.1.101\mp3

Now the samba setting on the knoppix side is done, move forward to the windows box to map the share drives.




Q: How to setup Knoppix and read the share drive on Windows XP machine ?

A: Use the ordinary unix mount command will do the trick.


Objective

I have two Windows XP machines on my network, I want to boot knoppix live CD 5.1.1 on the first machine. Boot windows XP on the second machine. Setup a folder on the windows XP machine as shareable. Then access the shared folder from the Knoppix machine.

The following location on the Windows XP box will be made shareable: d:\video



The following steps were tested using Knoppix 5.1.1


The information here may not be 100% correct, but it works for me. However, if you find something is wrong. Please let me know. Thank you.

chip_ling@yahoo.ca

Chip Ling 12th Jan 2009


1. Boot up the first machine to Knoppix

Boot the first machine with Knoppix Live CD 5.1.1.


2. Boot the second machine to Windows XP

Boot the second machine to Windows XP and write down it's IP address. To obtain the machine's IP address. Open up the command prompt (DOS box) and enter the following command:

 C:\> ipconfig

I assume the IP address of the Windows XP machine is 192.168.1.102


3. Configure the Windows XP d:\video folder to be shareable

From Windows Explorer

==> On the left panel go to d:\video folder

==> right click on d:\video

==> select Sharing and Security...

==> under the Sharing Tab

--> select Share this folder

--> enter "video" on the Share name field

==> click Apply

==> click OK


4. Create a directory on the knoppix machine as the mount point for the shared folder

Enter the following commands from the console terminal of the knoppix machine:

 $ su
 # mkdir /media/winbox


5. Mount the shared folder

From the console terminal on the knoppix machine:

 # mount -t smbfs //192.168.1.10/video /media/winbox -o username=chip,password=1234567


6. Done

Now you can access the windows xp shared folder from /media/winbox