8 size
="$(echo -n "$cmdline" | wc -c)"
9 dd if="$input" bs
=3M count
=1 > "$output"
10 /sbin
/patch-cmdline
"$output" "$cmdline"
13 fstype
="$(mount | grep ' / ' | awk '$5 != "rootfs
" {print $5}')"
15 ext2|jffs2
) echo "Copying from $fstype to yaffs2";;
16 *) echo "Invalid filesystem."; exit 1;;
19 [ -d /tmp
/cf2nand
] && {
20 echo "/tmp/cf2nand already exists"
25 mkdir
/tmp
/cf2nand
/rootfs
26 mount
-t "$fstype" /dev
/root
/tmp
/cf2nand
/rootfs ||
{
27 echo "Mounting rootfs failed."
31 boot
="$(find_mtd_part 'Routerboard NAND boot')"
32 main
="$(find_mtd_part 'rootfs')"
33 [ -z "$boot" -o -z "$main" ] && {
34 echo "Cannot find NAND Flash partitions"
38 echo "Erasing filesystem..."
39 mtd erase Boot
2>/dev
/null
>/dev
/null
40 mtd erase Main
2>/dev
/null
>/dev
/null
44 mount
-t yaffs2
"$boot" /tmp
/cf2nand
/p1
45 mount
-t yaffs2
"$main" /tmp
/cf2nand
/p2
47 echo "Copying kernel..."
48 copy_kernel
/dev
/cfa1
/tmp
/cf2nand
/p
1/kernel
"root=/dev/mtdblock1 rootfstype=yaffs2 init=/etc/preinit " 2>/dev
/null
>/dev
/null
49 umount
/tmp
/cf2nand
/p1
52 echo "Copying filesystem..."
53 ( cd /tmp
/cf2nand
/rootfs
; tar c .
) |
( cd /tmp
/cf2nand
/p2
; tar x
)
54 echo "chmod ugo+x /" > /tmp
/cf2nand
/p
2/etc
/uci-defaults
/set_root_permission
56 # Use kexec is present
57 [ -x /usr
/bin
/kexec
] && {
58 kexec
-l /tmp
/cf2nand
/p
1/kernel
--command-line="$(cat /proc/cmdline) root=/dev/mtdblock1 rootfstype=yaffs2 init=/etc/preinit"
61 umount
/tmp
/cf2nand
/p2
64 umount
/tmp
/cf2nand
/rootfs
65 rmdir /tmp
/cf2nand
/rootfs
This page took 0.052746 seconds and 5 git commands to generate.