Knowledge Base Glossary       Exit
(how to) Search  

Browse by Category
Knowledge Base > Products > Image for Linux > FAQ > Using IFL to create/restore images on Windows/Samba shares

Using IFL to create/restore images on Windows/Samba shares

This article covers the details involved in using Image for Linux (IFL) to save/restore images to/from SMB network shares (Windows or Samba network shares). This can be accomplished while running IFL from an installed Linux distribution, or from the IFL Boot Media.

The overall procedure is essentially the same as when working with images on local drives, except that it involves the extra step of mounting the network share before creating or restoring the image. Mounting the network share gives IFL access to the share's files and folders in a directory (the mount point) on the local file system. To get IFL to access the share, you will need to select the File (OS) option on the Backup To and Restore From screens in IFL. Doing that enables you to navigate through the local file system to the mount point directory, and then be able to save and access image files on the share.

1. Mounting SMB shares interactively from the IFL Boot Media

On the IFL Boot Media, there is an interactive, menu-driven method to mount and unmount SMB network shares. This will work in the majority of cases, without having to deal with the command line. To use the interactive method from the IFL CUI boot media, boot up to the IFL main menu, select "Mount Network Shares", and then follow the prompts. When using the IFL GUI boot media, boot up to the IFL desktop, then right-click the desktop and select the "Mount Network Shares" option (or click the "net1" icon on the launch bar). The "Auto Detect SMB Servers" method should work in most cases. If not, try the "Specify SMB Server Manually" method.

If necessary (or if preferred), you can also mount the share directly from the command line by choosing "Exit to Command Prompt" from the main menu (CUI version) or right-click the desktop and select "Terminal" or click the Terminal icon on the launch bar (GUI version). From there, please refer to section (4) below for the details of how to mount a share from the command line using the 'mount.cifs' command.

2. Mounting SMB shares from a Linux distribution 

From a Linux distribution, you can use a GUI tool (such as smb4k, if using KDE) to mount SMB shares, or you can mount them from the command line. In either case, you will need the SMB mount utilities (primarily the 'mount.cifs' command) to be installed. This is typically NOT installed by default. To check if it is installed, open a terminal and type 'mount.cifs' as root (or 'sudo mount.cifs' as a user) to see if mount.cifs exists on the system. If not, you will need to install the smbfs and/or the cifs-utils software package(s).

For example, on recent Debian-based distributions (such as Ubuntu, Linux Mint, etc.), the smbfs package depends on the cifs-utils package, so that installing smbfs will cause both packages to be installed ('apt-get install smbfs'). Installing this package (or packages) will install the 'mount.cifs' utility. Note that the actual package names (smbfs and cifs-utils) may vary somewhat by distribution, but searching for 'smbfs' or 'cifs' in the package manager should locate the package(s) you need. For details on how to mount a share from the command line, please see section (4) below.

3. Notes on the SMB protocols (cifs and smbfs) 

Historically, the smbfs protocol was used to mount SMB shares by using the 'smbmount' command. In recent years, the smbfs protocol has been deprecated in favor of the newer cifs protocol, which uses the 'mount.cifs' command to mount SMB shares. The IFL Boot Media no longer supports smbfs, and the kernels in many newer Linux distributions no longer support it either.

In any case, cifs is now the preferred protocol, and the information in section 4 below assumes the use of cifs and 'mount'cifs'. For information about using 'smbmount' and smbfs, please see section (6) below.

4. Using mount.cifs to mount SMB shares from the command line (from IFL Boot Media or Linux Distribution)

This section uses the 'mount.cifs' command to mount SMB shares from the command line. Before attempting to mount a share, the following requirements/conditions for mounting an SMB share should be reviewed, and the necessary information gathered:

server IP address:  Required on the command line. This is the IP address of the SMB server, which could be a Windows system, or a Linux/Unix system running a Samba server.

share name:
  Required on the command line. On a Windows server this will be the "Share name" as assigned on the Sharing tab when setting up the share. For Samba shares, this will also be the name of the share assigned when creating the share. In the case of the "homes" share, which is typically used to share user home directories, the share name will be the same as the user name (i.e. the name of the user's home directory).

mount point: Required on the command line. The directory where the share will be mounted within the local Linux file system. Once you have successfully mounted a share, the contents of the share will be accessible within that directory. The mount point should be an empty directory. You have the option of using an existing directory, or creating a new one by using the mkdir command. If you are running from the IFL Boot Media, there is already a /mnt directory and a /net1 directory available by default. Either could be used as the mount point.

write permissions: Required to save an image to a share. Typically, shares are configured to not allow writing by default. Write access will be required to save images to the share. In Windows, enabling write access privileges requires checking the box "Allow network users to change my files" (or wording similar to that) on the Sharing tab. On a Samba server, either the line "read only = No" or "writeable = Yes" must exist in the section of /etc/samba/smb.conf that defines that particular share. If neither line is there, the share will be read only.  Also note that the Samba server must be restarted for any changes to smb.conf to take effect.

user name and password: May be required on the command line, depending on how the share is configured. If unsure about what is required, you can try starting with just the "guest" option (more details below). That is the option to use when no user name or password is required to mount a share.

domain or workgroup:  May be required on the command line. In an SMB environment, this will usually be the workgroup name, which is typically set to "WORKGROUP" by default. This parameter is often not required. If in doubt, trying mounting without this parameter first.

root permissions: Usually required to mount a share. On a Linux distribution, you will typically need to be root (or use 'sudo') to be ale to use 'mount.cifs' to mount a share. It is possible to set up an /etc/fstab entry to allow a normal user to mount a share, but this is not typically there by default. On the IFL Boot Media, this is not an issue, since you are always root.

To mount the share, the command line format is as shown below:

mount.cifs  //<ip address>/<share name>  mountpoint  [-o option1, option2 ...]

Some common mount.cifs options (specified after the -o):

   user=<user name>
   SMB user name 
   pass=<password>    SMB password
   credentials=<filename>  
   file containing user name and password
   dom=<workgroup>    workgroup (or domain)
   guest    don't prompt for a password
   ro    mount share read only (rw is default)

Note 1: On some Linux distributions, you may need to use /sbin/mount.cifs instead of mount.cifs.

Note 2: If using more than 1 option after the -o, the options must be separated by a comma, and there should be no spaces before or after the comma.

Note 3: Please see the mount.cifs man page for more complete information, and the additional options available.

The following are some examples of using mount.cifs to mount an SMB share:

Example 1 - No user name or password required
ip address = 192.168.1.55
share name = data
mountpoint = /home/user/images
mount.cifs  //192.168.1.55/data  /home/user/images  -o guest

Example 2 - With spaces(s) in share name
ip address = 192.168.1.55
share name = data (d)
mountpoint = /home/user/images
mount.cifs  //192.168.1.55/"data (d)"  /home/user/images  -o guest

Example 3 - User name and password required
ip address = 192.168.1.55
share name = data (d)
mountpoint = /home/user/images
user = smith
password = 123
mount.cifs  //192.168.1.55/"data (d)"  /home/user/images  -o user=smith,pass=123

Example 4 - Using /mnt as mount point on IFL Boot Media
ip address = 192.168.1.55
share name = data
mountpoint = /mnt
user = smith
password = 123
mount.cifs  //192.168.1.55/data  /mnt  -o user=smith,pass=123

Example 5 - Using /mnt on IFL Boot Media and specifying workgroup
ip address = 192.168.1.55
share name = data
workgroup = SMBNET
mountpoint = /mnt
user = smith
password = 123
mount.cifs  //192.168.1.55/data  /mnt  -o user=smith,pass=123,dom=SMBNET

Once you have executed the mount.cifs command without an error message, you can further verify that the mount was successful by using one or more of the following commands:

df - will show the share mounted at the specified mount point
mount - same as above, but in a different format
ls  <mountpoint>  - will list files on the share (Linux equivalent of 'dir' command)

To unmount an SMB share, use the 'umount' command, along with the mount point. For example, if a share is mounted on the /mnt directory, use the command 'umount /mnt' to unmount the share.

5.  Automating the process with scripts

The process of creating/restoring an image on a network share can be automated by using an executable shell script that makes use of the IFL command line capability. The example below is about the simplest script that could be used to mount a share, create an image, validate the image byte-for-byte, and then unmount the share:

#! /bin/sh
mount.cifs  //192.168.1.155/sharename  /mnt  [-o option1, option2 ...]
/path/imagel  -b --d:0@0x1 --f:/mnt/myimage --vb --uy
umount  /mnt

Due to the nature of networks, it is usually wise to include some error checking. For example, if the mount.cifs command fails because the share is not available, the image could be created on the local file system instead, and could fill up the local partition. It is also advisable to check the exit code of the IFL command (0 = no error) to determine if the imaging operation was successful or not.

For additional help on this subject, the file ifl-smb.zip is available for download. The zip file contains some self-documented example scripts. The scripts include a reasonable amount of error checking, and can be configured to mount a specified share, save/restore one or more images to/from the share, and then unmount the share. The scripts are also suitable for running from a cron job. The scripts must be configured with specific parameters (server, share, user, password, mount point, etc.) before they will do anything. The configuration is accomplished by editing the configuration section at the beginning of the script with a text editor.

6. Using the smbmount command to mount SMB shares from a Linux distribution (deprecated)


While 'smbmount' is no longer supported on the IFL Boot Media, it could still be used from a Linux distribution, if desired and if still supported on your distribution. This is done in essentially the same manner as when using mount.cifs, and uses a similar comand line. The following is the format of the smbmount command line, followed by some notes and examples:

smbmount  //server/share  mountpoint  [-o option1,option2 ...]

Some common smbmount options (specified after the -o):
   username=<user name>
   SMB user name 
   password=<password>    SMB password
   credentials=<filename>
   file containing user name and password
   workgroup=<workgroup>    workgroup (or domain)
   guest    don't prompt for a password
   krb    use kerberos (active directory)
   lfs
   support file sizes > 2 GB
   ro    mount share read only (rw is default)

Note 1: If using more than 1 option after the -o, the options must be separated by a comma, and there should be no spaces before or after the comma.

Note 2: If creating or restoring an image with a file size > 2 GB, the lfs option must be used with smbmount, or the operation will fail. In addition, the server OS, as well as the share file system, must support the file size being used.

At a minimum, you will need to supply the server name, the share name, and the mount point on the command line. If the share name contains spaces, it must be enclosed in quotes on the command line (see example 2 below). Any additional options/parameters required are specified after the -o. The two most commonly required options are the user name and password for the share. For the password, you have a choice of supplying it on the command line, or if not, you will be prompted for it after entering the command. If a password is not required for the share, simply pressing Enter at the password prompt will get you by it. Optionally, you can suppress the password prompt completely by using the guest option (-o guest). You can see a complete list of available options by typing 'smbmount' without parameters, or by reading the man page for smbmount.

The mountpoint parameter shown above is the path/directory where the share will be mounted within the local Linux file system. Once you have successfully mounted a share, the contents of the share will be accessible within that directory. The mount point should be an empty directory. You have the option of using an existing directory, or creating a new one by using the mkdir command. Note that if you are running from the IFL Boot Media, there is already a /mnt directory available that can be used as the mount point.

The following are some examples of using 'smbmount' to mount an SMB share:

Example 1 - No user name or password required
server = winxp
share = data
mountpoint = /home/user/images
smbmount   //winxp/data   /home/user/images   -o guest

Example 2 - With space(s) in share name
server = winxp
share = storage (d)
mountpoin = /home/user/images
smbmount   //winxp/"storage (d)"  /home/user/images   -o guest

Example 3 - User name and password required
server = debian
share = linuser
mountpoint = /home/linuser/images
user = linuser
password = 123
smbmount   //debian/linuser   /home/linuser/images   -o username=linuser,password=123

Once you have executed the smbmount command without an error message, you can further verify that the mount was successful by using one or more of the following commands:

df - will show the share mounted at the specified mount point
mount - same as above, but in a different format
ls  <mountpoint>  - will list files on the share (Linux equivalent of 'dir' command)

To unmount an SMB share, use the 'umount' command, along with the mount point. For example, if a share is mounted on the /mnt directory, use the command 'umount /mnt' to unmount the share.



How helpful was this article to you?


powered by Lore