Linksys Network Storage NSLU2
De MicElectroLinGenMet.
Sommaire |
Description
Le Linksys NSLU2 permet de transformer n'importe quel disque dur externe USB 2.0 en serveur de fichiers autonome accessible depuis le réseau.
Passer son utilisation de base, il faut savoir qu'il y a une petite communauté autour du NSLU2 (liste de diffusion).
Le NSLU2 étant basé sur Linux et Samba, des développeurs (nslu2-linux.org) ont fourni un meilleur firmware que celui de Linksys, soit en améliorant celui de Linksys, soit en en créant un nouveau.
- Caractéristiques matériel:
Vue de l'intérieure:
Le plus interressant étant le portage Debian sur cette machine.
Installation Debian/NSLU2
Source: http://slugplayer.free.fr/wikini/wakka.php?wiki=DebianInstallerRC1
- Télécharger firmware DebianInstaller du nslu2
Dernière version de l'image DebianInstaller sur http://www.slug-firmware.net/d-dls.php
- Décompression
Décompresser le zip téléchargé.
unzip debian-etch-rc1-20061102.zip
Le fichier ZIP contient deux fichiers :
- Le fichier de licence
- di-nslu2.bin : Le firmware contenant DebianInstaller
- Démarrage du Slug en mode mise à jour de firmware
- Débrancher le disque
- Appuyer sur le bouton reset avec un trombone et ne pas le relâcher
- Démarrer le Slug en appuyant sur le bouton Power
Le slug démarre.
Les leds s'allument.
La led Power passe en orange
Dès qu'elle passe au rouge, relâcher le bouton Reset.
Le led Power passe au vert/rouge clignottant.
Le Slug est alors en attente de mise à jour de son firmware.
- Mise à jour du firmware
Passer en root sur le système a partir duquel on reflashera le Slug
Lancer la commande de mise à jour du Slug
UPSLUG2 est un outil permettant de mettre à jour le firmware du slug à partir d'une hôte Linux (package existant sous Debian).
# upslug2 -i di-nslu2.bin
Des barres de progression apparaissent dans la console, indiquant tout d'abord la progression de l'écriture sur la mémoire flash du Slug, puis la phase de vérification.
Une fois la mise à jour terminée, le Slug rédémarre automatiquement.
reboot auto Rebooting... done
Quand la led Ethernet s'eteint, le slug est alors en cours de redémarrage, il faut alors le débrancher électriquement.
- Démarrage du Slug sur le firmware DebianInstaller
- Brancher le disque/clef usb
- Allumer le Slug
Deux minutes plus tard, le Slug commence à répondre au ping. Quatre minutes plus tard, il est possible d'ouvrir une connexion SSH sur le Slug.
Pour accèder à l'assistant DebianInstaller, il suffit d'ouvrir une connexion SSH sur le Slug, en se connectant avec l'utilisateur installer (mot de passe : install).
ssh installer@nslu (@Ip DHCP ou 192.168.1.77)
- Suivre la procedure d'install. (identique à une install. Debian classique)
Sélectionner les composants devant être chargé par DebianInstaller :
ext3-modules-2.6.17-2-ixp4xx-di: EXT3 filesystem support partman-auto: Automatically partition storage devices (partman) partman-ext3: Add to partman support for ext3 scsi-core-modules-2.6.17-2-ixp4xx-di: Core SCSI subsystem usb-storage-modules-2.6.17-2-ixp4xx-di: USB storage support
Problème: L'installation s'arréte avec coupure de la connexion ssh lors de la création des partition => manque de mémoire !
J'ai créé les partion manuellement (surtout la swap) sur la clef à partir du PC avant de réssayer une 3ième fois.
Découverte du système
Première connection
Linux nslu2 2.6.18-4-ixp4xx #1 Tue Mar 27 18:01:56 BST 2007 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. No mail. Last login: Sun Jun 3 16:17:16 2007 from vesta dan@nslu2:~$ date Tue Jun 5 15:09:27 CEST 2007 dan@nslu2:~$
Nom de machine
dan@nslu2:~$ uname -a Linux nslu2 2.6.18-4-ixp4xx #1 Tue Mar 27 18:01:56 BST 2007 armv5tel GNU/Linux
Type de processeur
dan@nslu2:~$ cat /proc/cpuinfo Processor : XScale-IXP42x Family rev 1 (v5l) BogoMIPS : 132.71 Features : swp half fastmult edsp CPU implementer : 0x69 CPU architecture: 5TE CPU variant : 0x0 CPU part : 0x41f CPU revision : 1 Cache type : undefined 5 Cache clean : undefined 5 Cache lockdown : undefined 5 Cache format : Harvard I size : 32768 I assoc : 32 I line length : 32 I sets : 32 D size : 32768 D assoc : 32 D line length : 32 D sets : 32 Hardware : Linksys NSLU2 Revision : 0000 Serial : 0000000000000000
Mémoire
Seulement 32Mo de RAM.
dan@nslu2:~$ free
total used free shared buffers cached
Mem: 29988 26308 3680 0 356 10896
-/+ buffers/cache: 15056 14932
Swap: 136544 3660 132884
Messages au boot
Linux version 2.6.18-4-ixp4xx (Debian 2.6.18.dfsg.1-12etch2) (dannf@debian.org) (gcc version 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)) #1 Sun Apr 22 08:34:11 UTC 2007 CPU: XScale-IXP42x Family [690541f1] revision 1 (ARMv5TE), cr=0000397f Machine: Linksys NSLU2 Memory policy: ECC disabled, Data cache writeback On node 0 totalpages: 8192 DMA zone: 8192 pages, LIFO batch:1 CPU0: D VIVT undefined 5 cache CPU0: I cache: 32768 bytes, associativity 32, 32 byte lines, 32 sets CPU0: D cache: 32768 bytes, associativity 32, 32 byte lines, 32 sets Built 1 zonelists. Total pages: 8192 Kernel command line: console=ttyS0,115200 rtc-x1205.probe=0,0x6f noirqdebug IRQ lockup detection disabled PID hash table entries: 256 (order: 8, 1024 bytes) Console: colour dummy device 80x30 Dentry cache hash table entries: 4096 (order: 2, 16384 bytes) Inode-cache hash table entries: 2048 (order: 1, 8192 bytes) Memory: 32MB = 32MB total Memory: 25780KB available (1948K code, 496K data, 92K init) Calibrating delay loop... 132.71 BogoMIPS (lpj=663552) Security Framework v1.0.0 initialized SELinux: Disabled at boot. Capability LSM initialized Mount-cache hash table entries: 512 CPU: Testing write buffer coherency: ok checking if image is initramfs... it is Freeing initrd memory: 4096K NET: Registered protocol family 16 IXP4xx: Using 16MiB expansion bus window size PCI: IXP4xx is host PCI: IXP4xx Using direct access for memory space PCI: bus0: Fast back to back transfers disabled dmabounce: registered device 0000:00:01.0 on pci bus dmabounce: registered device 0000:00:01.1 on pci bus dmabounce: registered device 0000:00:01.2 on pci bus NET: Registered protocol family 2 IP route cache hash table entries: 256 (order: -2, 1024 bytes) TCP established hash table entries: 1024 (order: 0, 4096 bytes) TCP bind hash table entries: 512 (order: -1, 2048 bytes) TCP: Hash tables configured (established 1024 bind 512) TCP reno registered NetWinder Floating Point Emulator V0.97 (double precision) audit: initializing netlink socket (disabled) audit(7.500:1): initialized VFS: Disk quotas dquot_6.5.1 Dquot-cache hash table entries: 1024 (order 0, 4096 bytes) JFFS2 version 2.2. (NAND) (C) 2001-2006 Red Hat, Inc. Initializing Cryptographic API io scheduler noop registered io scheduler anticipatory registered io scheduler deadline registered io scheduler cfq registered (default) IXP4xx Watchdog Timer: heartbeat 60 sec Serial: 8250/16550 driver $Revision: 1.90 $ 2 ports, IRQ sharing disabled serial8250.0: ttyS0 at MMIO 0xc8000000 (irq = 15) is a XScale serial8250.0: ttyS1 at MMIO 0xc8001000 (irq = 13) is a XScale RAMDISK driver initialized: 16 RAM disks of 8192K size 1024 blocksize IXP4XX-Flash.0: Found 1 x16 devices at 0x0 in 16-bit bank IXP4XX-Flash.0: Found an alias at 0x800000 for the chip at 0x0 Intel/Sharp Extended Query Table at 0x0031 Using buffer write method cfi_cmdset_0001: Erase suspend on write enabled erase region 0: offset=0x0,size=0x20000,blocks=64 Searching for RedBoot partition table in IXP4XX-Flash.0 at offset 0x7e0000 6 RedBoot partitions found on MTD device IXP4XX-Flash.0 Creating 6 MTD partitions on "IXP4XX-Flash.0": 0x00000000-0x00040000 : "RedBoot" NSLU2 MAC: 00:14:bf:65:a6:52 0x00040000-0x00060000 : "SysConf" 0x00060000-0x00080000 : "Loader" 0x00080000-0x001e0000 : "Kernel" 0x001e0000-0x007e0000 : "Ramdisk" 0x007e0000-0x00800000 : "FIS directory" mice: PS/2 mouse device common for all mice i2c /dev entries driver x1205 0-006f: chip found, driver version 1.0.7 x1205 0-006f: rtc core: registered x1205 as rtc0 Registered led device: ready Registered led device: status Registered led device: disk-1 Registered led device: disk-2 NET: Registered protocol family 26 TCP bic registered NET: Registered protocol family 1 NET: Registered protocol family 17 Time: OSTS clocksource has been installed. x1205 0-006f: setting the system clock to 2008-02-09 12:34:10 (1202560450) Freeing init memory: 92K usbcore: registered new driver usbfs usbcore: registered new driver hub ohci_hcd: 2005 April 22 USB 1.1 'Open' Host Controller (OHCI) Driver (PCI) PCI: enabling device 0000:00:01.0 (0140 -> 0142) ohci_hcd 0000:00:01.0: OHCI Host Controller ohci_hcd 0000:00:01.0: new USB bus registered, assigned bus number 1 ohci_hcd 0000:00:01.0: irq 28, io mem 0x48000000 usb usb1: configuration #1 chosen from 1 choice hub 1-0:1.0: USB hub found hub 1-0:1.0: 3 ports detected PCI: enabling device 0000:00:01.1 (0140 -> 0142) ohci_hcd 0000:00:01.1: OHCI Host Controller ohci_hcd 0000:00:01.1: new USB bus registered, assigned bus number 2 ohci_hcd 0000:00:01.1: irq 27, io mem 0x48001000 usb usb2: configuration #1 chosen from 1 choice hub 2-0:1.0: USB hub found hub 2-0:1.0: 2 ports detected PCI: enabling device 0000:00:01.2 (0140 -> 0142) ehci_hcd 0000:00:01.2: EHCI Host Controller ehci_hcd 0000:00:01.2: new USB bus registered, assigned bus number 3 ehci_hcd 0000:00:01.2: irq 26, io mem 0x48002000 ehci_hcd 0000:00:01.2: USB 2.0 started, EHCI 1.00, driver 10 Dec 2004 usb usb3: configuration #1 chosen from 1 choice hub 3-0:1.0: USB hub found hub 3-0:1.0: 5 ports detected usb 3-1: new high speed USB device using ehci_hcd and address 2 usb 3-1: configuration #1 chosen from 1 choice SCSI subsystem initialized usb 3-2: new high speed USB device using ehci_hcd and address 3 Initializing USB Mass Storage driver... usb 3-2: configuration #1 chosen from 1 choice hub 3-2:1.0: USB hub found hub 3-2:1.0: 4 ports detected scsi0 : SCSI emulation for USB Mass Storage devices usb-storage: device found at 2 usb-storage: waiting for device to settle before scanning usb 3-2.2: new full speed USB device using ehci_hcd and address 4 usb 3-2.2: configuration #1 chosen from 1 choice usb 3-2.3: new full speed USB device using ehci_hcd and address 5 usb 3-2.3: configuration #1 chosen from 1 choice usbcore: registered new driver usb-storage USB Mass Storage support registered. Vendor: Ut163 Model: USB2FlashStorage Rev: 0.00 Type: Direct-Access ANSI SCSI revision: 02 usb-storage: device scan complete SCSI device sda: 1974271 512-byte hdwr sectors (1011 MB) sda: Write Protect is off sda: Mode Sense: 00 00 00 00 sda: assuming drive cache: write through SCSI device sda: 1974271 512-byte hdwr sectors (1011 MB) sda: Write Protect is off sda: Mode Sense: 00 00 00 00 sda: assuming drive cache: write through sda: sda1 sda2 sd 0:0:0:0: Attached scsi removable disk sda input: ixp4xx beeper as /class/input/input0 swapped image found Image loaded to NPE-B Func:0, Rel: 2:1, Status: 82800000 IXP4XX NPE driver Version 0.3.0 initialized IXP4XX Q Manager 0.2.1 initialized. ixp4xx_mac driver 0.3.1: eth0 on NPE-B with PHY[1] initialized Adding 136544k swap on /dev/sda2. Priority:-1 extents:1 across:136544k x1205 0-006f: rtc intf: dev (254:0) device-mapper: ioctl: 4.7.0-ioctl (2006-06-24) initialised: dm-devel@redhat.com eth0: link up, 100Mbps, full-duplex, lpa 0x41E1 Link of eth0 is full-duplex NET: Registered protocol family 10 lo: Disabled Privacy Extensions IPv6 over IPv4 tunneling driver process `syslogd' is using obsolete setsockopt SO_BSDCOMPAT eth0: no IPv6 routers present
Configuration du système
Modification système
Limitation de l'écriture sur la clef USB sur le lequel tourne le système.
- File système formaté en ext2
Pas d'écriture généré par les journaux en ext3.
- Montage de root avec option noatime
Pas de modification de la date d'accés des fichier à chaque lecture.
nslu2:~# mount /dev/sda1 on / type ext2 (rw,noatime,errors=remount-ro)
- Déplacement du répertoire de log
nslu2:~# l /var total 44K drwxr-xr-x 2 root root 4,0K 2008-02-10 06:25 backups/ drwxr-xr-x 6 root root 4,0K 2007-06-03 03:22 cache/ drwxr-xr-x 20 root root 4,0K 2008-02-09 11:38 lib/ drwxrwsr-x 2 root staff 4,0K 2006-10-30 19:02 local/ drwxrwxrwt 3 root root 4,0K 2008-02-09 13:35 lock/ lrwxrwxrwx 1 root root 8 2008-02-09 13:31 log -> /dev/shm/ drwxrwsr-x 2 root mail 4,0K 2007-06-03 09:56 mail/ drwxr-xr-x 2 root root 4,0K 2007-06-03 01:05 opt/ drwxr-xr-x 5 root root 4,0K 2008-02-11 00:07 run/ drwxr-xr-x 4 root root 4,0K 2007-06-05 17:39 spool/ drwxrwxrwt 2 root root 4,0K 2008-02-09 10:10 tmp/ drwxr-xr-x 4 www-data www-data 4,0K 2007-10-27 10:33 www/
Le device /dev/shm est un file system monté en RAM (ne consomme de la RAM qu'en fonction du contenu).
nslu2:~# free
total used free shared buffers cached
Mem: 29988 26384 3604 0 384 11120
-/+ buffers/cache: 14880 15108
Swap: 136544 3660 132884
nslu2:~# df -h Sys. de fich. Tail. Occ. Disp. %Occ. Monté sur /dev/sda1 811M 422M 349M 55% / tmpfs 15M 0 15M 0% /lib/init/rw udev 10M 40K 10M 1% /dev tmpfs 15M 4,2M 11M 29% /dev/shm
Configurer logrotate pour y faire le ménage régulièrement.
Utilisation
- open2300 sur nslu2
Station météo Ws2300 géré par le nslu2.
Utilisation d'un adaptateur USB/serie:
dan@nslu2:~$ lsusb Bus 002 Device 001: ID 0000:0000 Bus 003 Device 005: ID 067b:2303 Prolific Technology, Inc. PL2303 Serial Port Bus 003 Device 002: ID 1307:0163 Bus 003 Device 003: ID 05e3:0606 Genesys Logic, Inc. Bus 003 Device 001: ID 0000:0000 Bus 001 Device 001: ID 0000:0000
- Mysql
Adapter MySQL au NSLU2 Source: http://blog.fabroce.info/post/2007/02/04/Adapter-MySQL-au-NSLU2
Abandon de l'utilisation de mySql sous le nslu2. Trop lent à répondre avec une base météo de 2000000 enregistrements !!!
- Dropbear
Remplacer SSH par Dropbear
Le binaire dropbear est moins lourd en occupation mémoire/cpu que Openssh.
Pour remplacer Openssh, installer le package telnetd
ii telnetd 0.17-34 The telnet server
se connecter en telnet, désinstaller Openssh et installer dropbear.
J'ai du laisser le package openssh-client pour conserver les commandes clientes ssh,scp ...
- lighttpd
Serveur Web moins lourd que Apache.
Le package php5-cgi permet de faire du php avec lighttpd.
Hacks
OverClockTheSlug
Fréquence CPU aprés suppression résistance comme indiqué dans le HowTo nslu2-linux.org 133MHz => 266MHz :
dan@nslu2:~$ cat /proc/cpuinfo Processor : XScale-IXP42x Family rev 1 (v5l) BogoMIPS : 266.24 Features : swp half fastmult edsp CPU implementer : 0x69 CPU architecture: 5TE CPU variant : 0x0 CPU part : 0x41f CPU revision : 1 Cache type : undefined 5 Cache clean : undefined 5 Cache lockdown : undefined 5 Cache format : Harvard I size : 32768 I assoc : 32 I line length : 32 I sets : 32 D size : 32768 D assoc : 32 D line length : 32 D sets : 32 Hardware : Linksys NSLU2 Revision : 0000 Serial : 0000000000000000
AddASerialPort
http://www.nslu2-linux.org/wiki/HowTo/AddASerialPort
NSLU2 I²C Interface
http://www.staton.us/electronics/open_slug/i2c_interface.html
Divers
- Utilisation du bouton Power
Par défaut, le bouton Power redémarre le slug. Il est possible d'utiliser ce bouton pour l'arrêter :
Editer le fichier /etc/inittab Remplacer la ligne
ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -r now
par
ca:12345:ctrlaltdel:/sbin/shutdown -h now
- Gérer les leds
Voir la commande leds:
nslu2:~# leds
leds: change the setting of the LEDs
usage:
leds [boot] system|user|singleuser|shutdown [error|panic|*]
set leds during system boot to indicate a particular boot
state. 'boot' means that the system is transitioning to
the new state. 'error' or 'panic' means a (potentially)
recoverable error or an unrecoverable error ('panic') has
occured.
<led> off|on|slow|fast|panic|blink|flash|user|cpu|cpu-idle
set the named led to the given display, an arbitrary led
trigger may be given.
beep {args}
if possible cause the machine to emit a beep
Exemples:
nslu2:~# leds disk-2 slow nslu2:~# leds disk-2 fast nslu2:~# leds disk-2 panic nslu2:~# leds disk-2 blink nslu2:~# leds disk-2 flash nslu2:~# leds disk-2 user nslu2:~# leds disk-2 cpu-idle nslu2:~# leds disk-2 off nslu2:~# leds beep
Autre exemple permettant de vérifier que le nslu2 est toujours en vie:
while sleep 1 ; do leds disk-2 on ; sleep 1 ;leds disk-2 off ; done &
Toutes les secondes la led disk-2 clignote.
nslu2:~# ls -l /sys/class/leds/ total 0 drwxr-xr-x 2 root root 0 Jun 3 01:35 disk-1 drwxr-xr-x 2 root root 0 Jun 3 18:53 disk-2 drwxr-xr-x 2 root root 0 Jun 3 18:50 ready drwxr-xr-x 2 root root 0 Jun 3 18:50 status
- Commander le beeper
Installation package beep:
# apt-get install beep
Test de la commande:
# beep -e /dev/input/event0 -f 800 -l 500 -r 2 -d 300
Script beep au boot et shutdown (source: http://www.nslu2-linux.org/wiki/HowTo/BeepMelodies)
- Automatically Reboot on Panic
(http://www.nslu2-linux.org/wiki/HowTo/AutoRebootOnPanic)
Liens internet
- Page principale sur le nslu2/Linux: NSLU2-Linux
http://www.nslu2-linux.org/wiki/Main/HomePage
NSLU2-Linux - Debian / HomePage browse
http://www.nslu2-linux.org/wiki/Debian/HomePage
- Méthodes install Debian:
SlugPlayer For NSLU2 DebianInstallerRC1
http://slugplayer.free.fr/wikini/wakka.php?wiki=DebianInstallerRC1 (methode utilisé)
Installing Debian on the Linksys NSLU2
http://www.cyrius.com/debian/nslu2/install.html
Debian GNU/Linux sur le NSLU2 : Debian slug
http://blog.fabroce.info/post/2006/10/07/30-debian-gnu-linux-sur-le-nslu2
