Welcome! Log In Create A New Profile

Advanced

Recovery System ready for use

Posted by Jeff 
Recovery System ready for use
September 15, 2010 04:58PM
I've made a Recovery System that I think will be more useful than the Pogoplug partition. This will replace the Pogoplug kernel on mtd1 and the Pogoplug system on mtd2 with a more sophisticated system.

The new system includes:
  • ipkg
  • ext2/3/4 create and repair utilities
  • ubifs support/utilities
  • flash/nand utilities
  • md/raid support/utilities
  • ntfs-3g
  • xfs support/utilities
  • reiserfs support
  • nfs support
  • lvm support/utilities
  • ssh/sshfs/openssl
  • wget/curl/links/ncftp/rsync
  • vi/nano
  • screen
  • kernel 2.6.32-18 with tons of modules for whatever you may have connected

The default login is 'root' with password 'root'

See this post for a list of the included binaries.

By default, the system will attempt to get an IP address over DHCP. It will also use the static IP address 169.254.9.17 for recovery when DHCP is not working.

The installer will check to make sure you're running the latest uBoot, so make sure you upgrade that before anything else. If you don't want to upgrade uBoot, you can comment out the check as long as you're not running the stock Pogoplug uBoot.

Boot from a USB device (or a Debian NAND install) and run the following commands:
cd /tmp
wget http://jeff.doozan.com/debian/rescue/install_rescue.sh
chmod +x install_rescue.sh
./install_rescue.sh

The system is based on buildroot which is a pretty nice tool for this sort of thing. If you'd like to build your own images, you can do so with the following commands:
cd /usr/src
wget http://buildroot.uclibc.org/downloads/buildroot-2010.08.tar.gz
tar -xzvf buildroot-2010.08.tar.gz
cd buildroot-2010.08
wget http://jeff.doozan.com/debian/rescue/buildroot-dockstar.tgz
tar -xzvf buildroot-dockstar.tgz
cp custom/buildroot-config .config
make

If you're compiling on a multi-core machine, you may want to do 'make menuconfig' before 'make' and adjust 'number of jobs to run simultaneously' under 'build options' Be prepared to wait, the entire build process will likely take many hours.

After you've built the image, you can create the flashable images with the following commands:
cd output/images

cat <<END >rootfs.cfg
[ubifs]
mode=ubi
image=rootfs.ubifs
vol_id=0
vol_type=dynamic
vol_name=rootfs
vol_flags=autoresize
END

ubinize -o rootfs-mtd2.img -m 2048 -p 128KiB -s 512 rootfs.cfg
dd if=uImage of=uImage-mtd1.img bs=512K conv=sync


I'm more than happy to accept patches against this to add any requested features.

-- Jeff



Edited 6 time(s). Last edit at 09/16/2010 03:18PM by Jeff.
nguyen
Re: Recovery System ready for use
September 16, 2010 12:04AM
You are quick. Could you also provide rootfs for USB?
Vlad
Re: Recovery System ready for use
September 16, 2010 03:36AM
Hi,

For completeness some xfs tools could help (I use xfs for my /home)

Anyway thanks for your work.
Re: Recovery System ready for use
September 16, 2010 04:58AM
There is an error in the script Jeff:

debian:/tmp$ wget http://jeff.doozan.com/debian/rescue/install_rescue.sh
--2010-09-16 10:55:59--  http://jeff.doozan.com/debian/rescue/install_rescue.sh
Resolving jeff.doozan.com... 69.163.187.226
Connecting to jeff.doozan.com|69.163.187.226|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 8334 (8.1K) [application/x-sh]
Saving to: `install_rescue.sh'

100%[======================================>] 8,334       41.1K/s   in 0.2s

2010-09-16 10:56:00 (41.1 KB/s) - `install_rescue.sh' saved [8334/8334]

debian:/tmp$ chmod +x install_rescue.sh
debian:/tmp$ ./install_rescue.sh

This script will install a rescue system on your NAND.
It will OVERWRITE ALL OF THE POGOPLUG FILES.

This script will replace the kernel on on mtd1 and the rootfs on mtd2.

This installer will only work on a Seagate Dockstar or Pogoplug Pink.
Do not run this installer on any other device.

By typing ok, you agree to assume all liabilities and risks
associated with running this installer.

If you agree, type 'ok' and press ENTER to continue: ok

# Installing ubiformat...
--2010-09-16 10:56:35--  http://.md5/
Resolving .md5... failed: Name or service not known.
wget: unable to resolve host address `.md5'
http://: Invalid host name.
http://: Invalid host name.
mount: / is busy
## Could not install ubiformat, exiting.
debian:/tmp$

Hope this system can replace the non booting pogoplug os.
Re: Recovery System ready for use
September 16, 2010 05:59AM
I looked at the script but don't understand the language enough to see whats missing. It might be as simple as some quotes. I don't think it made it far enough to cause you harm but can't say that for sure either. I would avoid rebooting until there is an update.

It looks like it's writing a built system to the nand so it should be able to recover regardless.

I'm planning on trying it this weekend.
Johannes
Re: Recovery System ready for use
September 16, 2010 06:05AM
Line 34:
FW_PRINTENV_URL=http://jeff.doozan.com/debian/rescue/ubiformat
should be
UBIFORMAT_URL=http://jeff.doozan.com/debian/rescue/ubiformat
Re: Recovery System ready for use
September 16, 2010 06:13AM
Ok, I modified it. But there's still one point where the script is hanging:

debian:/tmp$ ./install_rescue.sh

This script will install a rescue system on your NAND.
It will OVERWRITE ALL OF THE POGOPLUG FILES.

This script will replace the kernel on on mtd1 and the rootfs on mtd2.

This installer will only work on a Seagate Dockstar or Pogoplug Pink.
Do not run this installer on any other device.

By typing ok, you agree to assume all liabilities and risks
associated with running this installer.

If you agree, type 'ok' and press ENTER to continue: ok

# Installing flash_eraseall...
--2010-09-16 12:10:34--  http://jeff.doozan.com/debian/uboot/flash_eraseall.md5
Resolving jeff.doozan.com... 69.163.187.226
Connecting to jeff.doozan.com|69.163.187.226|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 49 [text/plain]
Saving to: `/usr/sbin/flash_eraseall.md5'

100%[======================================>] 49          --.-K/s   in 0s

2010-09-16 12:10:34 (1.73 MB/s) - `/usr/sbin/flash_eraseall.md5' saved [49/49]

--2010-09-16 12:10:34--  http://jeff.doozan.com/debian/uboot/flash_eraseall
Resolving jeff.doozan.com... 69.163.187.226
Connecting to jeff.doozan.com|69.163.187.226|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 11648 (11K) [text/plain]
Saving to: `/usr/sbin/flash_eraseall'

100%[======================================>] 11,648      57.1K/s   in 0.2s

2010-09-16 12:10:35 (57.1 KB/s) - `/usr/sbin/flash_eraseall' saved [11648/11648]

mount: / is busy
# Successfully installed flash_eraseall.
Block size 131072, page size 2048, OOB size 64
Dumping data starting at 0x00000000 and ending at 0x00080000...
## Verifying new uBoot...
--2010-09-16 12:10:36--  http://jeff.doozan.com/debian/uboot/uboot.mtd0.kwb.md5
Resolving jeff.doozan.com... 69.163.187.226
Connecting to jeff.doozan.com|69.163.187.226|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 49 [text/plain]
Saving to: `/tmp/uboot.md5'

100%[======================================>] 49          --.-K/s   in 0s

2010-09-16 12:10:37 (1.74 MB/s) - `/tmp/uboot.md5' saved [49/49]

## uBoot is good

# Downloading Rescue System
--2010-09-16 12:10:37--  http://jeff.doozan.com/debian/rescue/uImage-mtd1.img.md5
Resolving jeff.doozan.com... 69.163.187.226
Connecting to jeff.doozan.com|69.163.187.226|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 50 [text/plain]
Saving to: `/tmp/uImage-mtd1.img.md5'

100%[======================================>] 50          --.-K/s   in 0s

2010-09-16 12:10:37 (1.76 MB/s) - `/tmp/uImage-mtd1.img.md5' saved [50/50]

--2010-09-16 12:10:37--  http://jeff.doozan.com/debian/rescue/uImage-mtd1.img
Resolving jeff.doozan.com... 69.163.187.226
Connecting to jeff.doozan.com|69.163.187.226|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 3145728 (3.0M) [text/plain]
Saving to: `/tmp/uImage-mtd1.img'

100%[======================================>] 3,145,728    708K/s   in 5.4s

2010-09-16 12:10:43 (567 KB/s) - `/tmp/uImage-mtd1.img' saved [3145728/3145728]

--2010-09-16 12:10:43--  http://jeff.doozan.com/debian/rescue/rootfs-mtd2.img.md5
Resolving jeff.doozan.com... 69.163.187.226
Connecting to jeff.doozan.com|69.163.187.226|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 50 [text/plain]
Saving to: `/tmp/rootfs-mtd2.img.md5'

100%[======================================>] 50          --.-K/s   in 0s

2010-09-16 12:10:44 (1.85 MB/s) - `/tmp/rootfs-mtd2.img.md5' saved [50/50]

--2010-09-16 12:10:44--  http://jeff.doozan.com/debian/rescue/rootfs-mtd2.img
Resolving jeff.doozan.com... 69.163.187.226
Connecting to jeff.doozan.com|69.163.187.226|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 25296896 (24M) [text/plain]
Saving to: `/tmp/rootfs-mtd2.img'

100%[======================================>] 25,296,896   696K/s   in 36s

2010-09-16 12:11:20 (691 KB/s) - `/tmp/rootfs-mtd2.img' saved [25296896/25296896]


# Installing Rescue System
Erasing 128 Kibyte @ 400000 -- 100 % complete.
Writing data to block 0 at offset 0x0
Writing data to block 1 at offset 0x20000
Writing data to block 2 at offset 0x40000
Writing data to block 3 at offset 0x60000
Writing data to block 4 at offset 0x80000
Writing data to block 5 at offset 0xa0000
Writing data to block 6 at offset 0xc0000
Writing data to block 7 at offset 0xe0000
Writing data to block 8 at offset 0x100000
Writing data to block 9 at offset 0x120000
Writing data to block 10 at offset 0x140000
Writing data to block 11 at offset 0x160000
Writing data to block 12 at offset 0x180000
Writing data to block 13 at offset 0x1a0000
Writing data to block 14 at offset 0x1c0000
Writing data to block 15 at offset 0x1e0000
Writing data to block 16 at offset 0x200000
Writing data to block 17 at offset 0x220000
Writing data to block 18 at offset 0x240000
Writing data to block 19 at offset 0x260000
Writing data to block 20 at offset 0x280000
Writing data to block 21 at offset 0x2a0000
Writing data to block 22 at offset 0x2c0000
Writing data to block 23 at offset 0x2e0000
Erasing 128 Kibyte @ 2000000 -- 100 % complete.
/usr/sbin/ubiformat /dev/mtd2 -s 512 -f /tmp/rootfs-mtd2.img -y
./install_rescue.sh: line 297: /usr/sbin/ubiformat: Permission denied
Read error on /dev/mtd0: Cannot allocate memory

# Rescue System installation has completed successfully.
debian:/tmp$
Re: Recovery System ready for use
September 16, 2010 07:07AM
Thanks for finding the typos in the script, they've all been fixed now.

@Ultrazauberer

It looks like it's failing on the very last step. Re-download and re-run the install script and see what happens. If it still doesn't work, try running the last command manually and post the results:
/usr/sbin/ubiformat /dev/mtd2 -s 512 -f /tmp/rootfs-mtd2.img -y

-- Jeff
Re: Recovery System ready for use
September 16, 2010 07:26AM
Ok Jeff, here we go:

debian:/tmp$ wget http://jeff.doozan.com/debian/rescue/install_rescue.sh
--2010-09-16 13:19:27--  http://jeff.doozan.com/debian/rescue/install_rescue.sh
Resolving jeff.doozan.com... 69.163.187.226
Connecting to jeff.doozan.com|69.163.187.226|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 7824 (7.6K) [application/x-sh]
Saving to: `install_rescue.sh'

100%[======================================>] 7,824       37.8K/s   in 0.2s

2010-09-16 13:19:28 (37.8 KB/s) - `install_rescue.sh' saved [7824/7824]

debian:/tmp$ chmod +x install_rescue.sh
debian:/tmp$ ./install_rescue.sh

This script will install a rescue system on your NAND.
It will OVERWRITE ALL OF THE POGOPLUG FILES.

This script will replace the kernel on on mtd1 and the rootfs on mtd2.

This installer will only work on a Seagate Dockstar or Pogoplug Pink.
Do not run this installer on any other device.

By typing ok, you agree to assume all liabilities and risks
associated with running this installer.

If you agree, type 'ok' and press ENTER to continue: ok
Block size 131072, page size 2048, OOB size 64
Dumping data starting at 0x00000000 and ending at 0x00080000...
## Verifying new uBoot...
--2010-09-16 13:19:38--  http://jeff.doozan.com/debian/uboot/uboot.mtd0.kwb.md5
Resolving jeff.doozan.com... 69.163.187.226
Connecting to jeff.doozan.com|69.163.187.226|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 49 [text/plain]
Saving to: `/tmp/uboot.md5'

100%[======================================>] 49          --.-K/s   in 0s

2010-09-16 13:19:39 (1.76 MB/s) - `/tmp/uboot.md5' saved [49/49]

## uBoot is good

# Downloading Rescue System
--2010-09-16 13:19:39--  http://jeff.doozan.com/debian/rescue/uImage-mtd1.img.md5
Resolving jeff.doozan.com... 69.163.187.226
Connecting to jeff.doozan.com|69.163.187.226|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 50 [text/plain]
Saving to: `/tmp/uImage-mtd1.img.md5'

100%[======================================>] 50          --.-K/s   in 0s

2010-09-16 13:19:39 (1.75 MB/s) - `/tmp/uImage-mtd1.img.md5' saved [50/50]

--2010-09-16 13:19:39--  http://jeff.doozan.com/debian/rescue/uImage-mtd1.img
Resolving jeff.doozan.com... 69.163.187.226
Connecting to jeff.doozan.com|69.163.187.226|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 3145728 (3.0M) [text/plain]
Saving to: `/tmp/uImage-mtd1.img'

100%[======================================>] 3,145,728    688K/s   in 5.5s

2010-09-16 13:19:45 (559 KB/s) - `/tmp/uImage-mtd1.img' saved [3145728/3145728]

--2010-09-16 13:19:45--  http://jeff.doozan.com/debian/rescue/rootfs-mtd2.img.md5
Resolving jeff.doozan.com... 69.163.187.226
Connecting to jeff.doozan.com|69.163.187.226|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 50 [text/plain]
Saving to: `/tmp/rootfs-mtd2.img.md5'

100%[======================================>] 50          --.-K/s   in 0s

2010-09-16 13:19:46 (1.74 MB/s) - `/tmp/rootfs-mtd2.img.md5' saved [50/50]

--2010-09-16 13:19:46--  http://jeff.doozan.com/debian/rescue/rootfs-mtd2.img
Resolving jeff.doozan.com... 69.163.187.226
Connecting to jeff.doozan.com|69.163.187.226|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 25296896 (24M) [text/plain]
Saving to: `/tmp/rootfs-mtd2.img'

100%[======================================>] 25,296,896   693K/s   in 37s

2010-09-16 13:20:23 (675 KB/s) - `/tmp/rootfs-mtd2.img' saved [25296896/25296896]


# Installing Rescue System
Erasing 128 Kibyte @ 400000 -- 100 % complete.
Writing data to block 0 at offset 0x0
Writing data to block 1 at offset 0x20000
Writing data to block 2 at offset 0x40000
Writing data to block 3 at offset 0x60000
Writing data to block 4 at offset 0x80000
Writing data to block 5 at offset 0xa0000
Writing data to block 6 at offset 0xc0000
Writing data to block 7 at offset 0xe0000
Writing data to block 8 at offset 0x100000
Writing data to block 9 at offset 0x120000
Writing data to block 10 at offset 0x140000
Writing data to block 11 at offset 0x160000
Writing data to block 12 at offset 0x180000
Writing data to block 13 at offset 0x1a0000
Writing data to block 14 at offset 0x1c0000
Writing data to block 15 at offset 0x1e0000
Writing data to block 16 at offset 0x200000
Writing data to block 17 at offset 0x220000
Writing data to block 18 at offset 0x240000
Writing data to block 19 at offset 0x260000
Writing data to block 20 at offset 0x280000
Writing data to block 21 at offset 0x2a0000
Writing data to block 22 at offset 0x2c0000
Writing data to block 23 at offset 0x2e0000
Erasing 128 Kibyte @ 2000000 -- 100 % complete.
/usr/sbin/ubiformat /dev/mtd2 -s 512 -f /tmp/rootfs-mtd2.img -y
./install_rescue.sh: line 270: /usr/sbin/ubiformat: Permission denied

# Rescue System installation has completed successfully.
debian:/tmp$

Then the single command:
┬┤debian:/tmp$ /usr/sbin/ubiformat /dev/mtd2 -s 512 -f /tmp/rootfs-mtd2.img -y
-bash: /usr/sbin/ubiformat: Permission denied

root without permissions... That's funny. ;)
debian:/tmp$ ls -la /usr/sbin/ubiformat
-rw-r--r-- 1 root root 0 Sep 16 10:56 /usr/sbin/ubiformat
debian:/tmp$ chmod 744 /usr/sbin/ubiformat
debian:/tmp$ ls -la /usr/sbin/ubiformat
-rwxr--r-- 1 root root 0 Sep 16 10:56 /usr/sbin/ubiformat
debian:/tmp$ /usr/sbin/ubiformat /dev/mtd2 -s 512 -f /tmp/rootfs-mtd2.img -y
debian:/tmp$

Then I re-run the whole script:
debian:/tmp$ rm *
debian:/tmp$ wget http://jeff.doozan.com/debian/rescue/install_rescue.sh
--2010-09-16 13:24:38--  http://jeff.doozan.com/debian/rescue/install_rescue.sh
Resolving jeff.doozan.com... 69.163.187.226
Connecting to jeff.doozan.com|69.163.187.226|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 7824 (7.6K) [application/x-sh]
Saving to: `install_rescue.sh'

100%[======================================>] 7,824       38.2K/s   in 0.2s

2010-09-16 13:24:39 (38.2 KB/s) - `install_rescue.sh' saved [7824/7824]

debian:/tmp$ chmod +x install_rescue.sh
debian:/tmp$ ./install_rescue.sh

This script will install a rescue system on your NAND.
It will OVERWRITE ALL OF THE POGOPLUG FILES.

This script will replace the kernel on on mtd1 and the rootfs on mtd2.

This installer will only work on a Seagate Dockstar or Pogoplug Pink.
Do not run this installer on any other device.

By typing ok, you agree to assume all liabilities and risks
associated with running this installer.

If you agree, type 'ok' and press ENTER to continue: ok
Block size 131072, page size 2048, OOB size 64
Dumping data starting at 0x00000000 and ending at 0x00080000...
## Verifying new uBoot...
--2010-09-16 13:24:54--  http://jeff.doozan.com/debian/uboot/uboot.mtd0.kwb.md5
Resolving jeff.doozan.com... 69.163.187.226
Connecting to jeff.doozan.com|69.163.187.226|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 49 [text/plain]
Saving to: `/tmp/uboot.md5'

100%[======================================>] 49          --.-K/s   in 0s

2010-09-16 13:24:55 (1.73 MB/s) - `/tmp/uboot.md5' saved [49/49]

## uBoot is good

# Downloading Rescue System
--2010-09-16 13:24:55--  http://jeff.doozan.com/debian/rescue/uImage-mtd1.img.md5
Resolving jeff.doozan.com... 69.163.187.226
Connecting to jeff.doozan.com|69.163.187.226|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 50 [text/plain]
Saving to: `/tmp/uImage-mtd1.img.md5'

100%[======================================>] 50          --.-K/s   in 0s

2010-09-16 13:24:55 (1.83 MB/s) - `/tmp/uImage-mtd1.img.md5' saved [50/50]

--2010-09-16 13:24:55--  http://jeff.doozan.com/debian/rescue/uImage-mtd1.img
Resolving jeff.doozan.com... 69.163.187.226
Connecting to jeff.doozan.com|69.163.187.226|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 3145728 (3.0M) [text/plain]
Saving to: `/tmp/uImage-mtd1.img'

100%[======================================>] 3,145,728    692K/s   in 5.4s

2010-09-16 13:25:01 (569 KB/s) - `/tmp/uImage-mtd1.img' saved [3145728/3145728]

--2010-09-16 13:25:01--  http://jeff.doozan.com/debian/rescue/rootfs-mtd2.img.md5
Resolving jeff.doozan.com... 69.163.187.226
Connecting to jeff.doozan.com|69.163.187.226|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 50 [text/plain]
Saving to: `/tmp/rootfs-mtd2.img.md5'

100%[======================================>] 50          --.-K/s   in 0s

2010-09-16 13:25:02 (1.73 MB/s) - `/tmp/rootfs-mtd2.img.md5' saved [50/50]

--2010-09-16 13:25:02--  http://jeff.doozan.com/debian/rescue/rootfs-mtd2.img
Resolving jeff.doozan.com... 69.163.187.226
Connecting to jeff.doozan.com|69.163.187.226|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 25296896 (24M) [text/plain]
Saving to: `/tmp/rootfs-mtd2.img'

100%[======================================>] 25,296,896   705K/s   in 38s

2010-09-16 13:25:40 (646 KB/s) - `/tmp/rootfs-mtd2.img' saved [25296896/25296896]


# Installing Rescue System
Erasing 128 Kibyte @ 400000 -- 100 % complete.
Writing data to block 0 at offset 0x0
Writing data to block 1 at offset 0x20000
Writing data to block 2 at offset 0x40000
Writing data to block 3 at offset 0x60000
Writing data to block 4 at offset 0x80000
Writing data to block 5 at offset 0xa0000
Writing data to block 6 at offset 0xc0000
Writing data to block 7 at offset 0xe0000
Writing data to block 8 at offset 0x100000
Writing data to block 9 at offset 0x120000
Writing data to block 10 at offset 0x140000
Writing data to block 11 at offset 0x160000
Writing data to block 12 at offset 0x180000
Writing data to block 13 at offset 0x1a0000
Writing data to block 14 at offset 0x1c0000
Writing data to block 15 at offset 0x1e0000
Writing data to block 16 at offset 0x200000
Writing data to block 17 at offset 0x220000
Writing data to block 18 at offset 0x240000
Writing data to block 19 at offset 0x260000
Writing data to block 20 at offset 0x280000
Writing data to block 21 at offset 0x2a0000
Writing data to block 22 at offset 0x2c0000
Writing data to block 23 at offset 0x2e0000
Erasing 128 Kibyte @ 2000000 -- 100 % complete.
/usr/sbin/ubiformat /dev/mtd2 -s 512 -f /tmp/rootfs-mtd2.img -y

# Rescue System installation has completed successfully.
debian:/tmp$

Seems all fine, right? Should I risk to reboot? *g*
Re: Recovery System ready for use
September 16, 2010 07:38AM
-rwxr--r-- 1 root root 0 Sep 16 10:56 /usr/sbin/ubiformat

It's empty. The earlier mistake in the script must have put an empty file there. Delete the file and re-run the script and you should be fine.

-- Jeff
Re: Recovery System ready for use
September 16, 2010 07:40AM
Thanks Jeff:

# Installing Rescue System
Erasing 128 Kibyte @ 400000 -- 100 % complete.
Writing data to block 0 at offset 0x0
Writing data to block 1 at offset 0x20000
Writing data to block 2 at offset 0x40000
Writing data to block 3 at offset 0x60000
Writing data to block 4 at offset 0x80000
Writing data to block 5 at offset 0xa0000
Writing data to block 6 at offset 0xc0000
Writing data to block 7 at offset 0xe0000
Writing data to block 8 at offset 0x100000
Writing data to block 9 at offset 0x120000
Writing data to block 10 at offset 0x140000
Writing data to block 11 at offset 0x160000
Writing data to block 12 at offset 0x180000
Writing data to block 13 at offset 0x1a0000
Writing data to block 14 at offset 0x1c0000
Writing data to block 15 at offset 0x1e0000
Writing data to block 16 at offset 0x200000
Writing data to block 17 at offset 0x220000
Writing data to block 18 at offset 0x240000
Writing data to block 19 at offset 0x260000
Writing data to block 20 at offset 0x280000
Writing data to block 21 at offset 0x2a0000
Writing data to block 22 at offset 0x2c0000
Writing data to block 23 at offset 0x2e0000
Erasing 128 Kibyte @ 2000000 -- 100 % complete.
/usr/sbin/ubiformat /dev/mtd2 -s 512 -f /tmp/rootfs-mtd2.img -y
ubiformat: mtd2 (nand), size 33554432 bytes (32.0 MiB), 256 eraseblocks of 131072 bytes (128.0 KiB), min. I/O size 2048 bytes
libscan: scanning eraseblock 255 -- 100 % complete
ubiformat: 256 eraseblocks are supposedly empty
ubiformat: flashing eraseblock 192 -- 100 % complete
ubiformat: formatting eraseblock 255 -- 100 % complete

# Rescue System installation has completed successfully.
debian:/tmp$

Now is all fine (I'll hope so). ;) Give me a hint and I reboot the system. ^^
Re: Recovery System ready for use
September 16, 2010 07:49AM
Everything looks fine, you're safe to reboot.
Re: Recovery System ready for use
September 16, 2010 08:09AM
Wohoo! Everything is working! And the LED is blinking like a happy child.

login as: root
root@debian's password:
rescue:~# top

PS: I don't really saw it at your first post, but the standard login is "root:root". I tried it and it worked. So please add this information in the first post. ;)
Waty
Re: Recovery System ready for use
September 16, 2010 08:47AM
Hi Jeff!

Thank you for your great work! Everything works really fine.
But is there a possibility, that you'll write a script for a debian install from the recovery system?
flatline
Re: Recovery System ready for use
September 16, 2010 09:36AM
Hi Jeff,

also a big thank you from me!

Worked perfectly well. But, I can't find the fsick.* applications. Even they are listed in the link above, it is not available on the rescue system...
thomas
Re: Recovery System ready for use
September 16, 2010 01:15PM
hi Jeff,
i want to check out the rescue system,
but i it doesnt write to the flash, .
Are there any chances to restore the old one ?

# Installing Rescue System

Erasing 128 Kibyte @ 400000 -- 100 % complete.
Writing data to block 0 at offset 0x0
Writing data to block 1 at offset 0x20000
Writing data to block 2 at offset 0x40000
Writing data to block 3 at offset 0x60000
Writing data to block 4 at offset 0x80000
Writing data to block 5 at offset 0xa0000
Writing data to block 6 at offset 0xc0000
Writing data to block 7 at offset 0xe0000
Writing data to block 8 at offset 0x100000
Writing data to block 9 at offset 0x120000
Writing data to block 10 at offset 0x140000
Writing data to block 11 at offset 0x160000
Writing data to block 12 at offset 0x180000
Writing data to block 13 at offset 0x1a0000
Writing data to block 14 at offset 0x1c0000
Writing data to block 15 at offset 0x1e0000
Writing data to block 16 at offset 0x200000
Writing data to block 17 at offset 0x220000
Writing data to block 18 at offset 0x240000
Writing data to block 19 at offset 0x260000
Writing data to block 20 at offset 0x280000
Writing data to block 21 at offset 0x2a0000
Writing data to block 22 at offset 0x2c0000
Writing data to block 23 at offset 0x2e0000
Erasing 128 Kibyte @ 2000000 -- 100 % complete.
ubiformat: mtd2 (nand), size 33554432 bytes (32.0 MiB), 256 eraseblocks of 131072 bytes (128.0 KiB), min. I/O size 2048 bytes
libscan: scanning eraseblock 255 -- 100 % complete
ubiformat: 256 eraseblocks are supposedly empty
ubiformat: flashing eraseblock 192 -- 100 % complete
ubiformat: formatting eraseblock 255 -- 100 % complete
Warning: Bad CRC, using default environment
MTD erase error on /dev/mtd2: Invalid argument
Error: can't write fw_env to flash
Warning: Bad CRC, using default environment
MTD erase error on /dev/mtd2: Invalid argument
Error: can't write fw_env to flash
Warning: Bad CRC, using default environment
MTD erase error on /dev/mtd2: Invalid argument
Error: can't write fw_env to flash
# Rescue System installation has completed successfully.
Thanks in advance
thomas
Re: Recovery System ready for use
September 16, 2010 01:53PM
It looks like those errors may just be bad blocks. Have you tried booting the rescue system?

You mount the partition from Debian with the following commands just to see if it was created properly:
ubiattach /dev/ubi_ctrl -m 2
mount -t ubifs ubi0:rootfs /mnt

-- Jeff
thomas
Re: Recovery System ready for use
September 16, 2010 03:15PM
hello,
Have you tried booting the rescue system?
don't work
ERROR: can't get kernel image!
stopping USB..
### JFFS2 loading 'uboot-original-mtd0.kwb' to 0x800000
Scanning JFFS2 FS:  done.
find_inode failed for name=uboot-original-mtd0.kwb
load: Failed to find inode
### JFFS2 LOAD ERROR<0> for uboot-original-mtd0.kwb!
## Starting application at 0x00800200 ...
i have mounted the rootfs and it looks good, files and folders are available.
but the last 3 $FW_SETENV lines from the script seems to be not executed ...
any hints ?
thomas
Re: Recovery System ready for use
September 16, 2010 03:17PM
I've updated the images with a few changes: decompression support in tar, support for xfs and reiserfs, and zcip. zcip isn't configured, but if anyone wants to test it out, I'd be happy to add configs for it.

My uBoot installer has been updated to run from this rescue system. The Debian installer still needs to be ported.

The new list of binaries is:
rescue:~# ls /bin /sbin /usr/bin /usr/sbin
/bin:
addgroup       echo           login          rmdir          xfs_copy
adduser        egrep          ls             run-parts      xfs_db
ash            false          lsattr         sed            xfs_estimate
busybox        fdflush        mkdir          setarch        xfs_freeze
cat            fgrep          mknod          sh             xfs_fsr
catv           getopt         mktemp         sleep          xfs_growfs
chattr         grep           more           stty           xfs_info
chgrp          gunzip         mount          su             xfs_io
chmod          gzip           mountpoint     sync           xfs_logprint
chown          hostname       mt             tar            xfs_mdrestore
cp             ip             mv             touch          xfs_metadump
cpio           ipaddr         netstat        true           xfs_mkfile
date           iplink         nice           umount         xfs_ncheck
dd             iproute        pidof          uname          xfs_quota
delgroup       iprule         ping           usleep         xfs_rtcp
deluser        iptunnel       pipe_progress  vi             zcat
df             kill           printenv       watch
dmesg          linux32        ps             xfs_admin
dnsdomainname  linux64        pwd            xfs_bmap
dumpkmap       ln             rm             xfs_check

/sbin:
devmem             lvextend           pvcreate           vgcfgbackup
dmsetup            lvm                pvdisplay          vgcfgrestore
fdisk              lvmchange          pvmove             vgchange
freeramdisk        lvmdiskscan        pvremove           vgck
fsck               lvmsadc            pvresize           vgconvert
fsck.xfs           lvmsar             pvs                vgcreate
getty              lvreduce           pvscan             vgdisplay
halt               lvremove           reboot             vgexport
hdparm             lvrename           rmmod              vgextend
hwclock            lvresize           route              vgimport
ifconfig           lvs                runlevel           vgmerge
ifdown             lvscan             setconsole         vgmknodes
ifup               makedevs           start-stop-daemon  vgreduce
init               mdev               sulogin            vgremove
insmod             mkfs.ntfs          swapoff            vgrename
klogd              mkfs.xfs           swapon             vgs
ldconfig           mkswap             switch_root        vgscan
loadkmap           modprobe           sysctl             vgsplit
losetup            mount.ntfs-3g      syslogd            watchdog
lsmod              nameif             tune2fs            xfs_repair
lvchange           pivot_root         udhcpc             zcip
lvcreate           poweroff           usbmount
lvdisplay          pvchange           vconfig

/usr/bin:
[                    length               seq
[[                   less                 setkeycodes
ar                   links                setserial
arping               lockfile-create      setsid
awk                  lockfile-remove      sftp
basename             lockfile-touch       sha1sum
bunzip2              logger               sha256sum
bzcat                logname              sha512sum
chattr               lsattr               slogin
chrt                 lspci                sort
chvt                 lsusb                ssh
cksum                lzcat                ssh-add
clear                lzma                 ssh-agent
cmp                  md5sum               ssh-keygen
crontab              mesg                 ssh-keyscan
curl                 mkfifo               sshfs
cut                  nano                 strings
dc                   nc                   sudo
deallocvt            ncftp                tail
diff                 ncftpbatch           tee
dirname              ncftpget             telnet
dos2unix             ncftpls              test
du                   ncftpput             tftp
eject                ncftpspooler         time
env                  nohup                top
ether-wake           nslookup             tr
expr                 ntfs-3g              traceroute
fdformat             ntfs-3g.probe        tty
file                 ntfscat              uniq
find                 ntfscluster          unix2dos
fold                 ntfscmp              unlzma
free                 ntfsfix              unxz
fuser                ntfsinfo             unzip
fusermount           ntfsls               update-alternatives
gio-querymodules     ntpdate              uptime
head                 od                   uudecode
hexdump              openssl              uuencode
hostid               openvt               uuidgen
iconv                passwd               vlock
id                   patch                wc
install              printf               wget
ipcrm                readlink             which
ipcs                 realpath             who
iperf                renice               whoami
ipkg-cl              reset                xargs
killall              resize               xz
killall5             rsync                xzcat
last                 scp                  yes
ldd                  screen

/usr/sbin:
badblocks       flashcp         mkfs.ext4       setlogcons
blkid           fsck            mkfs.ext4dev    smartctl
chroot          fsck.ext2       mkfs.jffs2      smartd
crond           fsck.ext3       mklost+found    sshd
dnsd            fsck.ext4       mkntfs          tune2fs
dumpe2fs        fsck.ext4dev    mtd_debug       ubiattach
e2freefrag      fw_printenv     mtdinfo         ubicrc32
e2fsck          fw_setenv       nanddump        ubidetach
e2label         ifplugd         nandtest        ubiformat
e2undo          ifplugstatus    nandwrite       ubimkvol
ethtool         inetd           ntfsclone       ubinfo
filefrag        loadfont        ntfscp          ubinize
findfs          logsave         ntfslabel       ubirename
flash_erase     lsusb           ntfsresize      ubirmvol
flash_eraseall  mdadm           ntfsundelete    ubirsvol
flash_info      mke2fs          ntpd            ubiupdatevol
flash_lock      mkfs.ext2       rdate           uuidd
flash_unlock    mkfs.ext3       readprofile     visudo

And there's still space for you to add whatever you like:
rescue:~# df
Filesystem                Size      Used Available Use% Mounted on
ubi0:rootfs              27.0M     22.1M      4.9M  82% /
tmpfs                    60.2M     48.0K     60.1M   0% /tmp

-- Jeff



Edited 1 time(s). Last edit at 09/16/2010 03:46PM by Jeff.
Re: Recovery System ready for use
September 16, 2010 03:28PM
@thomas

If the uBoot config didn't get set for some reason (odd, since that "# Rescue System installation has completed successfully." message is printed AFTER they run) you can configure them by hand:

fw_setenv set_bootargs_rescue 'setenv bootargs console=$console ubi.mtd=2 root=ubi0:rootfs ro rootfstype=ubifs $mtdparts'
fw_setenv bootcmd_rescue 'run set_bootargs_rescue; nand read.e 0x800000 0x100000 0x400000; bootm 0x800000'
fw_setenv bootcmd_pogo 'run bootcmd_rescue'

Did you happen to run the uBoot installer again after you installed the Recovery System? That would reset the environment back to what it sounds like you have.

-- Jeff
Johannes
Re: Recovery System ready for use
September 16, 2010 04:00PM
@thomas: It looks like fw_setenv isn't accessing the right environment. The boot loader environment is supposed to be on /dev/mtd0 at offset 0xC0000, not on mtd2.

> Warning: Bad CRC, using default environment
> MTD erase error on /dev/mtd2: Invalid argument
> Error: can't write fw_env to flash

It complains about a wrong environment checksum. Can you list the output of
fw_printenv
and
cat /etc/fw_env.conf
thomas
Re: Recovery System ready for use
September 17, 2010 12:02AM
@Johannes
ok, the output looks not good
dockstar ~ # fw_printenv
Warning: Bad CRC, using default environment
bootcmd=bootp; setenv bootargs root=/dev/nfs nfsroot=${serverip}:${rootpath} ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}:${hostname}::off; bootm
bootdelay=5
baudrate=115200
and the fw_env.conf is not avaiable, i'm here on gentoo ,forgot to say.
where is the right location for the /etc/ffw_env..conf, on the usb device !?
so i can put it manually there.
dockstar ~ # cat /etc/fw_env.conf
cat: /etc/fw_env.conf: No such file or directory
Thanks in advance
thomas
olla
Re: Recovery System ready for use
September 17, 2010 12:03AM
I think it is good to provide USB Recovery System for installing Recovery System on mtd0 and mtd1. You don't need to install Debian on USB.
thomas
Re: Recovery System ready for use
September 17, 2010 12:19AM
@Johannes
sorry , i found the file on USB device fw_env.config

cat: /etc/fw_env.conf: No such file or directory
dockstar ~ # cat /etc/fw_env.config
# Configuration file for fw_(printenv/saveenv) utility.
# Up to two entries are valid, in this case the redundant
# environment sector is assumed present.
# Notice, that the "Number of sectors" is ignored on NOR.

# MTD device name       Device offset   Env. size       Flash sector size       Number of sectors
/dev/mtd1               0x0000          0x4000          0x4000
/dev/mtd2               0x0000          0x4000          0x4000

# NAND example
#/dev/mtd0              0x4000          0x4000          0x20000                 2

on the rescue system
dockstar ~ # cat /mnt/etc/fw_env.config
# MTD device name       Device offset   Env. size       Flash sector size       Number of sectors
/dev/mtd0         0xc0000       0x20000   0x20000



Thomas
Johannes
Re: Recovery System ready for use
September 17, 2010 03:18AM
@thomas:

On the system which you use to install the rescue system (or on any other system from which you want to access the boot loader configuration with fw_printenv or fw_setenv), the configuration file /etc/fw_env.config must exist and have the following content (comment lines beginning with # and blank lines don't make a difference)

# MTD device name Device offset Env. size Flash sector size Number of sectors
/dev/mtd0 0xc0000 0x20000 0x20000

This tells fw_printenv and fw_setenv where the configuration data is stored (partition /dev/mtd0, offset 0xC0000, 128K size, 128K erase block). Without that information, both programs use their built-in default values which don't match the configuration of the actual system.

You can get create this file manually with your preferred text editor or get it like this (as root, with writable file system):
cd /etc
wget http://jeff.doozan.com/debian/uboot/fw_env.config

verify that you got it correctly:
cat /etc/fw_env.config
thomas
Re: Recovery System ready for use
September 17, 2010 03:45AM
@Johannes
thank you so much

flashing now without errors
and the rescue system was startet

..
Writing data to block 27 at offset 0x360000
Erasing 128 Kibyte @ 2000000 -- 100 % complete.
ubiformat: mtd2 (nand), size 33554432 bytes (32.0 MiB), 256 eraseblocks of 131072 bytes (128.0 KiB), min. I/O size 2048 bytes
libscan: scanning eraseblock 255 -- 100 % complete
ubiformat: 256 eraseblocks are supposedly empty
ubiformat: flashing eraseblock 199 -- 100 % complete
ubiformat: formatting eraseblock 255 -- 100 % complete
# Rescue System installation has completed successfully.
..
Starting kernel ...

Uncompressing Linux...........................................................................................................................
[    0.000000] Initializing cgroup subsys cpuset
[    0.000000] Initializing cgroup subsys cpu
[    0.000000] Linux version 2.6.32.18-dockstar (root@stfu.tcbnet) (gcc version 4.3.5 (Buildroot 2010.08) ) #1 Thu Sep 16 16:04:06 EDT 2010

Thomas
Andy
Re: Recovery System ready for use
September 17, 2010 06:09AM
Hi i have install the rescue system but i cant exit it. The Led flash orange and green. I think it has correct boot? But the device got non IP.
Andy
Re: Recovery System ready for use
September 17, 2010 06:21AM
Ok i have found out that the problem is a USB Stick with corrupt filesystem. If i plug it out it works.


What i have done is to pull the power-plug. Now it is like a power loss. So my idea wars that the dockstar now boot the rescue system and i can repair the filesystem and make a reboot. But it dosent work for me.
qingz
Re: Recovery System ready for use
September 17, 2010 02:43PM
Waty Wrote:
-------------------------------------------------------
> Hi Jeff!
>
> Thank you for your great work! Everything works
> really fine.
> But is there a possibility, that you'll write a
> script for a debian install from the recovery
> system?

Yes, Please! I need it too.
Thanks!
Lothar
Re: Recovery System ready for use
September 21, 2010 11:44AM
Since i was missing some mkfs.ext? and fsck.ext? i upgraded the rescue system and changed the usb_init to boot from a 2nd partition of the USB-device:

fw_setenv usb_init 'usb start; if ext2load usb 0:2 0x800000 /boot/uImage; then setenv usb_device 0:2; setenv usb_root /dev/sda2; elif ext2load usb 0:1 0x800000 /boot/uImage; then setenv usb_device 0:1; setenv usb_root /dev/sda1; fi;'

The complete environment is:
debian:~# fw_printenv
bootcmd=run bootcmd_usb; usb stop; run bootcmd_pogo; reset
bootdelay=3
baudrate=115200
preboot=
arcNumber=2097
mainlineLinux=yes
console=ttyS0,115200
usb_device=0:1
usb_root=/dev/sda1
usb_rootfstype=ext2
usb_rootdelay=10
mtdparts=mtdparts=orion_nand:1M(u-boot),4M(uImage),32M(rootfs),-(data)
mtdids=nand0=orion_nand
partition=nand0,2
usb_load_uimage=mw 0x800000 0 1; ext2load usb $usb_device 0x800000 /boot/uImage
usb_boot=if ext2load usb $usb_device 0x1100000 /boot/uInitrd; then bootm 0x800000 0x1100000;else bootm 0x800000;fi;
set_bootargs_usb=setenv bootargs console=$console root=$usb_root rootdelay=$usb_rootdelay rootfstype=$usb_rootfstype $mtdparts
bootcmd_usb=run usb_init; run usb_load_uimage; run set_bootargs_usb; run usb_boot;
led_init=green blinking
led_exit=green off
led_error=orange blinking
stdin=serial
stdout=serial
stderr=serial
ethact=egiga0
ethaddr=00:10:23:45:67:89
usb_init=usb start; if ext2load usb 0:2 0x800000 /boot/uImage; then setenv usb_device 0:2; setenv usb_root /dev/sda2; elif ext2load usb 0:1 0x800000 /boot/uImage; then setenv usb_device 0:1; setenv usb_root /dev/sda1; fi;
set_bootargs_rescue=setenv bootargs console=$console ubi.mtd=2 root=ubi0:rootfs ro rootfstype=ubifs $mtdparts
bootcmd_rescue=run set_bootargs_rescue; nand read.e 0x800000 0x100000 0x400000; bootm 0x800000
bootcmd_pogo=run bootcmd_rescue

But the rescue system doesnt boot anymore.
I got only two short repeating blinks of the LED. These i think are from the usb_init.

Any suggestions?
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: