====== Boot a LaCie NAS (Kirkwood based) from an USB key ====== ===== Introduction ===== This project intends to provide help for booting an alternative distribution on a LaCie NAS. An USB key is an attractive way to do that because it is rather non intrusive for the legacy OS and the hardware (no need to open a case). This document provides information on how to boot a Debian ARM on a Network Space v2 board. Any other Linux ARM distributions or any other Kirkwood based board _could_ probably be used, but has not been tested. This howto has been written in the hope to be useful but it comes without any warranty. In other words, the lacie-nas project is not responsible if you break your Kirkwood board during an USB boot attempt. So take care! All kinds of feedbacks are welcome, so if you've tried to apply some of the information found on this page on your own device, don't hesitate dropping us a line on the [[http://sequanux.org/cgi-bin/mailman/listinfo/lacie-nas|lacie-nas mailing list]] ===== USB key setup ===== You could initialize your USB disk or key with the raw image [[ftp://lacie-nas.org/images/usb_boot_kw_sid_arm.img.gz|usb_boot_kw_sid_arm.img]] This disk image embeds two partitions. The first contains a kernel uImage and the second a Debian (unstable flavour) ARM rootfs. The following command line can be used to flash the USB key on a Linux host: zcat usb_boot_kw_sid_arm.img.gz > /dev/sd${scsi_dev_letter} Please keep in mind that any kind of data that might reside on the target drive would be irremediably lost, so proceed with caution. ===== U-Boot and USB boot ===== One word about the LaCie flavoured U-Boot: to prevent users from doing bad things, some critical environment variables are hardcoded into the U-Boot binary image. For example if the U-Boot "''bootargs''" variable is modified and saved, all the changes would be overwritten at the next boot. That's a major drawback and as a consequence, U-Boot must be configured again for each USB boot attempt. By default, the LaCie flavoured U-Boot tries to find a kernel in a disk partition (6 or 10). To use a USB device some extra U-Boot configuration must be done. A serial console or a [[CLUNC|clunc]] netconsole can be used. Here is a [[CLUNC|clunc]] command line example: echo -e 'setenv bootargs ip=dhcp console=ttyS0,115200 netconsole=6666@${ipaddr}/,6666@${serverip}/ root=/dev/sda2 rootwait usb reset usbboot 0x800000 0:1 usb stop bootm' | ./clunc -i -t 60 ''NAS-IP'' is the source IP used by U-Boot and Linux for the netconsole. Here is the [[CLUNC|clunc]] output during a successful USB boot: simon@X31:~/work/lacie/src/clunc$ echo -e 'setenv bootargs ip=dhcp netconsole=6666@${ipaddr}/,6666@${serverip}/ root=/dev/sda2 rootwait; usb reset; usbboot 0x800000 0:1; usb stop; bootm' | ./clunc -i 192.168.0.16 -w 60 Marvell>> setenv bootargs ip=dhcp netconsole=6666@${ipaddr}/,6666@${serverip}/ root=/dev/sda2 rootwait; Marvell>> usb reset; (Re)start USB... USB: scanning bus for devices... 2 USB Device(s) found scanning bus for storage devices... 1 Storage Device(s) found Marvell>> usbboot 0x800000 0:1; Loading from USB device 0, partition 1: Name: usbda1 Type: U-Boot Image Name: Linux-2.6.33-rc6-00217-g4e4a8c1- Created: 2010-02-05 14:46:45 UTC Image Type: ARM Linux Kernel Image (uncompressed) Data Size: 2932964 Bytes = 2.8 MB Load Address: 00008000 Entry Point: 00008000 ................................................................................................................. ................................................................................................................. ................................................ Marvell>> usb stop; stopping USB.. Marvell>> bootm ## Booting image at 00800000 ... Image Name: Linux-2.6.33-rc6-00217-g4e4a8c1- Created: 2010-02-05 14:46:45 UTC Image Type: ARM Linux Kernel Image (uncompressed) Data Size: 2932964 Bytes = 2.8 MB Load Address: 00008000 Entry Point: 00008000 Verifying Checksum ... OK OK Starting kernel ... Linux version 2.6.33-rc6-00217-g4e4a8c1-svn (simon@X31) (gcc version 4.4.2 (crosstool NG-hg_default@1665_60a47ac6cae1) ) #3 PREEMPT Fri Feb 5 15:46:12 CET 2010 CPU: Feroceon 88FR131 [56251311] revision 1 (ARMv5TE), cr=00053177 CPU: VIVT data cache, VIVT instruction cache [snip] Waiting for root device /dev/sda2... scsi 2:0:0:0: Direct-Access LaCie iamaKey 0.00 PQ: 0 ANSI: 2 sd 2:0:0:0: Attached scsi generic sg0 type 0 sd 2:0:0:0: [sda] 31588248 512-byte logical blocks: (16.1 GB/15.0 GiB) sd 2:0:0:0: [sda] Write Protect is off sd 2:0:0:0: [sda] Assuming drive cache: write through sd 2:0:0:0: [sda] Assuming drive cache: write through sda: sda1 sda2 sd 2:0:0:0: [sda] Assuming drive cache: write through sd 2:0:0:0: [sda] Attached SCSI removable disk EXT3-fs (sda2): warning: checktime reached, running e2fsck is recommended kjournald starting. Commit interval 5 seconds EXT3-fs (sda2): using internal journal EXT3-fs (sda2): recovery complete EXT3-fs (sda2): mounted filesystem with writeback data mode VFS: Mounted root (ext3 filesystem) on device 8:2. Freeing init memory: 128K Warning: unable to open an initial console. EXT3-fs (sda2): warning: checktime reached, running e2fsck is recommended EXT3-fs (sda2): using internal journal It is now possible to log into the Debian system by using a ssh client. By default, the root password is empty. simon@X31:~/work/lacie/src/clunc$ ssh root@192.168.0.19 The authenticity of host '192.168.0.19 (192.168.0.19)' can't be established. RSA key fingerprint is 41:4a:3d:87:4c:b1:9c:e5:fc:2a:67:c0:a0:a1:78:0a. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added '192.168.0.19' (RSA) to the list of known hosts. Last login: Wed Sep 24 17:42:54 UTC 1930 from 192.168.0.14 on pts/0 Linux sid-arm 2.6.33-rc6-00217-g4e4a8c1-svn #3 PREEMPT Fri Feb 5 15:46:12 CET 2010 armv5tel The programs included with the Debian GNU/Linux system are free software; the exact distribution terms for each program are described in the individual files in /usr/share/doc/*/copyright. Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law. root@sid-arm:~# uname -a Linux sid-arm 2.6.33-rc6-00217-g4e4a8c1-svn #3 PREEMPT Fri Feb 5 15:46:12 CET 2010 armv5tel GNU/Linux It might be a very good idea to set a password for root, as leaving a passwordless root access to your device is probably not what you want. ===== Troubleshooting ===== * CLUNC doesn't display the kernel console message: check that the clunc target IP and the netconsole source IP are the same. An utility like tcpdump could provide useful debugging information. Perhaps you have plug the ethernet cable in the wrong slot, and the kernel assign an ip address to the other one. * U-Boot fails to scan the USB bus: retry. * How to get the system IP ? use a tool like dhcpdump or set the NAS IP by configuring your dhcp server. * rootfs not found: the SCSI device name for USB key depends on a lots of parameters. On the majority of LaCie products the kernel command line argument "''root=/dev/sda2''" should be correct. But possibly you will have to turn this into "''root=/dev/sdb2''". ===== TODO ===== Set the U-Boot parameters at each USB boot attempt is quite boring. Provide an U-Boot image with no hardcoded boot parameters could be very smart.