{"id":115,"date":"2010-08-24T23:34:09","date_gmt":"2010-08-25T03:34:09","guid":{"rendered":"http:\/\/hackspot.net\/iSpotBlog\/?p=115"},"modified":"2010-08-24T23:34:09","modified_gmt":"2010-08-25T03:34:09","slug":"backing-up-the-flash-memory-on-your-ispot-to-your-pc","status":"publish","type":"post","link":"http:\/\/hackspot.net\/iSpotBlog\/?p=115","title":{"rendered":"Backing up the flash memory on your iSpot to your PC"},"content":{"rendered":"<p>In case of future corruption of the flash memory chip on your iSpot (especially if you are &#8216;hacking&#8217; your device), it&#8217;s a good idea to make a backup of the contents.\u00a0 Hopefully, having this backup will make it possible to recover from &#8216;bricking&#8217;\/etc in the future.<\/p>\n<p>There are 10 &#8216;partitions&#8217; on the flash memory chip in the iSpot (at least on my device).\u00a0 You can get a list of the partitions by dumping the contents of the file &#8220;\/proc\/mtd&#8221;:<\/p>\n<pre># cat \/proc\/mtd\r\ndev:    size   erasesize  name\r\nmtd0: 00040000 00020000 \"RedBoot\"\r\nmtd1: 00020000 00020000 \"param\"\r\nmtd2: 00120000 00020000 \"linux\"\r\nmtd3: 00600000 00020000 \"rootfs\"\r\nmtd4: 00100000 00020000 \"system\"\r\nmtd5: 00120000 00020000 \"linux_2\"\r\nmtd6: 00600000 00020000 \"rootfs_2\"\r\nmtd7: 00020000 00020000 \"ver_1\"\r\nmtd8: 00020000 00020000 \"ver_2\"\r\nmtd9: 0001f000 00020000 \"FIS directory\"\r\nmtd10: 00001000 00020000 \"RedBoot config\"<\/pre>\n<p>Each of the partitions has a pair of corresponding &#8220;device files&#8221; in &#8220;\/dev&#8221; (one &#8216;character&#8217; device, one &#8216;block&#8217; device). For example, for &#8220;mtd0&#8221; you&#8217;ll find &#8220;\/dev\/mtd0&#8221; and &#8220;\/dev\/mtdblock0&#8221; files.<\/p>\n<p>NOTE: Actually, &#8220;mtd10&#8221; doesn&#8217;t seem to have these device\u00a0files by default. If you&#8217;d like to be able to access &#8220;mtd10&#8221; like other partitions, then type the following commands to create them:<\/p>\n<pre>mknod \/dev\/mtd10 c 90 20\r\nmknod \/dev\/mtdblock10 b 31 10<\/pre>\n<p>To &#8216;back up&#8217; a partition, use the &#8220;dd&#8221; command to dump the contents of the &#8216;character&#8217; device file (&#8220;\/dev\/mtd0&#8221;, for example):<\/p>\n<pre>dd if=\/dev\/mtd0 of=\/tmp\/mtd0_backup.bin<\/pre>\n<p><em>Be careful about the &#8220;<strong>if=<\/strong>&#8221; (input file) and &#8220;<strong>of=<\/strong>&#8221; (output file) arguments &#8211; don&#8217;t mix them up!<\/em><\/p>\n<p>Execute the &#8220;dd&#8221; command on each of the 10 partitions in order to have a complete backup.<\/p>\n<p>The above\u00a0example leaves the backup binary file in &#8220;\/tmp&#8221;.\u00a0 I&#8217;ve found that backing up to &#8220;\/var\/wwwroot&#8221; instead makes it easy to get the files off of the iSpot (and on to your PC).\u00a0 &#8220;\/var\/wwwroot&#8221; points to the root of the iSpot&#8217;s web server, so you can download the backup file by downloading <a href=\"http:\/\/192.168.1.1\/mtd0_backup.bin\">http:\/\/192.168.1.1\/mtd0_backup.bin<\/a> from your PC.<\/p>\n<p><em>Don&#8217;t forget to remove the mtd backup files from &#8220;\/var\/wwwroot&#8221; once you&#8217;ve grabbed it using your PC!<\/em><\/p>\n<p>In order to make things easier\/less prone to error, I&#8217;ve written a little script to backup all of the partitions to files in &#8220;\/var\/wwwroot\/mtd_backup&#8221;. Once you run the script, you can then browse to &#8220;http:\/\/192.168.1.1\/mtd_backup&#8221;, then right-click on each link and &#8220;Save Target As&#8230;&#8221; to save each file.<\/p>\n<p>Here&#8217;s a link to an <a href=\"http:\/\/www.hackspot.net\/iSpot\/code\/mtd_backup.sh\">mtd_backup.sh<\/a>, and\u00a0here&#8217;s the contents of the script:<\/p>\n<pre>#! \/bin\/sh\r\n\r\nDESTDIR=\/var\/wwwroot\/mtd_backup\r\nmkdir -p $DESTDIR\r\necho \"&lt;HTML&gt;&lt;body&gt;\" &gt; $DESTDIR\/index.html\r\necho \"&lt;br&gt;Right-click and 'Save Target As...' on all of the following:&lt;br&gt;\" &gt;&gt; $DESTDIR\/index.html\r\n\r\nlet x=0\r\nwhile [[ $x -le 10 ]]\r\ndo\r\n    if [[ -c \/dev\/mtd$x ]]; then\r\n        echo \"--- Backing up mtd$x ---\"\r\n        dd if=\/dev\/mtd$x of=$DESTDIR\/mtd$x.bin\r\n        if [[ $? -ne 0 ]]; then\r\n            echo \"=== ERROR backing up mtd$x! Check free space in $DESTDIR! ===\"\r\n            exit 1\r\n        fi\r\n        echo \"&lt;br&gt;&lt;br&gt;&lt;A HREF=\\\"mtd$x.bin\\\"&gt;mtd$x.bin&lt;\/A&gt;\" &gt;&gt; $DESTDIR\/index.html\r\n    fi\r\n    let x=$x+1\r\ndone\r\n\r\necho \"&lt;\/body&gt;&lt;\/html&gt;\" &gt;&gt; $DESTDIR\/index.html\r\necho \"=== Backup to $DESTDIR complete:\"\r\nls -l $DESTDIR\/mtd*.bin<\/pre>\n<p>The script creates a backup directory (&#8220;\/var\/wwwroot\/mtd_backup&#8221;), backs-up all of the &#8220;\/dev\/mtd#&#8221; device files, and in the process creates an &#8220;index.html&#8221; file in &#8220;\/var\/wwwroot\/mtd_backup&#8221; (makes it easier to download the files from your PC).<\/p>\n<p><em>Don&#8217;t forget to remove the mtd backup files from &#8220;\/var\/wwwroot\/mtd_backup&#8221; once you&#8217;ve grabbed them using your PC!<\/em><\/p>\n<p>A future article will give some tips on recovering a device by making use of these backup files.<\/p>\n<p><em>\u00a0<\/em><\/p>\n<p><em>Disclaimer: information on this site is for educational purposes only, and intended to help iSpot owners experiment with their own devices. I do not condone any hacking for illegal purposes, such as stealing service, etc.<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In case of future corruption of the flash memory chip on your iSpot (especially if you are &#8216;hacking&#8217; your device), it&#8217;s a good idea to make a backup of the contents.\u00a0 Hopefully, having this backup will make it possible to &hellip; <a href=\"http:\/\/hackspot.net\/iSpotBlog\/?p=115\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-115","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"http:\/\/hackspot.net\/iSpotBlog\/index.php?rest_route=\/wp\/v2\/posts\/115","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/hackspot.net\/iSpotBlog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/hackspot.net\/iSpotBlog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/hackspot.net\/iSpotBlog\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/hackspot.net\/iSpotBlog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=115"}],"version-history":[{"count":39,"href":"http:\/\/hackspot.net\/iSpotBlog\/index.php?rest_route=\/wp\/v2\/posts\/115\/revisions"}],"predecessor-version":[{"id":156,"href":"http:\/\/hackspot.net\/iSpotBlog\/index.php?rest_route=\/wp\/v2\/posts\/115\/revisions\/156"}],"wp:attachment":[{"href":"http:\/\/hackspot.net\/iSpotBlog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=115"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/hackspot.net\/iSpotBlog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=115"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/hackspot.net\/iSpotBlog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=115"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}