There are a multitude of roles for which Ubuntu Server is well suited. In many cases it's possible to task a server...
with multiple roles. When you initially install Ubuntu Server, you're given a list of options including OpenSSH, DNS, LAMP, Mail, PostgreSQL database, Print, Samba, Tomcat Java and Virtual Machine host.
Using virtualization it is possible to host different roles as individual virtual machine (VM) instances, making it easier to perform updates and system reboots without taking other services down. For a storage role, you can set up a file server using Samba. But, in today's enterprise environment you're more likely to find network-attached storage (NAS) using iSCSI, and Ubuntu Server 11.04 is up to the task. A NAS iSCSI storage server is not a role configurable from the install menus, but it's not hard to set up. The key to setting up a server for this storage role is a combination of hardware (a lot of disk space), plus the right software modules and configuration. In this tip I will cover what it takes to get everything configured properly and how to manage the system once setup is complete.
Setting up Ubuntu 11.04 as an iSCSI target
Configuring an Ubuntu server as an iSCSI target is not difficult as long as you are comfortable with the command line. The first thing you have to do is install the iscsitarget package. From the command line as root type:
aptitude install iscsitarget
After that process completes, you must edit the file /etc/default/iscsitarget and change option from false to true. The line should look like:
The iscsitarget module handles security in a number of ways. Using the file /etc/initiators.allow makes it possible to specify access on an IP address basis. By default, this file has the entry "ALL ALL" meaning it gives access to all targets by any requestor. To start the service type:
There won't be any targets available at this point, but you can see the service running by looking at the iscsitarget module, which uses port 3260 for all communications. The lsof (list open files) command with the –i parameter can be used to determine if any process is attached to that port:
# lsof -i:3260 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME ietd
1356 root 8u IPv4 8958 0t0 TCP *:3260 (LISTEN)
ietd 1356 root 9u IPv6 8959 0t0 TCP *:3260 (LISTEN)
The netstat command combined with grep will also check for activity on port 3260:
netstat -apne | grep 3260
There are a number of different options for creating an iSCSI target device. These include a physical device, a logical volume, or a file. There are performance issues with a file-based device depending on the type of drive it resides on. Here's the command to create an empty 20 GB file you can use as a file-based target:
dd if=/dev/zero of=/storage/lun1.img bs=1024k count=20000
Adding a target volume requires the editing of the ietd.conf file. This is the configuration file for the iSCSI Enterprise Target daemon (ietd). In Ubuntu Server 11.04, this file resides in the /etc/iet directory. Previous verisons of Ubuntu Server had this file in the /etc directory. In this file are many options commented out with a #. The first line you need to change is the Target line:
The second line that needs to be changed is the line defining Lun 0. LUN numbers must start with zero, and every target must have a Lun 0:
Lun 0 Path=/storage/lun1.img,Type=fileio
Once that's complete, restart the iscsitarget module with the command:
To check the status you can view the contents of two files (volume and session) in the /proc/net/iet directory:
root@ubuntvmsrv:/etc/iet# cat /proc/net/iet/volume
lun:0 state:0 iotype:fileio iomode:wt blocks:2048000 blocksize:512 path:/storage/lun1.img
root@ubuntvmsrv:/etc/iet# cat /proc/net/iet/session
iSCSI target management on Ubuntu
Webmin is a great tool for managing any Linux server system. But, a module needs to be added to manage the iSCSI target configuration. Adding Webmin modules is simple: open a Web browser and go to webmin.org and click on “Third-Party Modules” and search for iSCSI then copy the link and paste it into the Webmin add module screen. This provides access to all the iSCSI and storage configuration options necessary to manage your system. This shows the files and script commands that Webmin uses to do its configuration job.
Webmin provides access to the underlying storage hardware to include RAID configuration, disk partitions and full control over Logical Volume Management (LVM).
With the addition of Webmin you can avoid command-line configuration of Ubuntu Server 11.04. This Linux operating system distribution is good for general-purpose server functionality, including a low-cost storage server.