A Linux User Reference

Search tips
  • search ignores words that are less than 4 characters in length
  • searches are case insensitve
  • if a search does not return anything try it in Boolean mode then Query expansion mode by checking the appropriate radio button e.g. searching for 'cron' in just the Administration category returns nothing - presumably because the 50% threshold is reached. Boolean mode ignores this threshold so a search for 'cron' returns several hits
  • in Boolean mode preceding a word with a '+' means the result must include that word, a '-' means it must not
  • in Boolean mode '+crontab -anacron' means match articles about crontab that DO NOT mention anacron
  • to match a phrase e.g. 'manage system' check the Boolean mode radio button and enclose the phrase in quotes "some phrase ..."
  • in Query expansion mode the search context is expanded beyond the keywords you entered - relevancy of hits may well be degraded



  • The root filesystem

    Some things about the root filesystem:

    • In general, filesystems are hierarchial structures containing stored objects.
    • The root filesystem '/' can be pictured as a tree, its stored objects (other filesystems, directories and files) being represented as branches and leaves stemming from it's base/root.
    • Do not confuse the root user's home directory (/root) with the root (/) filesystem.
    • To use a filesystem it needs to be mounted.
    • A filesystem is mounted on a mount point - a directory.
    • The root filesystem is mounted on the root '/' directory.
    • '/' is the top level directory. All other directories and filesystems are mounted below it (within the '/' directory).
    • Every linux system has a '/' root directory.
    • It is the first filesystem to be made available during boot.

    The directories listed below '/' are always part of the root directory and include:

    Directory Contents
    / Files and dirctories needed by boot
    /bin, /sbin Required system binaries
    /dev Device files
    /etc System configuration files
    /lib Shared libraries

    The remaining directories can and usually are, created as separate filesystems in separate partitions. They include:

    Mount point Contents
    /boot Contains static files used by the boot loader - kernel image, GRUB,, ramdisk images, ...
    /home User home directories
    /tmp Temporary files
    /usr User commands, source, documentation, ...
    /var System and application log files

    Filesystems in general

    • Filesystems may provide local or remote access. Remote access is often via a client to a fileserver using network protocols such as NFS, SMB or 9P.
    • Users can also create their own filesystems such as /www for web files, /srv for third party server applications, /share ...
    • Sub-directories can also be sub-divided into filesystems such as /usr/local/, /usr/src ....
    • Logical volumes can be used to group disks and partitions.

    Filesystem information nodes - inodes

    • Information about each object within a filesystem is contained in an 'information node' (an inode).
    • Multiple objects within the same filesystem can share the same inode (linking - hard or symbolic).
    • Each linux ext2, ext3 and ext4 filesystem is created with a finite number of inodes based on the size of the filesystem.
    • It is possible for a filesystem, if it contains a very high number of small files, to run out of inodes. A way to rectify this is to backup the filesystem and recreate it using
    mke2fs -N num-of-inodes ...
  • Kernel filesystem support

    There are many supported types of filesystems such as xfs, reiserfs, vfat, ext2, ext3, ext4 ... To get an idea of which file systems are supported and for which filesystems support is enabled you can

    /boot$ grep _FS= config-3.8.0-33-generic
    /boot$ grep _FS= config-3.8.0-33-generic | wc -l
    /boot$ grep _FS=n config-3.8.0-33-generic 

    Since this is a generic kernel, support for all filesystems has been enabled (the majority as modules).

    ext3 - a journaled ext2 filesystem

    # mke2fs -j -L Label /dev/sdaX         (creates a ext3 FS)
    # tune2fs -j /dev/sdaX                 (upgrades an ext2 -> ext3. REMEMBER to update /etc/fstab)

    ext4 is the latest.

    vfat - dos and early windows filesystem

    Available in dosfstools package on both Debian and Red Hat.

    • 'mkfs.vfat' creates
    • 'fsck.vfat' checks

    Mount a floppy drive on /mnt

    # mount -t vfat /dev/fd0 /mnt

    can read and write to floppy from linux.

  • Create a fileystem
    /sbin/mkfs, mke2fs

    The partition in which a filesystem will reside must be created first.

    'mkfs' is a front-end for

    /sbin/mkfs.msdos, /sbin/mkfs.cramfs, /sbin/mkfs.ext2, /sbin/mkfs.ext3, 
    /sbin/mkfs.ext4, /sbin/mkfs.vfat .....

    'mke2fs' is another front-end only for

    /sbin/mkfs.ext2, /sbin/mkfs.ext3, /sbin/mkfs.ext4

    Command defaults are configured in '/etc/mke2fs.conf'

  • Auto Mount Daemon (AMD)
    Brief intro to auto mounting

    Automounting is used for mounting non-fixed or removable media such as floppies, CDs, USB drives and NFS.

    AMD appears to the kernel as a user-level NFS/UDP server, the kernel sends RPC messages to AMD as it would a NFS server but uses the loopback address instead.

    As a user-land NFS server there is a performance hit, also if AMD were to crash it could hang every process on the system that was trying to access the automounted directories. Because of this a special in-kernel automounter helper filesystem called 'autofs' was devised. 'autofs' often works in conjunction with a user-level automounter whose job is reduced to map lookup and parsing.

    AMD is older and operates in userland, runs periodically to see if any new mountable filesystems have become available. Primarily for NFS. Largely replaced by autofs.

    AMD consists of a user-level daemon that attaches itself to a directory, called an automount point. It receives requests whenever users try to access an automounted directory. It uses its maps to determine where the requested physical resource is located and mounts it (using NFS if necessary) in the automounter directory tree. It then links the mount point to a regular file that the user accesses (do not create these links - AMD does this automatically).

    BSD 4.4 am-utils package, AMD related binaries and files:

    File Purpose
    /usr/sbin/amd AMD binary
    /etc/amd.conf AMD config file
    /etc/rc.d/init.d/amd AMD startup script
    /.automount Temporary directory to manage the automount points, Automounter Directory tree
    /var/log/messages Log files (depends on your configuration in syslog.conf)
  • AMD configuration

    AMD maintains its mounts beneath a temporary directory, in the 4.4BSD implementation this defaults to /.automount, others use /a.

    # amd -a </path-to/directory tree> ...

    Whatever directory is used, it must exist before running 'amd -a ....'

    When AMD starts, it loads automounter maps for each automount point defined in it's configuration file. Automounter maps can be read from plain files, NIS/NIS+, LDAP, N/DBM and more.

    AMD configuration file - /etc/amd.conf

    # global options are applicable to all automounted directories
    log_file = /var/log/amd
    debug_options = all,noreaddir
    # Definition of an automounted directory
    map_type = file                                  # Map type is a text file
    map_name = /etc/                          # Location of the map file to use
    mount_type = nfs                                 # What sort of mount it is
    # /net maps are commonly used to allow the 
    # mounting of any exported filesystem from 
    # any host.
    # Definition of an automounted directory
    map_type = nis                                   # Map type is an nis map
    map_name = /etc/
    mount_type = autofs

    Example mount with sample net map - /etc/

    defaults     fs:=/share/${rhost}/${rfs}
    *            rhost:=${key};type:=host;rfs:=/
    # Comments
    # fs:=              Defines the pathname on the local host where AMD mounts
    #                   remote hosts' filesystems, must be unique
    # ${rhost}          Expands to the name of the remote server
    # ${rfs}            Expands to the name of the remote (exported) filesystem
    # *                 Wildcard that matches anything and sets the key variable's value
    #                   to the value of the name being looked up inside /net
    # type:=host        A special AMD mount
    # rfs:=/            Requests that all exported filesystems from the remote system, 
                        starting with '/', be mounted

    If a server named remote-serv1 exports two filesystems - '/homes' and '/projects/secret'. The sample '/net' configuration (above) will, when a user on the local system accesses '/net/remote-serv1', substitute the placeholder variable rhosts with remote-serv1 and rfs with '/homes' and '/projects/secret'.

    AMD will mount remote-serv1:/homes on /share/remote-serv1/homes and remote-serv1:/projects/secret on /share/remote-serv1/projects/secret as specified by the fs variable. An 'ls' of '/net/remote-serv1' will show these two directories.

    Sample map file - /etc/

    # User home directories
    /defaults      type:=nfs;opts:nosuid,nodev
    mark           rhost:=remote-serv1;rfs:=/it-home-directories/mark
    sue            rhost:=remote-serv2;rfs:=/admin-home-directories/sue
    # comments
    # /defaults    Defines values common to all entries in the map; here, all mounts in this map are NFS mounts
    # nosuid       Don't allow suid programs
    # nodev        Don't allow device files
    # rhosts       Specifies the remote server name
    # rfs          Specifies the the remote filesystem name 

    When a request is made to access '/home/sue' AMD uses nfs to mount the remote directory 'remote-serv2:/admin-home-directories/sue' on '/.automount/home/sue' and links it to '/home/sue'.

    Auto mount CDs. Sample CD-images map - /etc/amd.cdisos

    /defaults      type:=cdfs;opts:=loop
    shrike1        dev:=/iso/rh9/shrike-disc1.iso
    shrike2        dev:=/iso/rh9/shrike-disc2.iso
    shrike3        dev:=/iso/rh9/shrike-disc3.iso
  • AMD extensibility mechanism

    By using a mount type of 'program' a custom method of mounting/unmounting filesystems can be used.

    Using a script to mount/unmount a filesystem - /etc/amd.cdisos

    # A somewhat contrived example
    specialfs    type:=program;dev:=/dev/sda11; mount:="/usr/local/sbin/ mount ${dev} \
                 ${fs}"; unmount:="/usr/local/sbin/ unmount ${fs}"
    # In the above the variable 'dev' is set to /dev/sda11.  This and the automatically 
    # determined 'fs' parameter are passed to the script '' as args (only 'fs'
    # is passed when unmounting).
    # Sources:
  • AMD automount daemon

    Automount daemon, see man pages.

    amd [options] [directory] [conffile]
     -a <dir>                  Defines the temporary directory to manage the mount points
     -l syslog                 Tells AMD to log all messages via syslogd
     -c <int s>                Cache the remote host's filesystem for <int> seconds
     /net                      Tells AMD to put it's links in this directory
     /etc/amd.conf             Tells AMD where to find it's config files

    A common 4.4BSD invocation

    # amd -a /.automount -l syslog -c 1000 /net /etc/amd.conf
  • AMD query tool

    Provides a simple way of determining the current state of AMD program using RPC. By default a list of mount points and auto-mounted filesystems is output.

    amq [options] directory ...
    Some options:
     -f                  Flush the internal caches and reload all the maps.
     -h hostname         Query 'hostname'.  By default the local host is used.
     -m                  Provide a list of mounted filesystems with reference 
                         and error stats.
     -p                  Return the process ID of the remote or locally running amd.
     -s                  Provide system-wide mount statistics.
     -u                  Unmount the filesystems named in directory instead of 
                         providing information about them. Unmounts are requested,
                         not forced. They merely cause the mounted fs to timeout.
     -v                  Version information. A subset of the information output by
                         amd's -v option.

    List mounted filesystems and system wide mount statistics

    # amq -ms

    Using amq and tcp wrappers

    /etc/amd.conf entry

    use_tcpwrappers = yes

    /etc/hosts.allow entry

    amd: localhost

    /etc/hosts.deny entry

    amd: ALL
    main files

    Autofs is a kernel process - compiled into the kernel. Map files can be stored in NIS, LDAP and as flat files.

    File Description
    /usr/sbin/automount autofs binary
    /etc/auto.master Master file
    /etc/auto.misc Map file
    /etc/rc.d/init.d/autofs autofs startup script
    /usr/lib/autofs autofs libraries
    /lib/modules//fs/autofs.ko autofs loadable module
    /.autofs Temporary directory to manage the mount points
    /var/log/messages Log files (depends on syslog.conf)

    Check that autofs kernel parameters are enabled

    /boot $ grep -i autofs config-2.6.24-24-generic

    If not then need to enable the above two parameters and recompile the kernel

    Install the autofs package - on debian/ubuntu

    $ sudo aptitude install autofs
    Setting up autofs (4.1.4+debian-2.1ubuntu1) ...
    Creating config file /etc/auto.master with new version
    Creating config file /etc/auto.misc with new version
    Creating config file /etc/ with new version
    Creating config file /etc/auto.smb with new version
    Creating config file /etc/default/autofs with new version
    Starting automounter: loading autofs4 kernel module, no automount maps defined.

    Check the install

    $ cat /proc/filesystems | grep autofs
    nodev   autofs
    $ lsmod | grep autofs
    autofs4                23044  0
    $ ls /etc/init.d | grep autofs

    Autofs uses map files for its configuration. The following default maps are provided by the installation.

    $ ls -al  /etc/auto.*
    -rw-r--r-- 1 root root  345 2008-04-10 18:04 /etc/auto.master
    -rw-r--r-- 1 root root  581 2008-04-10 18:04 /etc/auto.misc
    -rwxr-xr-x 1 root root 1335 2008-04-10 18:04 /etc/
    -rwxr-xr-x 1 root root  737 2008-04-10 18:04 /etc/auto.smb

    Both '' and 'auto.smb' are required to be executable.

    Required /etc/nsswitch.conf entry

    automount:     files nisplus
  • AUTOFS master map file

    This map defines the top-level directory for each mount point that should be governed by autofs.

    Each mount point has an automount map associated with it (/etc/auto.). This file defines the subdirectories (key), mount options and location of the resource.

    Supported map types - file, program, yp, nisplus, hesiod, userdir, ldap

    Example master map - /etc/auto.master

    # Format: 
    # <mount point> whitespace <maptype:mapname> whitespace [options]<
    # where whitespace is space(s) or tab(s)
    # Check for a NIS map of the same name, it can be found using nsswitch sources
    # Temporary mount directory, its contents are managed my the automount daemon autofs
    # Unmounting will occur automatically, in this, case 10 seconds after last access
    /misc      /etc/auto.misc    --timeout=10
    # Accessing /net/remote-server will mount exports from myserver on directories 
    # below /net/remote-server mounts done from a hosts map will be mounted with 
    # the "nosuid" and "nodev" options unless the "suid" and "dev" options are 
    # explicitly given
    /net      -hosts
    # Any access to /home will cause autofs to consult /etc/auto.home map file
    /home      /etc/auto.home
    # Any access to /mnt will cause autofs to consult the NIS map file

    If the above configured top-level directories (/net, /misc, /mnt, /home) do not exist then create them. Do not add or delete links, files, sub-directories from these top-level directories. This is all handled by autofs.

  • AUTOFS top-level directory maps
    • Any string containing a ':' specifies the resource to mount.
    • If ':' is a prefix the resource is local to the system.
    • If ':' is not a prefix then the resource is remote and NFS mounted by default.

    Sample top-level directory map - /etc/auto.misc

    # Format:
    # key [-comma-separated list of mountoptions] location
    cdrom     -fstype=iso9660,ro,nosuid,nodev   :/dev/cdrom
    floppy    -fstype=vfat,rw,sync,umask=002    :/dev/fd0
    floppy    -fstype=auto,rw,sync,umask=002    :/dev/fd0
    # To automount server winnt under /misc/winnt
    winnt     -fstype=smbfs,login=your_id,passwd=xxxxxx     winnt:
    # If access is requested to /misc/floppy autofs will attempt 
    # to mount /dev/fd0 on /misc/floppy.

    Another top-level directory map example - /etc/auto.home

    # /home/mark is mounted from remote-server:/server/home/mark
    mark      -rw,intr,hard       remote-server:/server/home/&
    # Whenever a home directory other than mark is requested, the corresponding 
    # directory will attempt to be mounted from remote-server:/server/homes
    # e.g./home/fred will be mounted from remote-server:/server/homes/fred
    *         -rw,intr,hard       remote-server:/server/homes/&
    # where & is replaced by the key - in this case a user account name
    After modifying maps

    If a map other than auto.master is modified then the change will become effective immediately.

    If the auto.master map is modified then the autofs script must be rerun to activate the changes.

    Reload autofs

     # /etc/init.d/autofs reload       ([start|stop|status|reload|condrestart])
  • AUTOFS 2 CD-rom auto mount example

    Have 2 cdroms. Each cdrom is to be accessed via /vol/cd/1 and /vol/cd/2.

    In /etc/auto.master

    /vol    /etc/auto.vol                     # Top level autofs governs /vol

    In /etc/auto.vol

    cd     -fstype=autofs     file:/etc/

    'cd' is defined as a submount where '/etc/' is it's map file.

    Accessing '/vol/cd' causes autofs to create '/vol/cd' and starts a new instance to govern it.

    In /etc/ map file

    0      -fstype=iso9660,ro      :/dev/cdrom0
    1      -fstype=iso9660,ro      :/dev/cdrom1

    Accessing '/vol/cd/1' causes the governing autofs instance to create '/vol/cd/1' and attempt to mount '/dev/cdrom1' on it.

    • Auto mounting of removable media on access
    • 'supermount' and 'submount' are kernel-level tools (either compiled into the base kernel or as kernel modules) to automatically mount removable media when accessed.
    • 'submount' is somewhat newer, but 'supermount' is still probably used in more distributions. Neither tool is useful for NFS remote mounts, but either is more seamless than 'autofs' for local media.
    • 'submount' specifies the block device in the regular location rather than as a mount option. In either case, devices requiring automounting are generally listed in the /etc/fstab.

    Sample supermount enabled fstab entries - /etc/fstab

    none    /mnt/cdrom   supermount   fs=auto,dev=/dev/cdrom           0 0
    none    /mnt/floppy  supermount   fs=auto,dev=/dev/fd0,--,user,rw  0 0

    Sample submount enabled fstab entries - /etc/fstab

    /dev/cdrom    /mnt/cdrom    subfs    fs=cdfss,ro,users      0 0
    /dev/fd0      /mnt/floppy   subfs    fs=floppyfss,rw,users  0 0
  • ISO9660
    CD, DVD burning
    Burning cd-roms

    create a directory tree containing all files to include

    use mkisofs to generate an iso image


    Joliet - Windows

    Rock Ridge - Filenames < 30 chars, UID/GID perms, POSIX symbolic links and devices

    ISO9660 pre-mastering program - /usr/bin/mkisofs, genisoimage

    # file `which mkisofs`
    /usr/bin/mkisofs: symbolic link to `/etc/alternatives/mkisofs'
    # file /etc/alternatives/mkisofs
    /etc/alternatives/mkisofs: symbolic link to `/usr/bin/genisoimage'

    A pre-mastering program to generate ISO9660/Joliet/HFS hybrid filesystems.

    genisoimage, mkisofs [options] [-o filename] 
                         pathspec [pathspec ...]
     -J              Joliet
     -ldots          Allow ISO9660  filenames  to  begin with a period
     -l              Allow full 31-character filenames
     -f              Follow symbolic links when generating the filesystem
     -o fname        Write image to named file
     -R              Generate SUSP and RR records using the Rock Ridge protocol to 
                     further describe the files on the ISO9660 filesystem
     -r              Like '-R' but file ownership and modes are set to more useful values
     -T              Generate a file TRANS.TBL in each directory on the CD-ROM.  This can
                     be used on non-Rock Ridge capable systems to help establish the 
                     correct filenames

    Create a joliet image file

    # mkisofs -T -r -ldots -l -J -o /tmp/image.iso /var/backup

    Mount an ISO9960 filesystem

    # mount -t iso9960 -o ro /dev/cdrom /mnt/cdrom
    # mount -t iso9660 -o loop,ro /tmp/image.iso /mnt/cdrom 

    The second command example assumes that loop devices are supported by the kernel.

  • UDF
    Kernel support for Universal Disk Format

    Is a newer file system for CD and DVD. If not done already, configure kernel to provide udf support.

    1. Select packet support in the block device section
    2. Select UDF support in the filesystem section
    3. Recompile kernel

    'cdrwtool' and 'pktsetup', part of the udftools package, can perform certain actions on a CD-R, CD-RW or DVD-R device. Primarily blanking the media, formating it for use with the packet-cd device and applying a UDF filesystem.

    Format the CD-RW disc - blank disc inserted in drive

    # cdrwtool -d /dev/cdrw -q

    Verify that /dev/pktcdvd0 exists - if not, create it

    # mknod /dev/pktcdvd0 b 97 0

    Set up writer, mount and copy files to it

    # pktsetup /dev/pktcdvd0 /dev/cdrw
    # mount /dev/pktcdvd0
  • Command line CD and DVD recording

    '/usr/bin/cdrecord' and '/usr/bin/dvdrecord' are links to 'wodim'.

    # file `which cdrecord`
    /usr/bin/cdrecord: symbolic link to `/etc/alternatives/cdrecord'
    # file `which /etc/alternatives/cdrecord`
    /etc/alternatives/cdrecord: symbolic link to `/usr/bin/wodim'
    # file `which dvdrecord`
    /usr/bin/dvdrecord: symbolic link to `/etc/alternatives/cdrecord-dvdrecord'
    # file `which /etc/alternatives/cdrecord-dvdrecord`
    /etc/alternatives/cdrecord-dvdrecord: symbolic link to `/usr/bin/wodim'

    Recording examples follow. First you need to know what devices you have, their names and address.

    Determine device address of your CD/DVDs

    $ cdrecord -scanbus                                          (for symbolic scsi addresses)
      1,0,0  100) 'TEAC   ' 'CD-532E    ' '3.0A' Removable CD-ROM
      1,1,0  101) 'CD-RW  ' 'CDR-7S52   ' 'QSGE' Removable CD-ROM
      2,0,0  200) 'FREECOM_' 'DVD+/-RW20J5 ' 'QF51' Removable CD-ROM
    $ wodim -scanbus                                             (Same command as 'cdrecord -scanbus')

    Get device names for your CD/DVDs

    $ wodim --devices                                            (For device names)
    wodim: Overview of accessible drives (3 found) :
     0  dev='/dev/scd0' rwrw-- : 'TEAC' 'CD-532E'
     1  dev='/dev/scd1' rwrw-- : 'CD-RW' 'CDR-7S52'
     2  dev='/dev/scd2' rwrw-- : 'FREECOM_' 'DVD+/-RW20J5'
    $ cdrecord --devices                                         (Same command as 'wodim --devices')
    wodim: Overview of accessible drives (3 found) :
    $ ls -al /dev/dvdrw2
    lrwxrwxrwx 1 root root 4 2009-05-10 18:47 /dev/dvdrw2 -> scd2

    Record a pure CD-ROM at double speed, using data from the file cdimage.raw

    # wodim -v speed=2 dev=/dev/scd2 cdimage.raw
    # wodim -v speed=2 dev=2,0,0 cdimage.raw

    Create an image for a ISO 9660 filesystem with Rock Ridge extensions

    # genisoimage -R -o cdimage.raw /tmp/cd-image

    Check the resulting file before writing to CD

    # mount cdimage.raw -r -t iso9660 -o loop /mnt
    # ls -lR /mnt
    # umount /mnt

    Test burn a cd iso image

    # cdrecord -v -dummy driveropts=burnfree dev=2,0,0 /tmp/image.iso
    /* options used
     * -v                       verbose
     * -dummy                   dummy run, do not burn. Useful to check for under-runs with '-v'
     * driveropts=burnfree      enable burning mode that tolerates underruns
     * speed=speed              often auto-detected
     * dev=device               cdrw

    Burn an iso image to cd and verify the burn process

    # cdrecord driveropts=burnfree dev=2,0,0 /tmp/image.iso
    # cmp /dev/cdrom /tmp/image.iso

    Copy a cd image to disk ready to burn to another cd

    # dd bs=2k if=/dev/cdrom of=/tmp/cd-image.iso
  • Loop devices

    A loop device, vnd (vnode disk) or lofi (loopback file interface) is a pseudo-device that makes a file accessible as a block device. Before use, a loop device must be connected to an existing file in the filesystem.

    # ls -al /dev/loop*
    brw-r----- 1 root disk 7, 0 2007-12-29 21:09 /dev/loop0
    brw-r----- 1 root disk 7, 1 2007-12-29 21:09 /dev/loop1

    Set up and control loop devices - /sbin/losetup

    losetup <loop_device>            Get info on given loop device
    losetup -a                       Get info on all loop devices
    losetup -d <loop_device>         Delete loop device
    losetup -f                       Print name of first unused loop device
    losetup [{-e|-E} encryption]     Setup loop device
            [-o offset] [-p pfd]
            [-r]{-f[-s]|loop_device} file

    Setting up an encrypted filesytem on a loop back device

    (1) - Create an image file - /tmp/file (100kb)

    $ dd if=/dev/zero of=/tmp/file bs=1k count=100
    100+0 records in
    100+0 records out
    102400 bytes (102 kB) copied, 0.000887941 s, 115 MB/s

    Create a loop back device using an encrypted image

    $ sudo losetup -e aes-128 /dev/loop0 /tmp/file
    [sudo] password for mark:

    If you get any of the errors below - not likely as this was a while back ...

    ioctl: LOOP_SET_STATUS: Invalid argument, requested cipher or key \
    length (128 bits) not supported by kernel
    ioctl: LOOP_SET_STATUS: Invalid argument
    ioctl: LOOP_SET_STATUS: No such file or directory

    then it is down to

    • unpatched version of util-linux (fixed by installing loop-aes-utils)
    • or one or more modules (loop, aes, cryptoloop) not loaded
    • or kernel not configured for aes/encryption
    • or any combination of the above
    ## On Ubuntu 8.04 - installed the following to remedy.
    $ sudo aptitude install loop-aes-utils (ubuntu 8.04 2.6.24-24)
    $ sudo modprobe loop
    $ sudo modprobe aes
    $ sudo modprobe cryptoloop

    Create a filesystem on the device, mount and use

    $ sudo mkfs -t ext2 /dev/loop0 100
    $ sudo mount -t ext2 /dev/loop0 /mnt

    Undo, remove everything

    $ sudo umount /dev/loop0
    $ sudo losetup -d /dev/loop0
    $ sudo modprobe -r loop aes cryptoloop