Hack 41 Create an Emergency File Server 
When files need to be transferred quickly over
the network, Knoppix can serve as a quick makeshift file server.
There are many different
occasions that might call for creating an emergency file server. For
instance, you might have a file server with multiple drives that has
suffered hard-disk failure on the root drive. All of the hard disks
that have shared data are fine, but you need to still serve files
while waiting on the replacement drive. This is the perfect
environment for anyone wanting to learn how to configure Samba or
start up a quick temporary file server. For experienced systems
administrators, this makes it easy to share all the drives on an
infected system for a quick virus scan by a centralized corporate
virus scanner while the infected OS is shut down. You can even
connect a spare machine to a printer, boot Knoppix, and quickly
configure a makeshift network printer server.
Knoppix includes a nice GUI configuration utility to configure Samba
(the Linux SMB file server). You aren't required to
use the Knoppix Samba utility to set up a file server. If you already
know which kind of configuration you want, simply edit
/etc/samba/smb.conf directly, and then run this
command to start the Samba process:
knoppix@ttyp0[knoppix]$ sudo /etc/init.d/samba start
To use the Knoppix-provided Samba configuration utility, click K
Menu KNOPPIX Services Start Samba Server.
Each time you run this script, it wipes out the previous Samba
configuration, so don't run this script if you have
made changes to smb.conf that you want to keep.
This program prompts you to choose a password to assign to the
knoppix user if there isn't
already one, because Knoppix's default behavior
requires a username and password to access any shares it creates.
After it confirms your password, Knoppix asks you whether you want to
export all your hard drives so that remote machines can access them.
If you answer "no" to this
question, the script creates an smb.conf file
that shares your home directory and any printers that you have
previously configured on the system. If you answer
"yes" to this question, the script
adds shares for all hard drives and CD-ROM drives that Knoppix has
detected, and automatically mounts the devices for you as they are
accessed. Once you click "yes" or
"no," the script creates the
smb.conf file and starts Samba.
If you only want to share all of the drives on your system as
read-only over the network, then you are finished. By default, the
share shows up in the WORKGROUP workgroup as a
machine named KNOPPIX, and if you have shared all
of the drives on your system, they appear with the same names they
were previously assigned on your desktop, such as
hda1. You can find the configuration for each
drive at the bottom of the /etc/samba/smb.conf :
[hda1]
comment = /mnt/hda1
browseable = yes
path = /mnt/hda1
writeable = yes
preexec = /bin/mount /mnt/hda1
postexec = /bin/umount /mnt/hda1
These shares all require that you log in with the username
knoppix and the password you created for the
knoppix account. Then Knoppix automatically
mounts the drive when you access it and unmounts it when you are
finished. Notice that by default, Samba is configured to allow
writing to the drives, but Knoppix automatically mounts all drives
read-only, so it overrides this, and you are still able to read from
the drives. To allow write access to a drive, modify the
preexec line in smb.conf to
read:
preexec = sudo /bin/mount -o rw /mnt/hda1
and replace /mnt/hda1 with the drive you are
configuring. To allow anyone to access the share without requiring a
password, add the following line to the share's
configuration:
guest ok = yes
In general, you do not need to restart Samba for share level changes
to take effect; however, changes you make to the global configuration
(under the [global] header) require you to restart
Samba.
To share something entirely different from the hard drives, add new
shares to the default configuration. It doesn't
matter which script option you chose earlier, just add the new
configuration to the end of the file. The following example creates a
new directory called share under the home
directory knoppix and configures it as a guest
share under Samba. First, create the share
directory:
knoppix@ttyp0[knoppix]$ mkdir /home/knoppix/share
Then edit /etc/samba/smb.conf as root, and add
the following lines:
[share]
comment = Knoppix share
browseable = yes
path = /home/knoppix/share
writeable = yes
guest ok = yes
Once you save your changes, the new share immediately appears, and
anyone is able to view, add, and delete files in that directory. Keep
in mind that this share is running off of your home directory that is
in a ramdisk by default. The size of files stored here are limited by
RAM, so for storing large files, you want to configure a share on the
system's hard drives.
 |
Remember that each time you run the Knoppix Samba configuration
script, it creates a new smb.conf, and any
manual changes are lost.
|
|
|