Welcome! Log In Create A New Profile

Advanced

Some Uboot and migrating questions.

Posted by 6pack 
6pack
Some Uboot and migrating questions.
August 19, 2012 01:28AM
Q1 - Migrating old disk to new one
I have installed debian on a sandisk 4GB usb disk. The debian partiton is 2GB and swap is 512MB i think.
I want to move this to a larger 1TB usb hdd. I made a 2Gb partition for rootfs with label rootfs, 512MB saw with no label and rest might be ntfs/ ext 3 or 4 (havent formatted it yet).

What are the steps I need to do this? I'm a beginner in linux/bash and easily forget commands since i dont use them often. if possible a step by step instructions would be helpful to me.

Also my sandisk has some bad sectors i think. if i copy the files directly, will the os mark the corresponding sectors on my usb hdd as bad? also i think the media or device type or id is mentioned in some file in form of 0x0002c or something... do i need to change that file?


Q2 - I wanted to try archlinux in meantime. So i tried extracting archlinux arm tarbgz file on my empty usb hdd. but it wont boot into it. it boots into pogo's bash everytime.

While installing, i didnt do the uboot install part, since i thought it will rewrite the nand with uboot again if i do it, right?

Where is uboot installed in the first place? on hdd or nand of pogo?
i had already downloaded archlinux arm tar from the site and i unpacked it to root of usb hdd after creating a tmp dir. Comparing the install with my debian install on usb, i can see all the folders in the root of the hdd, except - initrd.img and vmlinuz. I saw some files not present are in the boot folder. only uImage is present. the rest 4 kirkwood files and uInitrd files are not present. i'm sure some lib files are not there too.
what did i do wrong?

Q3 - can someone explain how the uboot works to me? like is it installed in pogoplug and it checks the usb stick for boot image, etc. I'm not is search of a detailed explanation, just what process it does normally when the plug is started.

Q4 - is there an option of dualbooting between archlinux and debian in uboot?
Re: Some Uboot and migrating questions.
August 19, 2012 03:35PM
6pack Wrote:
-------------------------------------------------------
> Q1 - Migrating old disk to new one
> I have installed debian on a sandisk 4GB usb disk.
> The debian partiton is 2GB and swap is 512MB i
> think.
> I want to move this to a larger 1TB usb hdd. I
> made a 2Gb partition for rootfs with label rootfs,
> 512MB saw with no label and rest might be ntfs/
> ext 3 or 4 (havent formatted it yet).
>
> What are the steps I need to do this? I'm a
> beginner in linux/bash and easily forget commands
> since i dont use them often. if possible a step by
> step instructions would be helpful to me.
>
> Also my sandisk has some bad sectors i think. if i
> copy the files directly, will the os mark the
> corresponding sectors on my usb hdd as bad? also i
> think the media or device type or id is mentioned
> in some file in form of 0x0002c or something... do
> i need to change that file?
>

If you have Acronis on a Windows PC then cloning the USB flash to a HDD is pretty easy. Cloning with Acronis allows the partitions to be expanded to fit the new capacity.

If not, the manual steps are a little bit elaborated, and must be done on another Linux box. The basic idea is to format the HDD to the same structure as the USB flash (i.e. 3 partitions with the same FS type, marking the boot partitions active,....). The same way that you've used to partition and format the USB drive. And then as root, use cp command to copy. For example, cp -aR /media/sda1/ /media/sdb1/ (where sda1 is the drive letter for the USB flash, and sdb1 is for the HDD, as mounted on the Linux box). There are other different ways to do it, but I think this is the simplest. Only the rootfs partition needs copying, the swap parttion only needs to be marked as swap when you create it.


> Q3 - can someone explain how the uboot works to
> me? like is it installed in pogoplug and it checks
> the usb stick for boot image, etc. I'm not is
> search of a detailed explanation, just what
> process it does normally when the plug is started.
>
>

UBoot is installed in NAND. During power up, it is executed automattically, and the installed UBoot environment variables determine where the Debian boot image (uImage) is. So UBoot uses these info to know where to find the uImage. For example, this netconsole log shows UBoot loading Debian uImage and uInitrd from the hard drive hda1.

U-Boot 2010.09 (Oct 23 2010 - 11:53:10)
Marvell-GoflexNet by Jeff Doozan, Peter Carmichael
Hit any key to stop autoboot:  0 
(Re)start USB...
USB:   Register 10011 NbrPorts 1
USB EHCI 1.00
scanning bus for devices... 1 USB Device(s) found
       scanning bus for storage devices... 0 Storage Device(s) found
** Block device usb 0 not supported

** Invalid boot device **
Creating 1 MTD partitions on "nand0":
0x000002500000-0x000010000000 : "mtd=3"
UBI: attaching mtd1 to ubi0
UBI: physical eraseblock size:   131072 bytes (128 KiB)
UBI: logical eraseblock size:    129024 bytes
UBI: smallest flash I/O unit:    2048
UBI: sub-page size:              512
UBI: VID header offset:          512 (aligned 512)
UBI: data offset:                2048
UBI error: validate_ec_hdr: bad VID header offset 2048, expected 512
UBI error: validate_ec_hdr: bad EC header
UBI error: ubi_io_read_ec_hdr: validation failed for PEB 0
UBI error: ubi_init: cannot attach mtd1
UBI error: ubi_init: UBI error: cannot initialize UBI, error -22
UBI init error -22
** Block device usb 0 not supported
** Block device usb 1 not supported
** Block device usb 2 not supported
** Block device usb 3 not supported
** Block device usb 0 not supported
** Block device usb 0 not supported
Wrong Image Format for bootm command
ERROR: can't get kernel image!
stopping USB..

Reset IDE: Bus 0: ....OK Bus 1: OK 
  Device 0: Model: Hitachi HDT721016SLA380  Firm: ST1OA31B Ser#: xxxxxxxxxxxxx
            Type: Hard Disk
            Supports 48-bit addressing
            Capacity: 152627.8 MB = 149.0 GB (312581808 x 512)
  Device 1: Model: Hitachi HDT721016SLA380  Firm: ST1OA31B Ser#: xxxxxxxxxxxxx
            Type: Hard Disk
            Supports 48-bit addressing
            Capacity: 152627.8 MB = 149.0 GB (312581808 x 512)
Loading file "/boot/uImage" from ide device 0:1 (hda1)
1638256 bytes read
Loading file "/boot/uInitrd" from ide device 0:1 (hda1)
6664745 bytes read
## Booting kernel from Legacy Image at 00800000 ...
   Image Name:   Linux-3.2.26-kirkwood
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    1638192 Bytes = 1.6 MiB
   Load Address: 00008000
   Entry Point:  00008000
   Verifying Checksum ... OK
## Loading init Ramdisk from Legacy Image at 01100000 ...
   Image Name:   initramfs-3.2.26-kirkwood
   Image Type:   ARM Linux RAMDisk Image (gzip compressed)
   Data Size:    6664681 Bytes = 6.4 MiB
   Load Address: 00000000
   Entry Point:  00000000
   Verifying Checksum ... OK
   Loading Kernel Image ... OK
OK

Starting kernel ...


> Q4 - is there an option of dualbooting between
> archlinux and debian in uboot?

Not exactly as in a PC with bootcamp, but manually with 2 different USB sticks. Also depending on the HW (it is true for Dockstar, GoFlex Home/Net, Pogoplug E02, they can be all used with the same Uboot installation script). Debian and ArchLinux ARM rootfs will boot in a similar way. After you've installed Debian, and boot successfully, then you can get the latest ArchLinux ARM rootfs (see the installation instruction from the website) and put it on a USB flash drive to boot ArchLinux. For GoFlex Home/Net, watch out for the differences in UBoot/UBit installation. As you've discover, uInitrd is also a difference. Bottom line is it can't hurt to try booting another rootfs, the worse is you just go back to the rootfs that works.



Edited 3 time(s). Last edit at 08/19/2012 03:45PM by bodhi.
Re: Some Uboot and migrating questions.
August 20, 2012 12:07AM
Please change the partitions with your real partition names accordingly

# dd if=/dev/usb-rootfs-partition of=/dev/sata-rootfs-partition
# resize2fs /dev/sata-partition
6pack
Re: Some Uboot and migrating questions.
August 20, 2012 06:28AM
bodhi Wrote:
> .........................
>
> UBoot is installed in NAND. During power up, it is
> executed automattically, and the installed UBoot
> environment variables determine where the Debian
> boot image (uImage) is. So UBoot uses these info
> to know where to find the uImage. For example,
> this netconsole log shows UBoot loading Debian
> uImage and uInitrd from the hard drive hda1.
>
> Loading file "/boot/uImage" from ide device 0:1 (hda1)
> 1638256 bytes read
> Loading file "/boot/uInitrd" from ide device 0:1 (hda1)
> ........

So if i want to install archlinux on a usb device, i need to reflash the nand with uboot again?
What is still confusing me is how does the uImage files come on the hdd.
In the archlinux page, the only reference to uboot was
cd /tmp wget http://jeff.doozan.com/debian/uboot/install_uboot_mtd0.sh chmod +x install_uboot_mtd0.sh ./install_uboot_mtd0.sh
This i believe will write the nand with uboot. Since I had already installed debian on a usb stick, and had done this before, i didnt do this step.
Steps after this are relating to formating the disk to ext2, downloading archlinux tar file, extracting it and then
sync  #what does this do? does it sync archlinux files or boot image
I ran sync but nothing happened.

So from where do the uImage and the kirkwood files come into the /boot folder? i searched the tar file for these and didnt find them. Even the vmlinuz or boot initrd file in root of drive was missing. Does uboot have a script to make these files dynamically? or do these files get downloaded from some site?


My current debian is on an ext2 formatted partiton. I want to migrate it to an ext3 partition. Is it possible or should i not do it?
Re: Some Uboot and migrating questions.
August 20, 2012 08:58AM
sync flushes all write to disc, confirming a complete write.

You can safely convert the boot partition from ext2 to ext3 if on HDD, I would suggest against it on flash media.

http://archlinuxarm.org/developers/downloads has the link to the armv5te rootfs, which should be all you need.
6pack
Re: Some Uboot and migrating questions.
August 21, 2012 02:06AM
@WarheadsSE, thank you for taking the time to explain.
I actually downloaded the tar file from the site you mentioned. It has md5 starting with 767a8.....
There is another tar in the /rootfs folder with the same md5 and size. only the filename has a rootfs in it.

I noticed this on the downloads page.
Quote

Simply download the tarball that best fits and supply your own kernel.
supply your own kernel = ?

Is it possible that the tar file i downloaded does not have the initrd image in it by mistake? or is it by design?
Anyway, I got back to booting in Debian on my usb stick. I'm keeping a copy of this page for reference, next time I migrate to a usb hdd.
@bodhi, your acronis method works like a charm. I tried it on a 16GB usb stick i had lying with me. :D
6pack
Re: Some Uboot and migrating questions.
August 21, 2012 02:33AM
Another question I forgot to ask is there a way to update the kirkwood image on the pogoplug?
I see during ssh login that the kirkwood image in my debian is 2.6. version. The latest version is linux-image-3.2.0 which is in backports.
Is there a way to upgrade the kirkwood image in my usb to this newer one easily when it gets released to stable squeeze version?
Re: Some Uboot and migrating questions.
August 21, 2012 03:01AM
Debian method of upgrading (in summary):

1. Specify in apt sources.list what distribution to get the packages from. Below is "wheezy" example. Currently your 2.6.x is stable and it's "squeeze". So you should see the mirror name URL and "squeeze" in /etc/apt/sources.list

# cat /etc/apt/sources.list
deb http://ftp.us.debian.org/debian wheezy main

2. Run apt-get update and upgrade to get the latest version of your distribution:

#apt-get update
#apt-get upgrade

3. To upgrade the distribution (prepare for massive changes!)

# apt-get dist-upgrade

Right now, when you run these 2 commands, you'll get the latest in "squeeze". So when a distribution become stable, just modify your sources.list and do update and upgrade.



Edited 1 time(s). Last edit at 08/24/2012 04:44AM by bodhi.
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: