diff --git a/ChangeLog b/ChangeLog
index 99b3df08f56a129bbd4e3b62e989c63a24c1992b..04d47cfc1b6fe8c3ca1c8493ab0ec70b04926294 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -553,4 +553,5 @@
 	* Added a block to character (BCH) driver.  This is kind of the reverse of the loop
 	  device; it allows you access a block device like a character device.
 	* Added strcasecmp() and strncasecmp()
-	* NSH: Added 'dd' command
+	* NSH: Added the 'dd' command
+	* NSH: Added the 'losetup' command
diff --git a/Documentation/NuttShell.html b/Documentation/NuttShell.html
index 9418056eb9eddeb8c619ec8d6b5040bf2adce142..c873c79b95fafbc90a8f7ed69b9977bfc1a4380c 100644
--- a/Documentation/NuttShell.html
+++ b/Documentation/NuttShell.html
@@ -1,6 +1,6 @@
 <html>
 <head>
-<title>NuttX</title>
+<title>NuttShell</title>
 </head>
 <body background="backgd.gif">
 <hr><hr>
@@ -149,127 +149,133 @@
 <tr>
   <td><br></td>
   <td>
-    <a href="#cmdls">2.12 List Directory Contents (ls)</a>
+    <a href="#cmdlosetup">2.12 Setup/teardown the Loop Device (losetup)</a>
   </td>
 </tr>
 <tr>
   <td><br></td>
   <td>
-    <a href="#cmdmbhw">2.13 Access Memory (mb, mh, and mw)</a>
+    <a href="#cmdls">2.13 List Directory Contents (ls)</a>
   </td>
 </tr>
 <tr>
   <td><br></td>
   <td>
-    <a href="#cmdmem">2.14 Show Memory Manager Status (mem)</a>
+    <a href="#cmdmbhw">2.14 Access Memory (mb, mh, and mw)</a>
   </td>
 </tr>
 <tr>
   <td><br></td>
   <td>
-    <a href="#cmdps">2.15 Show Current Tasks and Threads (ps)</a>
+    <a href="#cmdmem">2.15 Show Memory Manager Status (mem)</a>
   </td>
 </tr>
 <tr>
   <td><br></td>
   <td>
-    <a href="#cmdmkdir">2.16 Create a Directory (mkdir)</a>
+    <a href="#cmdps">2.16 Show Current Tasks and Threads (ps)</a>
   </td>
 </tr>
 <tr>
   <td><br></td>
   <td>
-    <a href="#cmdmkfatfs">2.17 Create a FAT Filesystem (mkfatfs)</a>
+    <a href="#cmdmkdir">2.17 Create a Directory (mkdir)</a>
   </td>
 </tr>
 <tr>
   <td><br></td>
   <td>
-    <a href="#cmdmkfifo">2.18 Create a FIFO (mkfifo)</a>
+    <a href="#cmdmkfatfs">2.18 Create a FAT Filesystem (mkfatfs)</a>
   </td>
 </tr>
 <tr>
   <td><br></td>
   <td>
-    <a href="#cmdmkrd">2.19 Create a RAMDISK (mkrd)</a>
+    <a href="#cmdmkfifo">2.19 Create a FIFO (mkfifo)</a>
   </td>
 </tr>
 <tr>
   <td><br></td>
   <td>
-    <a href="#cmdmount">2.20 Mount a File System (mount)</a>
+    <a href="#cmdmkrd">2.20 Create a RAMDISK (mkrd)</a>
   </td>
 </tr>
 <tr>
   <td><br></td>
   <td>
-    <a href="#cmdping">2.21 Check Network Peer (ping)</a>
+    <a href="#cmdmount">2.21 Mount a File System (mount)</a>
   </td>
 </tr>
 <tr>
   <td><br></td>
   <td>
-    <a href="#cmdput">2.22 Send File Via TFTP (put)</a>
+    <a href="#cmdping">2.22 Check Network Peer (ping)</a>
   </td>
 </tr>
 <tr>
   <td><br></td>
   <td>
-    <a href="#cmdpwd">2.23 Show Current Working Directory (pwd)</a>
+    <a href="#cmdput">2.23 Send File Via TFTP (put)</a>
   </td>
 </tr>
 <tr>
   <td><br></td>
   <td>
-    <a href="#cmdrm">2.24 Remove a File (rm)</a>
+    <a href="#cmdpwd">2.24 Show Current Working Directory (pwd)</a>
   </td>
 </tr>
 <tr>
   <td><br></td>
   <td>
-    <a href="#cmdrmdir">2.25 Remove a Directory (rmdir)</a>
+    <a href="#cmdrm">2.25 Remove a File (rm)</a>
   </td>
 </tr>
 <tr>
   <td><br></td>
   <td>
-    <a href="#cmdset">2.26 Set an Environment Variable (set)</a>
+    <a href="#cmdrmdir">2.26 Remove a Directory (rmdir)</a>
   </td>
 </tr>
 <tr>
   <td><br></td>
   <td>
-    <a href="#cmdsh">2.27 Execute an NSH Script (sh)</a>
+    <a href="#cmdset">2.27 Set an Environment Variable (set)</a>
   </td>
 </tr>
 <tr>
   <td><br></td>
   <td>
-    <a href="#cmdsleep">2.28 Wait for Seconds (sleep)</a>
+    <a href="#cmdsh">2.28 Execute an NSH Script (sh)</a>
   </td>
 </tr>
 <tr>
   <td><br></td>
   <td>
-    <a href="#cmdunmount">2.29 Unmount a File System (umount)</a>
+    <a href="#cmdsleep">2.29 Wait for Seconds (sleep)</a>
   </td>
 </tr>
 <tr>
   <td><br></td>
   <td>
-    <a href="#cmdunset">2.30 Unset an Environment Variable (unset)</a>
+    <a href="#cmdunmount">2.30 Unmount a File System (umount)</a>
   </td>
 </tr>
 <tr>
   <td><br></td>
   <td>
-    <a href="#cmdusleep">2.31 Wait for Microseconds (usleep)</a>
+    <a href="#cmdunset">2.31 Unset an Environment Variable (unset)</a>
   </td>
 </tr>
 <tr>
   <td><br></td>
   <td>
-    <a href="#cmdxd">2.32 Hexadecimal Dump (xd)</a>
+    <a href="#cmdusleep">2.32 Wait for Microseconds (usleep)</a>
+  </td>
+</tr>
+<tr>
+  <td><br></td>
+  <td>
+    <a href="#cmdxd">2.33 Hexadecimal Dump (xd)</a>
   </td>
 </tr>
 <tr>
@@ -936,7 +942,33 @@ eth0    HWaddr 00:18:11:80:10:06
 <table width ="100%">
   <tr bgcolor="#e4e4e4">
   <td>
-    <a name="cmdls"><h2>2.12 List Directory Contents (ls)</h2></a>
+    <a name="cmdlosetup"><h2>2.12 Setup/teardown the Loop Device (losetup)</h2></a>
+  </td>
+  </tr>
+</table>
+
+<a <p><b>Command Syntax 1:</b></p>
+<ul><pre>
+losetup [-o <offset>] [-r] &lt;dev-path&gt; &lt;file-path&gt;
+</pre></ul>
+<p>
+  <b>Synopsis</b>.
+   Setup the loop device at &lt;dev-path&gt; to access the file at &lt;file-path&gt; as a block device:
+</p>
+
+<a <p><b>Command Syntax 2:</b></p>
+<ul><pre>
+losetup d &lt;dev-path&gt;
+</pre></ul>
+<p>
+  <b>Synopsis</b>.
+  Teardown the setup for the loop device at &lt;dev-path&gt;.
+</p>
+
+<table width ="100%">
+  <tr bgcolor="#e4e4e4">
+  <td>
+    <a name="cmdls"><h2>2.13 List Directory Contents (ls)</h2></a>
   </td>
   </tr>
 </table>
@@ -973,7 +1005,7 @@ ls [-lRs] &lt;dir-path&gt;
 <table width ="100%">
   <tr bgcolor="#e4e4e4">
   <td>
-    <a name="cmdmbhw"><h2>2.13 Access Memory (mb, mh, and mw)</h2></a>
+    <a name="cmdmbhw"><h2>2.14 Access Memory (mb, mh, and mw)</h2></a>
   </td>
   </tr>
 </table>
@@ -1027,7 +1059,7 @@ nsh&gt;
 <table width ="100%">
   <tr bgcolor="#e4e4e4">
   <td>
-    <a name="cmdmem"><h2>2.14 Show Memory Manager Status (mem)</h2></a>
+    <a name="cmdmem"><h2>2.15 Show Memory Manager Status (mem)</h2></a>
   </td>
   </tr>
 </table>
@@ -1076,7 +1108,7 @@ nsh&gt;
 <table width ="100%">
   <tr bgcolor="#e4e4e4">
   <td>
-    <a name="cmdps"><h2>2.15 Show Current Tasks and Threads (ps)</h2></a>
+    <a name="cmdps"><h2>2.16 Show Current Tasks and Threads (ps)</h2></a>
   </td>
   </tr>
 </table>
@@ -1102,7 +1134,7 @@ nsh&gt;
 <table width ="100%">
   <tr bgcolor="#e4e4e4">
   <td>
-    <a name="cmdmkdir"><h2>2.16 Create a Directory (mkdir)</h2></a>
+    <a name="cmdmkdir"><h2>2.17 Create a Directory (mkdir)</h2></a>
   </td>
 </tr>
 </table>
@@ -1137,7 +1169,7 @@ nsh>
 <table width ="100%">
   <tr bgcolor="#e4e4e4">
   <td>
-    <a name="cmdmkfatfs"><h2>2.17 Create a FAT Filesystem (mkfatfs)</h2></a>
+    <a name="cmdmkfatfs"><h2>2.18 Create a FAT Filesystem (mkfatfs)</h2></a>
   </td>
 </tr>
 </table>
@@ -1157,7 +1189,7 @@ mkfatfs &lt;path&gt;
 <table width ="100%">
   <tr bgcolor="#e4e4e4">
   <td>
-    <a name="cmdmkfifo"><h2>2.18 Create a FIFO (mkfifo)</h2></a>
+    <a name="cmdmkfifo"><h2>2.19 Create a FIFO (mkfifo)</h2></a>
   </td>
 </tr>
 </table>
@@ -1195,7 +1227,7 @@ nsh>
 <table width ="100%">
   <tr bgcolor="#e4e4e4">
   <td>
-    <a name="cmdmkrd"><h2>2.19 Create a RAMDISK (mkrd)</h2></a>
+    <a name="cmdmkrd"><h2>2.20 Create a RAMDISK (mkrd)</h2></a>
   </td>
 </tr>
 </table>
@@ -1246,7 +1278,7 @@ nsh&gt;
 <table width ="100%">
   <tr bgcolor="#e4e4e4">
   <td>
-    <a name="cmdmount"><h2>2.20 Mount a File System (mount)</h2></a>
+    <a name="cmdmount"><h2>2.21 Mount a File System (mount)</h2></a>
   </td>
 </tr>
 </table>
@@ -1313,7 +1345,7 @@ nsh>
 <table width ="100%">
   <tr bgcolor="#e4e4e4">
   <td>
-    <a name="cmdping"><h2>2.21 Check Network Peer (ping)</h2></a>
+    <a name="cmdping"><h2>2.22 Check Network Peer (ping)</h2></a>
   </td>
   </tr>
 </table>
@@ -1346,7 +1378,7 @@ nsh&gt;
 <table width ="100%">
   <tr bgcolor="#e4e4e4">
   <td>
-    <a name="cmdput"><h2>2.22 Send File Via TFTP (put)</h2></a>
+    <a name="cmdput"><h2>2.23 Send File Via TFTP (put)</h2></a>
   </td>
   </tr>
 </table>
@@ -1381,7 +1413,7 @@ put [-b|-n] [-f &lt;remote-path&gt;] -h &lt;ip-address&gt; &lt;local-path&gt;
 <table width ="100%">
   <tr bgcolor="#e4e4e4">
   <td>
-    <a name="cmdpwd"><h2>2.23 Show Current Working Directory (pwd)</h2></a>
+    <a name="cmdpwd"><h2>2.24 Show Current Working Directory (pwd)</h2></a>
   </td>
   </tr>
 </table>
@@ -1411,7 +1443,7 @@ nsh&gt;
 <table width ="100%">
   <tr bgcolor="#e4e4e4">
   <td>
-    <a name="cmdrm"><h2>2.24 Remove a File (rm)</h2></a>
+    <a name="cmdrm"><h2>2.25 Remove a File (rm)</h2></a>
   </td>
 </tr>
 </table>
@@ -1445,7 +1477,7 @@ nsh>
 <table width ="100%">
   <tr bgcolor="#e4e4e4">
   <td>
-    <a name="cmdrmdir"><h2>2.25 Remove a Directory (rmdir)</h2></a>
+    <a name="cmdrmdir"><h2>2.26 Remove a Directory (rmdir)</h2></a>
   </td>
 </tr>
 </table>
@@ -1480,7 +1512,7 @@ nsh>
 <table width ="100%">
   <tr bgcolor="#e4e4e4">
   <td>
-    <a name="cmdset"><h2>2.26 Set an Environment Variable (set)</h2></a>
+    <a name="cmdset"><h2>2.27 Set an Environment Variable (set)</h2></a>
   </td>
   </tr>
 </table>
@@ -1506,7 +1538,7 @@ nsh&gt;
 <table width ="100%">
   <tr bgcolor="#e4e4e4">
   <td>
-    <a name="cmdsh"><h2>2.27 Execute an NSH Script (sh)</h2></a>
+    <a name="cmdsh"><h2>2.28 Execute an NSH Script (sh)</h2></a>
   </td>
   </tr>
 </table>
@@ -1524,7 +1556,7 @@ sh &lt;script-path&gt;
 <table width ="100%">
   <tr bgcolor="#e4e4e4">
   <td>
-    <a name="cmdsleep"><h2>2.28 Wait for Seconds (sleep)</h2></a>
+    <a name="cmdsleep"><h2>2.29 Wait for Seconds (sleep)</h2></a>
   </td>
   </tr>
 </table>
@@ -1541,7 +1573,7 @@ sleep &lt;sec&gt;
 <table width ="100%">
   <tr bgcolor="#e4e4e4">
   <td>
-    <a name="cmdunmount"><h2>2.29 Unmount a File System (umount)</h2></a>
+    <a name="cmdunmount"><h2>2.30 Unmount a File System (umount)</h2></a>
   </td>
 </tr>
 </table>
@@ -1571,7 +1603,7 @@ nsh>
 <table width ="100%">
   <tr bgcolor="#e4e4e4">
   <td>
-    <a name="cmdunset"><h2>2.30 Unset an Environment Variable (unset)</h2></a>
+    <a name="cmdunset"><h2>2.31 Unset an Environment Variable (unset)</h2></a>
   </td>
   </tr>
 </table>
@@ -1597,7 +1629,7 @@ nsh&gt;
 <table width ="100%">
   <tr bgcolor="#e4e4e4">
   <td>
-    <a name="cmdusleep"><h2>2.31 Wait for Microseconds (usleep)</h2></a>
+    <a name="cmdusleep"><h2>2.32 Wait for Microseconds (usleep)</h2></a>
   </td>
   </tr>
 </table>
@@ -1614,7 +1646,7 @@ usleep &lt;usec&gt;
 <table width ="100%">
   <tr bgcolor="#e4e4e4">
   <td>
-    <a name="cmdxd"><h2>2.32 Hexadecimal dump (xd)</h2></a>
+    <a name="cmdxd"><h2>2.33 Hexadecimal dump (xd)</h2></a>
   </td>
   </tr>
 </table>
@@ -1733,6 +1765,11 @@ nsh>
     <td><code>CONFIG_NET</code></td>
     <td><code>CONFIG_EXAMPLES_NSH_DISABLE_IFCONFIG</code></td>
   </tr>
+  <tr>
+    <td><b><code>losetup</code></b></td>
+    <td>!<code>CONFIG_DISABLE_MOUNTPOINT</code> &amp;&amp; <code>CONFIG_NFILE_DESCRIPTORS</code> &gt; 0</td>
+    <td><code>CONFIG_EXAMPLES_NSH_DISABLE_LOSETUP</code></td>
+  </tr>
   <tr>
     <td><b><code>ls</code></b></td>
     <td><code>CONFIG_NFILE_DESCRIPTORS</code> &gt; 0</td>
@@ -2159,6 +2196,7 @@ nsh>
   <li><a href="#cmdhelp"><code>help</code></a></li>
   <li><a href="#conditional"><code>if-then[-else]-fi</code></a></li>
   <li><a href="#cmdifconfig"><code>ifconfig</code></a></li>
+  <li><a href="#cmdlosetup"><code>losetup</code></a></li>
   <li><a href="#cmdls">ls</code></a></li>
   <li><a href="#cmdmbhw"><code>mb</code></a></li>
   <li><a href="#cmdmbhw"><code>mh</code></a></li>
diff --git a/Documentation/NuttX.html b/Documentation/NuttX.html
index a26f2e55e8c9b08bef297e3d4944629ea207525d..6bb9c58c3d683086e8079b064cf58f2c610b6979 100644
--- a/Documentation/NuttX.html
+++ b/Documentation/NuttX.html
@@ -1195,7 +1195,8 @@ nuttx-0.3.18 2008-xx-xx Gregory Nutt &lt;spudmonkey@racsa.co.cr&gt;
           into very small memory footprints.
 	* Added a block to character (BCH) driver.  This is kind of the reverse of the loop
 	  device; it allows you access a block device like a character device.
-	* NSH: Added 'dd' command
+	* NSH: Added the 'dd' command
+	* NSH: Added the 'losetup' command
 
 pascal-0.1.3 2008-xx-xx Gregory Nutt &lt;spudmonkey@racsa.co.cr&gt;
 
diff --git a/examples/nsh/README.txt b/examples/nsh/README.txt
index 9ea0464099371de9540576469c19f2399013a910..a34b03da971fc632006fe54e583bf0fb94ff28d4 100644
--- a/examples/nsh/README.txt
+++ b/examples/nsh/README.txt
@@ -328,6 +328,19 @@ o ifconfig
   if uIP statistics are enabled (CONFIG_NET_STATISTICS), then
   this command will also show the detailed state of uIP.
 
+o losetup [-d <dev-path>] | [[-o <offset>] [-r] <ldev-path> <file-path>]
+
+  Setup or teardown the loop device:
+
+  1. Teardown the setup for the loop device at <dev-path>:
+
+    losetup d <dev-path>
+
+  2. Setup the loop device at <dev-path> to access the file at <file-path>
+     as a block device:
+
+    losetup [-o <offset>] [-r] <dev-path> <file-path>
+
 o ls [-lRs] <dir-path>
 
   Show the contents of the directory at <dir-path>.  NOTE:
@@ -721,6 +734,7 @@ Command Dependencies on Configuration Settings
   get        CONFIG_NET && CONFIG_NET_UDP && CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NET_BUFSIZE >= 558  (see note 1)
   help       --
   ifconfig   CONFIG_NET
+  losetup    !CONFIG_DISABLE_MOUNTPOINT && CONFIG_NFILE_DESCRIPTORS > 0
   ls         CONFIG_NFILE_DESCRIPTORS > 0
   mb,mh,mw   ---
   mem        ---
@@ -762,15 +776,15 @@ also allow it to squeeze into very small memory footprints.
   CONFIG_EXAMPLES_NSH_DISABLE_CAT,      CONFIG_EXAMPLES_NSH_DISABLE_CD,      CONFIG_EXAMPLES_NSH_DISABLE_CP,
   CONFIG_EXAMPLES_NSH_DISABLE_DD,       CONFIG_EXAMPLES_NSH_DISABLE_ECHO,    CONFIG_EXAMPLES_NSH_DISABLE_EXEC,
   CONFIG_EXAMPLES_NSH_DISABLE_EXIT,     CONFIG_EXAMPLES_NSH_DISABLE_GET,     CONFIG_EXAMPLES_NSH_DISABLE_HELP,
-  CONFIG_EXAMPLES_NSH_DISABLE_IFCONFIG, CONFIG_EXAMPLES_NSH_DISABLE_LS,      CONFIG_EXAMPLES_NSH_DISABLE_MB,
-  CONFIG_EXAMPLES_NSH_DISABLE_MEM,      CONFIG_EXAMPLES_NSH_DISABLE_MKDIR,   CONFIG_EXAMPLES_NSH_DISABLE_MKFATFS,
-  CONFIG_EXAMPLES_NSH_DISABLE_MKFIFO,   CONFIG_EXAMPLES_NSH_DISABLE_MKRD,    CONFIG_EXAMPLES_NSH_DISABLE_MH,
-  CONFIG_EXAMPLES_NSH_DISABLE_MOUNT,    CONFIG_EXAMPLES_NSH_DISABLE_MW,      CONFIG_EXAMPLES_NSH_DISABLE_PS,
-  CONFIG_EXAMPLES_NSH_DISABLE_PING,     CONFIG_EXAMPLES_NSH_DISABLE_PUT,     CONFIG_EXAMPLES_NSH_DISABLE_PWD,
-  CONFIG_EXAMPLES_NSH_DISABLE_RM,       CONFIG_EXAMPLES_NSH_DISABLE_RMDIR,   CONFIG_EXAMPLES_NSH_DISABLE_SET,
-  CONFIG_EXAMPLES_NSH_DISABLE_SH,       CONFIG_EXAMPLES_NSH_DISABLE_SLEEP,   CONFIG_EXAMPLES_NSH_DISABLE_TEST,
-  CONFIG_EXAMPLES_NSH_DISABLE_UMOUNT,   CONFIG_EXAMPLES_NSH_DISABLE_UNSET,   CONFIG_EXAMPLES_NSH_DISABLE_USLEEP,
-  CONFIG_EXAMPLES_NSH_DISABLE_XD
+  CONFIG_EXAMPLES_NSH_DISABLE_IFCONFIG, CONFIG_EXAMPLES_NSH_DISABLE_LOSETUP, CONFIG_EXAMPLES_NSH_DISABLE_LS,
+  CONFIG_EXAMPLES_NSH_DISABLE_MB,       CONFIG_EXAMPLES_NSH_DISABLE_MEM,     CONFIG_EXAMPLES_NSH_DISABLE_MKDIR,
+  CONFIG_EXAMPLES_NSH_DISABLE_MKFATFS,  CONFIG_EXAMPLES_NSH_DISABLE_MKFIFO,  CONFIG_EXAMPLES_NSH_DISABLE_MKRD,
+  CONFIG_EXAMPLES_NSH_DISABLE_MH,       CONFIG_EXAMPLES_NSH_DISABLE_MOUNT,   CONFIG_EXAMPLES_NSH_DISABLE_MW,
+  CONFIG_EXAMPLES_NSH_DISABLE_PS,       CONFIG_EXAMPLES_NSH_DISABLE_PING,    CONFIG_EXAMPLES_NSH_DISABLE_PUT,
+  CONFIG_EXAMPLES_NSH_DISABLE_PWD,      CONFIG_EXAMPLES_NSH_DISABLE_RM,      CONFIG_EXAMPLES_NSH_DISABLE_RMDIR,
+  CONFIG_EXAMPLES_NSH_DISABLE_SET,      CONFIG_EXAMPLES_NSH_DISABLE_SH,      CONFIG_EXAMPLES_NSH_DISABLE_SLEEP,
+  CONFIG_EXAMPLES_NSH_DISABLE_TEST,     CONFIG_EXAMPLES_NSH_DISABLE_UMOUNT,  CONFIG_EXAMPLES_NSH_DISABLE_UNSET,
+  CONFIG_EXAMPLES_NSH_DISABLE_USLEEP,   CONFIG_EXAMPLES_NSH_DISABLE_XD
 
 NSH-Specific Configuration Settings
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/examples/nsh/nsh.h b/examples/nsh/nsh.h
index 825ea6554ffb656deb0ed8b708130cea6a703ae6..32a0c934d598707b68e1d4985519400474b30415 100644
--- a/examples/nsh/nsh.h
+++ b/examples/nsh/nsh.h
@@ -378,6 +378,9 @@ extern int cmd_lbracket(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
 #   endif
 # endif  /* CONFIG_NFILE_STREAMS && !CONFIG_EXAMPLES_NSH_DISABLESCRIPT */
 # ifndef CONFIG_DISABLE_MOUNTPOINT
+#   ifndef CONFIG_EXAMPLES_NSH_DISABLE_LOSETUP
+      extern int cmd_losetup(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
+#   endif
 #   ifndef CONFIG_EXAMPLES_NSH_DISABLE_MKFIFO
       extern int cmd_mkfifo(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
 #   endif
diff --git a/examples/nsh/nsh_fscmds.c b/examples/nsh/nsh_fscmds.c
index 8dcf90372170f03707bbec57fc5ac12b3a9e992b..301abddbb1cee014745621621235263bf3ce9a37 100644
--- a/examples/nsh/nsh_fscmds.c
+++ b/examples/nsh/nsh_fscmds.c
@@ -647,6 +647,128 @@ errout:
 #endif
 #endif
 
+/****************************************************************************
+ * Name: cmd_losetup
+ ****************************************************************************/
+
+#if CONFIG_NFILE_DESCRIPTORS > 0 && !defined(CONFIG_DISABLE_MOUNTPOINT)
+#ifndef CONFIG_EXAMPLES_NSH_DISABLE_LOSETUP
+int cmd_losetup(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
+{
+  char   *loopdev  = NULL;
+  char   *filepath = NULL;
+  boolean teardown = FALSE;
+  boolean readonly = FALSE;
+  off_t   offset   = 0;
+  int     ret      = ERROR;
+  int     option;
+
+  /* Get the losetup options:  Two forms are supported:
+   *
+   *   losetup -d <loop-device>
+   *   losetup [-o <offset>] [-r] <loop-device> <filename>
+   *
+   * NOTE that the -o and -r options are accepted with the -d option, but
+   * will be ignored.
+   */
+
+  while ((option = getopt(argc, argv, "d:o:r")) != ERROR)
+    {
+      switch (option)
+        {
+        case 'd':
+          loopdev  = nsh_getfullpath(vtbl, optarg);
+          teardown = TRUE;
+          break;
+
+        case 'o':
+          offset = atoi(optarg);
+          break;
+
+        case 'r':
+          readonly = TRUE;
+          break;
+
+        case '?':
+        default:
+          nsh_output(vtbl, g_fmtarginvalid, argv[0]);
+          return ERROR;
+        }
+    }
+
+  /* If this is not a tear down operation, then additional command line
+   * parameters are required.
+   */
+
+  if (!teardown)
+    {
+      /* There must be two arguments on the command line after the options */
+
+      if (optind + 1 < argc)
+        {
+          loopdev = nsh_getfullpath(vtbl, argv[optind]);
+          optind++;
+
+          filepath = nsh_getfullpath(vtbl, argv[optind]);
+          optind++;
+        }
+      else
+        {
+          nsh_output(vtbl, g_fmtargrequired, argv[0]);
+          goto errout_with_paths;
+        }
+    }
+
+  /* There should be nothing else on the command line */
+
+  if (optind < argc)
+   {
+     nsh_output(vtbl, g_fmttoomanyargs, argv[0]);
+     goto errout_with_paths;
+   }
+
+  /* Perform the teardown operation */
+
+  if (teardown)
+    {
+      /* Tear down the loop device. */
+
+      ret = loteardown(loopdev);
+      if (ret < 0)
+        {
+          nsh_output(vtbl, g_fmtcmdfailed, argv[0], "loteardown", NSH_ERRNO_OF(-ret));
+          goto errout_with_paths;
+        }
+    }
+  else
+    {
+      /* Set up the loop device */
+
+      ret = losetup(loopdev, filepath, 512, offset, readonly);
+      if (ret < 0)
+        {
+          nsh_output(vtbl, g_fmtcmdfailed, argv[0], "losetup", NSH_ERRNO_OF(-ret));
+          goto errout_with_paths;
+        }
+    }
+
+  /* Free memory */
+
+errout_with_paths:
+  if (loopdev)
+    {
+      free(loopdev);
+    }
+
+  if (filepath)
+    {
+      free(filepath);
+    }
+  return ret;
+}
+#endif
+#endif
+
 /****************************************************************************
  * Name: cmd_ls
  ****************************************************************************/
diff --git a/examples/nsh/nsh_main.c b/examples/nsh/nsh_main.c
index 14b1afb55bdb8691cf39251fab714f585469b495..db116b5c05589eb2878d0c5671bbafef77f164b9 100644
--- a/examples/nsh/nsh_main.c
+++ b/examples/nsh/nsh_main.c
@@ -188,6 +188,12 @@ static const struct cmdmap_s g_cmdmap[] =
 # endif
 #endif
 
+#if CONFIG_NFILE_DESCRIPTORS > 0 && !defined(CONFIG_DISABLE_MOUNTPOINT)
+# ifndef CONFIG_EXAMPLES_NSH_DISABLE_LOSETUP
+  { "losetup",   cmd_losetup, 3, 6, "[-d <dev-path>] | [[-o <offset>] [-r] <dev-path> <file-path>]" },
+# endif
+#endif
+
 #if CONFIG_NFILE_DESCRIPTORS > 0
 # ifndef CONFIG_EXAMPLES_NSH_DISABLE_LS
   { "ls",       cmd_ls,       1, 5, "[-lRs] <dir-path>" },