Difference between revisions of "Archiving JFFS2 Images"
(→Procedure) |
|||
Line 13: | Line 13: | ||
root@emac-oe:~# mount -o nolock -t nfs 10.0.2.60:/opt/nfs /tmp/nfs | root@emac-oe:~# mount -o nolock -t nfs 10.0.2.60:/opt/nfs /tmp/nfs | ||
<li>Next, determine which MTD partition contains the JFFS2 image to be copied. In most cases, this will be the root filesystem but the same procedure can be used to archive any JFFS2 partition. The most helpful information can usually be found in the <code>/proc/mtd</code> file. The output of the <code>mount</code> command, <code>/etc/fstab</code>, and other commands may also be used. The listing below shows the contents of <code>/proc/mtd</code> on a system where <code>/dev/mtd0</code> contains the root filesytem.</li> | <li>Next, determine which MTD partition contains the JFFS2 image to be copied. In most cases, this will be the root filesystem but the same procedure can be used to archive any JFFS2 partition. The most helpful information can usually be found in the <code>/proc/mtd</code> file. The output of the <code>mount</code> command, <code>/etc/fstab</code>, and other commands may also be used. The listing below shows the contents of <code>/proc/mtd</code> on a system where <code>/dev/mtd0</code> contains the root filesytem.</li> | ||
− | |||
root@emac-oe:~# cat /proc/mtd | root@emac-oe:~# cat /proc/mtd | ||
dev: size erasesize name | dev: size erasesize name | ||
Line 21: | Line 20: | ||
mtd3: 00210000 00000210 “df_kernel” | mtd3: 00210000 00000210 “df_kernel” | ||
mtd4: 001ce000 00000210 “df_aux” | mtd4: 001ce000 00000210 “df_aux” | ||
− | |||
<li>Once the remote NFS filesystem has been mounted, a binary copy of the image can be taken by following the steps below.</li> | <li>Once the remote NFS filesystem has been mounted, a binary copy of the image can be taken by following the steps below.</li> | ||
{{mbox | type = notice | text = The required commands are different for NAND flash and NOR flash. If you are unsure of which type of flash is used on the system that you are archiving, refer to the documentation for your hardware.}} | {{mbox | type = notice | text = The required commands are different for NAND flash and NOR flash. If you are unsure of which type of flash is used on the system that you are archiving, refer to the documentation for your hardware.}} |
Revision as of 15:30, 6 May 2013
After modifying the filesytem on a system, it is often advantageous to archive the JFFS2 image. This allows for the same image to be programmed to other systems as well as providing a backup during software development. While there are several ways to do this, the method outlined here utilizes an NFS server to copy the binary JFFS2 image directly from the running system.
"Note that this process applies only to boards that use a JFFS2 filesystem for flash storage. A different method is utilized for systems using other filesystems, such as ext3. |
Procedure
This procedure assumes that a working NFS server is accessible on the local network and that the board will have write access to the server. Once this configuration has been tested, follow the steps below to create the archive.
- Boot the system and log in as the root user.
- Create a directory to use for the mount point of the NFS drive. For this example,
/tmp/nfs
will be used. - Mount the NFS filesystem. The commands in this step assume that 10.0.2.60 is the IP address of the NFS server on the local network and that
/opt/nfs
is the exported directory on the server that the image should be copied to. These parameters will need to be adjusted to match the local network configuration. Also note that the nolock option is necessary because no portmap daemon is running on the default EMAC OE system. - Next, determine which MTD partition contains the JFFS2 image to be copied. In most cases, this will be the root filesystem but the same procedure can be used to archive any JFFS2 partition. The most helpful information can usually be found in the
/proc/mtd
file. The output of themount
command,/etc/fstab
, and other commands may also be used. The listing below shows the contents of/proc/mtd
on a system where/dev/mtd0
contains the root filesytem. - Once the remote NFS filesystem has been mounted, a binary copy of the image can be taken by following the steps below.
- NOR Flash
- For NOR flash, the
dd
command should be used. The MTD block device corresponding to the JFFS2 partition must be specified as the image source:/dev/mtdblock0
in this case. - NAND Flash
- For NAND devices, the
nanddump
command is used to allow for correct bad block handling. The MTD device (not the block device) corresponding to the JFFS2 partion must be specified as the image source:/dev/mtd0
in this case. - Once the image has been successfully copied, unmount the NFS drive.
root@emac-oe:~# mkdir /tmp/nfs
root@emac-oe:~# mount -o nolock -t nfs 10.0.2.60:/opt/nfs /tmp/nfs
root@emac-oe:~# cat /proc/mtd dev: size erasesize name mtd0: 02000000 00020000 “root” mtd1: 0e000000 00020000 “aux” mtd2: 00042000 00000210 “df_boot” mtd3: 00210000 00000210 “df_kernel” mtd4: 001ce000 00000210 “df_aux”
The required commands are different for NAND flash and NOR flash. If you are unsure of which type of flash is used on the system that you are archiving, refer to the documentation for your hardware. |
root@emac-oe:~# cd /tmp/nfs root@emac-oe:~# dd if=/dev/mtdblock0 of=rootfs_backup.jffs2
root@emac-oe:~# cd /tmp/nfs root@emac-oe:~# nanddump /dev/mtd0 -o -n -f rootfs_backup.jffs2
root@emac-oe:~# cd root@emac-oe:~# umount /tmp/nfs