Differences

This shows you the differences between the selected revision and the current version of the page.

howto:install_debian 2008/04/07 02:22 howto:install_debian 2017/12/04 17:26 current
Line 1: Line 1:
-STToVB &lt;a href="http://kkamypzguiar.com/">kkamypzguiar</a>, [url=http://hhvphhhdjxxc.com/]hhvphhhdjxxc[/url], [link=http://nnlmfkrvsbzi.com/]nnlmfkrvsbzi[/link], http://iuqdypydphrw.com/+**WARNING**: This procedure is horrible. For a &quot;real" native Debian installation, take a look at http://www.cyrius.com/debian/orion/d-link/dns-323/install.html . 
 + 
 +This page described how to get Debian natively running on your 
 +DNS-323. 
 + 
 +NOTE: If you follow this procedure, the DNS-323 will no longer run its 
 +normal operation.  It will only run debian.  The function can be restored, 
 +details at the end. 
 + 
 +NOTE2: You can brick your unit if you are not careful, and maybe even 
 +if you are careful.  As long as you don't overwrite the mtdblock4 
 +device, you *should* be able to recover your system, but this 
 +procedure has not been well tested.  MAKE SURE to save off your old 
 +MTD devices someplace safe so you can restore them if necessary. 
 + 
 +You will need: 
 + 
 +  * A DNS-323 with a serial port as described in [[hardware:serial]].  You must upgrade the firmware to 1.03 
 +  * A running Debian system 
 +  * Fast Internet access (not strictly required, but very helpful) 
 +  * Running kermit from http://www.columbia.edu/kermit (On debian just execute apt-get install ckermit and use the command kermit without the path to the executable).  Note that you can use minicom, but you will not be able to transfer kernels to uboot later if you don't have it. 
 + 
 +You need a minimal debian image installed on a machine that can act as 
 +an NFS server.  You can get http://dev.skcserver.de/dns323/etch.tar, I 
 +think, but I have not tried it.  This is a full minimal image, but I'm 
 +going to document using cdebootstrap, though, since the above link may 
 +go away and this is more general.  You need an existing debian system 
 +to do this, and you need root access and need to be logged in as root. 
 + 
 +<code> 
 +i2:~# apt-get install cdebootstrap 
 +Reading package lists... Done 
 +Building dependency tree... Done 
 +cdebootstrap is already the newest version. 
 +0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded. 
 +(Note - I already had this installed) 
 +i2:~# mkdir dns 
 +i2:~# cd dns 
 +i2:~/dns# cdebootstrap -aarm --foreign etch etch ftp://ftp.us.debian.org/debian 
 +P: Retrieving Release.gpg 
 +P: Retrieving Release 
 +P: Parsing Release 
 +P: Retrieving Release 
 +
 +
 +
 +P: Extracting util-linux 
 +P: Writing hosts 
 +P: Writing resolv.conf 
 +I: Second stage installer is available as /sbin/cdebootstrap-foreign or /sbin/init 
 +</code> 
 + 
 +The "--foreign" option tell cdebootstrap to only perform unpacking action of the needed packages. All the operations that need to be executed on the destination machine will be executed after the first booting by executing the "fake" init. 
 + 
 + 
 +Now create the rtc and ttyS0 devices as to prevent some errors 
 + 
 +<code> 
 +i2:~# cd etch/dev 
 +i2:~/dns/etch/dev# MAKEDEV rtc 
 +i2:~/dns/etch/dev# mknod ttyS0 c 4 64 
 +</code> 
 + 
 +Set up fstab: 
 + 
 +<code> 
 +i2:~/dns/etch/etc# vi fstab 
 +</code> 
 + 
 +Let's use: 
 + 
 +<file> 
 +# <file system> <mount point>          <type>  <options>    <dump>  <pass> 
 +#/dev/sda1      none                    swap    sw              0      0 
 +#/dev/sdb1      none                    swap    sw              0      0 
 +proc            /proc                  proc    defaults        0      0 
 +#/dev/md0        /                      ext3    defaults        0      2 
 +</file> 
 + 
 +You can add other stuff later, but that will be enough to get you 
 +going.  We will uncomment these once we get them on the disk. 
 + 
 +And prepare the nfs export 
 + 
 +<code> 
 +i2:~/dns/etch# vi /etc/exports 
 +</code> 
 + 
 +Add the following to /etc/exports: 
 +<code> 
 +/root/dns/etch *(rw,no_root_squash,sync,subtree_check) 
 +</code> 
 + 
 +Now let other mount it through NFS: 
 +<code> 
 +i2:~/dns/etch# exportfs -r 
 +</code> 
 + 
 +Now you will be able to mount the root filesystem.  The default kernel 
 +on the dns-323 is able to mount an NFS filesystem.  Now let's hook to 
 +the serial port.  Mine is on /dev/ttyS0, but it depends on where you 
 +have it plugged in. 
 + 
 +<code> 
 +root@desk:~# ~cminyard/kermit -l /dev/ttyS0 -b 115200 
 +C-Kermit 8.0.209, 17 Mar 2003, for Linux 
 + Copyright (C) 1985, 2003, 
 +  Trustees of Columbia University in the City of New York. 
 +Type ? or HELP for help. 
 +(/root/) C-Kermit>set carrier-watch off 
 +(/root/) C-Kermit>c 
 +Connecting to /dev/ttyS0, speed 115200 
 + Escape character: Ctrl-\ (ASCII 28, FS): enabled 
 +Type the escape character followed by C to get back, 
 +or followed by ? to see other options. 
 +---------------------------------------------------- 
 +</code> 
 + 
 +Note: Before to connect correctly to the nas, i need to execute on the kermit command line these two command, "set flow xon/xoff" and "set stop-bits 1". Personally i prefer minicom as you don't need kermit if you dont'have to upload a binary file, and minicom give me less difficulties than kermit. 
 + 
 +Now power the system on, and quickly type the space then "1" keys. 
 +This will fall into uboot.  Then we will boot on the NFS partition we 
 +just created and exported.  Substitute your IP address with the one I 
 +use. 
 + 
 +<code> 
 + ** LOADER ** 
 + ** MARVELL BOARD: RD-88F5181-POS-NAS LE 
 + 
 +U-Boot 1.1.1 (Nov 13 2006 - 14:01:34) Marvell version: 1.4.2 
 + 
 +DRAM CS[0] base 0x00000000  size  64MB 
 +DRAM Total size  64MB 
 +[8192kB@ff800000] Flash:  8 MB 
 +Addresses 20M - 0M are saved for the U-Boot usage. 
 +Mem malloc Initialization (20M - 16M): Done 
 +*** Warning - bad CRC, using default environment 
 + 
 + 
 +Soc: MV88F5181 Rev 3 
 +CPU: ARM926 (Rev 0) running @ 500Mhz 
 +SysClock = 166Mhz , TClock = 166Mhz 
 + 
 + 
 + Init usb device. 
 +PCI 0: PCI Express Root Complex Interface 
 +PCI 1: Conventional PCI, speed = 33000000 
 +Hit any key to stop autoboot:  0 
 +Marvell>> 
 +</code> 
 + 
 +Boot the thing using NFS. 
 + 
 +<code> 
 +Marvell>>setenv bootargs root=/dev/nfs nfsroot=192.168.27.126:/root/dns/etch ip=dhcp console=ttyS0,115200 
 +Marvell>> bootm FF820000 
 +## Booting image at ff820000 ... 
 +  Image Name:  Linux-2.6.12.6-arm1 
 +  Image Type:  ARM Linux Kernel Image (uncompressed) 
 +  Data Size:    1518100 Bytes =  1.4 MB 
 +  Load Address: 00008000 
 +  Entry Point:  00008000 
 +  Verifying Checksum ... OK 
 +OK 
 + 
 +Starting kernel ... 
 + 
 +Uncompressing Linux..................................................................................................... done, booting the kernel. 
 +Linux version 2.6.12.6-arm1 (cminyard@i2) (gcc version 3.3.3) #7 Sat Sep 8 18:42:37 CDT 2007 
 +CPU: ARM926EJ-Sid(wb) [41069260] revision 0 (ARMv5TEJ) 
 +CPU0: D VIVT write-back cache 
 +CPU0: I cache: 32768 bytes, associativity 1, 32 byte lines, 1024 sets 
 +CPU0: D cache: 32768 bytes, associativity 1, 32 byte lines, 1024 sets 
 +Machine: MV-88fxx81 
 +Using UBoot passing parameters structure 
 +Sys Clk = 166000000, Tclk = 166000000 
 + 
 + 
 +- Warning - This LSP release was tested only with U-Boot release 1.7.3 
 + 
 +Memory policy: ECC disabled, Data cache writeback 
 +Built 1 zonelists 
 +Kernel command line: root=/dev/nfs nfsroot=192.168.27.126:/root/dns/etch ip=dhcp console=ttyS0,115200 
 +
 +
 +
 +IP-Config: Got DHCP answer from 0.0.0.0, my address is 192.168.27.54 
 +IP-Config: Complete: 
 +      device=egiga0, addr=192.168.27.54, mask=255.255.255.0, gw=192.168.27.254, 
 +    host=192.168.27.54, domain=minyard.local, nis-domain=(none), 
 +    bootserver=0.0.0.0, rootserver=192.168.27.126, rootpath= 
 +md: Autodetecting RAID arrays. 
 +md: autorun ... 
 +md: ... autorun DONE. 
 +Looking up port of RPC 100003/2 on 192.168.27.126 
 +Looking up port of RPC 100005/1 on 192.168.27.126 
 +VFS: Mounted root (nfs filesystem).                                                   
 +Freeing init memory: 112K                                                             
 +Adding `local diversion of /sbin/init to /sbin/init.REAL'                             
 +tar: ./postinst: time stamp 2007-01-07 12:14:28 is 212388557.923672 s in the future   
 +tar: ./preinst: time stamp 2007-01-07 12:14:28 is 212388557.863465 s in the future   
 +</code> 
 + 
 +If the device is new and you never have set the clock, you will probably have some little problem due to a wrong clock setting. If not, just don't execute the related command. 
 + 
 +Now check frequently in "dns/etch/etc" if the file inittab as been extracted, and as soon as you find it edit the file as follow 
 + 
 +<code> 
 +i2:~/dns/etch/etc# vi inittab 
 +</code> 
 + 
 +Find the line that says: 
 +<code> 
 +#T0:23:respawn:/sbin/getty -L ttyS0 9600 vt100 
 +</code> 
 + 
 +and turn it into: 
 +<code> 
 +T0:23:respawn:/sbin/getty -L ttyS0 115200 vt100 
 +</code> 
 + 
 +Wait until cdebootstrap have terminated it's work. This will take some times. 
 + 
 +<code> 
 +Removing `local diversion of /sbin/init to /sbin/init.REAL' 
 +INIT: version 2.86 booting 
 +Activating swap...done. 
 +Setting the system clock.. 
 +Cleaning up ifupdown.... 
 +Loading kernel modules...FATAL: Could not load /lib/modules/2.6.12.6-arm1/modules.dep: No such file or directory 
 +Loading device-mapper support. 
 +Checking file systems...fsck 1.40-WIP (14-Nov-2006) 
 +done. 
 +Setting kernel variables...done. 
 +Mounting local filesystems...done. 
 +Activating swapfile swap...done. 
 +Setting up networking.... 
 +Configuring network interfaces...done. 
 +INIT: Entering runlevel: 2 
 +Starting system log daemon: syslogd. 
 +Starting kernel log daemon: klogd. 
 +* Not starting internet superserver: no services enabled. 
 +Starting periodic command scheduler: crond. 
 + 
 +Debian GNU/Linux 4.0 lynk ttyS0 
 + 
 +lynk login: 
 +</code> 
 + 
 +If you modify "inittab" too late you will not find the login prompt, and you'll have to repeat the boot process. Only the boot process using the same method as before, getting the u-boot prompt and setting the bootargs variable. 
 + 
 +When you get the login prompt login as "root", and first of all set the clock to an acceptable date. 
 + 
 +<code> 
 +192:~# date --set 2008-10-17 
 +</code> 
 + 
 +Create the remaining needed devices 
 + 
 +<code> 
 +192:~# cd /dev 
 +192:/dev# MAKEDEV generic-arm 
 +192:/dev# MAKEDEV md 
 +</code> 
 + 
 +These following for the flash driver.  You really do not want to 
 +overwrite mtdblock4, since that is uboot, so we make it read-only.  As 
 +long as you have a serial port and uboot, you can recover the device. 
 + 
 +<code> 
 +192:/dev# mknod mtdblock0 b 31 0 
 +192:/dev# mknod mtdblock1 b 31 1 
 +192:/dev# mknod mtdblock2 b 31 2 
 +192:/dev# mknod mtdblock3 b 31 3 
 +192:/dev# mknod mtdblock4 b 31 4 
 +192:/dev# chmod 660 mtdblock* 
 +192:/dev# chmod 440 mtdblock4 
 +</code> 
 + 
 +Now we need to save off the old MTD files, in case we need to restore 
 +them later. 
 + 
 +<code> 
 +192:# cd /root/ 
 +192:# mkdir oldmtd 
 +192:# cd oldmtd/ 
 +192# dd if=/dev/mtdblock0 of=mtd0 
 +128+0 records in 
 +128+0 records out 
 +65536 bytes (66 kB) copied, 0.076184 seconds, 860 kB/s 
 +192:# dd if=/dev/mtdblock1 of=mtd1 
 +128+0 records in 
 +128+0 records out 
 +65536 bytes (66 kB) copied, 0.076254 seconds, 859 kB/s 
 +192:# dd if=/dev/mtdblock2 of=mtd2 
 +3072+0 records in 
 +3072+0 records out 
 +1572864 bytes (1.6 MB) copied, 1.71174 seconds, 919 kB/s 
 +192:# dd if=/dev/mtdblock3 of=mtd3 
 +12672+0 records in 
 +12672+0 records out 
 +6488064 bytes (6.5 MB) copied, 6.89164 seconds, 941 kB/s 
 +192:# dd if=/dev/mtdblock4 of=mtd4 
 +384+0 records in 
 +384+0 records out 
 +196608 bytes (197 kB) copied, 0.214457 seconds, 917 kB/s 
 +</code> 
 + 
 +The most interesting ones are mtd2 (kernel) and mtd3 (filesystem) Now 
 +save off the old filesystem.  You will need some files from it later. 
 +It's in a uboot image, so we have to play around a little to extract 
 +it. 
 + 
 +<code> 
 +192:# cd .. 
 +192:# dd if=oldmtd/mtd3 of=olddnsfs.gz bs=64 skip=1 
 +101375+0 records in 
 +101375+0 records out 
 +6488000 bytes (6.5 MB) copied, 6.6507 seconds, 976 kB/s 
 +192:# gzip -d olddnsfs.gz 
 + 
 +gzip: olddnsfs.gz: decompression OK, trailing garbage ignored 
 +192:# mount -o loop olddnsfs /mnt/ 
 +EXT2-fs warning: mounting unchecked fs, running e2fsck is recommended 
 +192:# mkdir dns323-oldfs 
 +192:# cp -a /mnt/* dns323-oldfs/ 
 +192:# umount /mnt 
 +</code> 
 + 
 +First get the mac_read command so we can properly set our MAC address: 
 + 
 +<code> 
 +192:~# cd dns323-oldfs/ 
 +192:~/dns323-oldfs# mount -o loop image.cfs /mnt 
 +192:~/dns323-oldfs# cp /mnt/sbin/mac_read /usr/local/sbin/ 
 +192:~/dns323-oldfs# chmod +x /usr/local/sbin/mac_read 
 +192:~/dns323-oldfs# cp ~/dns323-oldfs/lib/ld-uClibc.so.0 /lib 
 +192:~/dns323-oldfs# cp ~/dns323-oldfs/lib/libc.so.0 /lib 
 +192:~/dns323-oldfs# chmod +x /lib/ld-uClibc.so.0 
 +192:~/dns323-oldfs# chmod +x /lib/libc.so.0 
 +</code> 
 + 
 +Now set up networking: 
 + 
 +<code> 
 +192:~# cd /etc/network 
 +192:/etc/network# vi interfaces 
 +</code> 
 + 
 +The exact format of the interfaces file depends on your configuration. 
 +Let's use: 
 + 
 +<file> 
 +auto lo 
 +#auto lo egiga0 
 + 
 +iface lo inet loopback 
 + 
 +iface egiga0 inet dhcp 
 +        pre-up /usr/local/sbin/mac_read 
 +</file> 
 + 
 +We'll replace the first line with the commented out line later, so it 
 +won't mess you up if you reboot.  We won't start it up yet, we'll 
 +wait, as it will mess up our NFS mount.  If you do an ifconfig, you'll 
 +notice that the mac address is 00:00:00:00:00:00.  This will be fixed 
 +by mac_read sometime later. 
 + 
 +Now we'll set up fan control. 
 + 
 +<code> 
 +192:/# cd /etc 
 +192:/etc# vi rc.local 
 +</code> 
 + 
 +Add the following before the "exit 0" in rc.local: 
 + 
 +<file> 
 +echo "Starting fan control" 
 +export PATH=/usr/local/sbin:$PATH 
 +fan.script 
 +fancontrol & 
 +</file> 
 + 
 +And do: 
 + 
 +<code> 
 +192:/etc# cp ~/dns323-oldfs/sbin/fan.script /usr/local/sbin/ 
 +192:/etc# cp /mnt/sbin/fancontrol /usr/local/sbin 
 +192:/etc# cp /mnt/sbin/fanspeed /usr/local/sbin/ 
 +</code> 
 + 
 + 
 +Now lets create some things on the disk.  I'll demo creating a / 
 +filesystem of 5gb on a RAID 1 volume, and an LVM you can create 
 +whatever you want to with. 
 + 
 +For some odd reason D-Link didn't compile the scsi disk driver into 
 +the kernel.  No matter, easy enough to handle: 
 + 
 +<code> 
 +192:~# mkdir /lib/modules/2.6.12.6-arm1 
 +192:~# cp /mnt/scsi/sd_mod.ko /lib/modules/2.6.12.6-arm1/ 
 +192:~# depmod -a 
 +192:~# modprobe sd_mod 
 +SCSI device sda: 490234752 512-byte hdwr sectors (251000 MB) 
 +SCSI device sda: drive cache: write back 
 +SCSI device sda: 490234752 512-byte hdwr sectors (251000 MB) 
 +SCSI device sda: drive cache: write back 
 + sda: sda1 sda2 sda4 
 +Attached scsi disk sda at scsi1, channel 0, id 0, lun 0 
 + 
 + 
 +192:/etc# fdisk /dev/sda 
 + 
 +The number of cylinders for this disk is set to 30515. 
 +There is nothing wrong with that, but this is larger than 1024, 
 +and could in certain setups cause problems with: 
 +1) software that runs at boot time (e.g., old versions of LILO) 
 +2) booting and partitioning software from other OSs 
 +  (e.g., DOS FDISK, OS/2 FDISK) 
 + 
 +Command (m for help): p 
 + 
 +Disk /dev/sda: 251.0 GB, 251000193024 bytes 
 +255 heads, 63 sectors/track, 30515 cylinders 
 +Units = cylinders of 16065 * 512 = 8225280 bytes 
 + 
 +  Device Boot      Start        End      Blocks  Id  System 
 +/dev/sda1              1          66      530113+  82  Linux swap / Solaris 
 +/dev/sda2              93      30515  244372747+  83  Linux 
 +/dev/sda4              67          92      208845  83  Linux 
 + 
 +Partition table entries are not in disk order 
 + 
 +Command (m for help): d 
 +Partition number (1-4): 2 
 + 
 +Command (m for help): d 
 +Partition number (1-4): 4 
 + 
 +Command (m for help): n 
 +Command action 
 +  e  extended 
 +  p  primary partition (1-4) 
 +
 +Partition number (1-4): 2 
 +First cylinder (67-30515, default 67): 
 +Using default value 67 
 +Last cylinder or +size or +sizeM or +sizeK (67-30515, default 30515): +5G 
 + 
 +Command (m for help): n 
 +Command action 
 +  e  extended 
 +  p  primary partition (1-4) 
 +
 +Partition number (1-4): 3 
 +First cylinder (676-30515, default 676): 
 +Using default value 676 
 +Last cylinder or +size or +sizeM or +sizeK (676-30515, default 30515): 
 +Using default value 30515 
 + 
 +Command (m for help): t 
 +Partition number (1-4): 2 
 +Hex code (type L to list codes): fd 
 +Changed system type of partition 2 to fd (Linux raid autodetect) 
 + 
 +Command (m for help): t 
 +Partition number (1-4): 3 
 +Hex code (type L to list codes): fd 
 +Changed system type of partition 3 to fd (Linux raid autodetect) 
 + 
 +Command (m for help): p 
 + 
 +Disk /dev/sda: 251.0 GB, 251000193024 bytes 
 +255 heads, 63 sectors/track, 30515 cylinders 
 +Units = cylinders of 16065 * 512 = 8225280 bytes 
 + 
 +  Device Boot      Start        End      Blocks  Id  System 
 +/dev/sda1              1          66      530113+  82  Linux swap / Solaris 
 +/dev/sda2              67        675    4891792+  fd  Linux raid autodetect 
 +/dev/sda3            676      30515  239689800  fd  Linux raid autodetect 
 + 
 +Command (m for help): w 
 +The partition table has been altered! 
 + 
 +Calling ioctl() to re-read partition table. 
 +SCSI device sda: 490234752 512-byte hdwr sectors (251000 MB) 
 +SCSI device sda: drive cache: write back 
 + sda: sda1 sda2 sda3 
 +SCSI device sda: 490234752 512-byte hdwr sectors (251000 MB) 
 +SCSI device sda: drive cache: write back 
 + sda: sda1 sda2 sda3 
 +Syncing disks. 
 +</code> 
 + 
 +If you have two disks, do the same (starting with the fdisk command) for sdb 
 + 
 +Now we need some debian packages to install.  First, many routers will not route 00:00:00:00:00:00 MAC addresses, so do: 
 + 
 +<code> 
 +192:/etc# mac_read 
 +MAC = 00:19:5B:EC:E7:1B 
 +egiga0: mac address changed 
 +egiga0: link down 
 +192:/etc# egiga0: link up<5>, full duplex<5>, speed 100 Mbps<5> 
 +</code> 
 + 
 +Now set up apt: 
 + 
 +<code> 
 +192:/etc# vi /etc/apt/sources.list 
 +</code> 
 + 
 +Set it to: 
 + 
 +<file> 
 +# See sources.list(5) for more information, especialy 
 +# Remember that you can only use http, ftp or file URIs 
 +# CDROMs are managed through the apt-cdrom tool. 
 +deb http://http.us.debian.org/debian stable main contrib non-free 
 +deb http://non-us.debian.org/debian-non-US stable/non-US main contrib non-free 
 +deb http://security.debian.org stable/updates main contrib non-free 
 + 
 +# Uncomment if you want the apt-get source function to work 
 +#deb-src http://http.us.debian.org/debian stable main contrib non-free 
 +#deb-src http://non-us.debian.org/debian-non-US stable/non-US main contrib non-free 
 +</file> 
 + 
 +Edit ''/etc/resolv.conf'' and point it to your DNS server.  Look on your 
 +running system to see what it should be. 
 + 
 +Edit ''/etc/hostname'' and put your machine's name in it. 
 + 
 +Edit ''/etc/hosts'' and add your host, like (replacing the names with your 
 +name, but leave localhost alone): 
 + 
 +<file> 
 +127.0.0.1              server.minyard.local server localhost 
 +</file> 
 + 
 +Now update apt: 
 + 
 +<code> 
 +192:/etc# apt-get update 
 +</code> 
 + 
 +This may take some time and generates some output.  It may generate an 
 +error on a couple of gets, this is probably not a big deal. 
 + 
 +Let's set up the initrd now: 
 + 
 +<code> 
 +192:/etc# cd /initrd 
 +192:/initrd# apt-get install busybox 
 +192:/initrd# mkdir bin dev lib proc root 
 +192:/initrd# cp /lib/ld-linux.so.2 lib 
 +192:/initrd# cp /lib/libc.so.6 lib/ 
 +192:/initrd# cp /lib/libgcc_s.so.1 lib/ 
 +192:/initrd# cp /lib/libcrypt.so.1 lib 
 +192:/initrd# cp /lib/libm.so.6 lib 
 +192:/initrd# cp /bin/busybox bin 
 +192:/initrd# cp /sbin/pivot_root bin/ 
 +192:/initrd# cp /sbin/insmod bin/ 
 +192:/initrd# ln -s busybox bin/sh 
 +192:/initrd# cp -a /dev/console /dev/md0 /dev/md1 /dev/null /dev/ram0 /dev/tty /dev/ttyS0 /dev/zero /dev/sda2 /dev/sda3 /dev/sdb2 /dev/sdb3 dev 
 +192:/initrd# cp /lib/modules/2.6.12.6-arm1/sd_mod.ko . 
 +192:/initrd# vi bin/init 
 +</code> 
 + 
 +Put the following in bin/init: 
 + 
 +<file> 
 +#!/bin/sh 
 + 
 +echo "/init script running..." 
 + 
 +export init=/bin/init 
 +export rootmnt=/root 
 + 
 +echo -n " [*] mounting /proc..." 
 +mount -t proc proc /proc || die "failed to mount /proc" 
 +echo "done" 
 + 
 +# Standard kernel from D-Link doesn't have sd_mod built in. 
 +echo -n " [*] loading sd_mod..." 
 +insmod /sd_mod.ko 
 +echo "done" 
 + 
 +echo -n " [*] assembling RAID arrays..." 
 +echo 'DEVICE /dev/sda2 /dev/sda3 /dev/sdb2 /dev/sdb3' >mdadm.conf 
 +mdadm --examine --scan --config=partitions >>mdadm.conf 
 +mdadm --assemble --scan --config=mdadm.conf 
 +echo "done" 
 + 
 +echo -n " [*] mounting /root..." 
 +mount /dev/md0 ${rootmnt} 
 +echo "done" 
 + 
 +echo -n " [*] Cleaning up..." 
 +# Clean up 
 +umount -l /proc 
 +echo "done" 
 + 
 +# Pivot Root 
 +echo " [*] Switching to real root fs..." 
 +# Don't pass in args, they are bogus. 
 +cd /root 
 +pivot_root . old_root 
 +exec /usr/sbin/chroot . sh -c 'umount /old_root; /usr/local/sbin/freeramdisk /dev/ram0; exec /sbin/init' </dev/console >/dev/console 2>&1 
 + 
 +#shouldn't get here! 
 +echo "switch_root must have failed" 
 +exec /bin/sh 
 +</file> 
 + 
 +And make it executable: 
 + 
 +<code> 
 +192:/initrd# chmod +x bin/init 
 +</code> 
 + 
 +You will need to install mkimage from {{howto:mkimage.gz}} into ''/usr/local/bin'' after un-gzipping it. 
 +Make sure to ''chmod +x' 'the file, too, so it will be executable.  The sources are available as part of  
 +the uboot code from D-Link, but I've pared it down in {{howto:mkimage.tgz}}. 
 + 
 +You should also install freeramdisk from {{howto:freeramdisk.gz}} into ''/usr/local/sbin'' after un-gzipping it.  chmod this one, too.  The source is in {{howto:freeramdisk.c.gz}}. 
 + 
 +Now create the tools to build the init ramdisk: 
 + 
 +<code> 
 +192:/initrd# cd /root 
 +192:/initrd# vi make_uinitrd 
 +</code> 
 + 
 +Set it to: 
 + 
 +<file> 
 +rm -f initrd.img.gz 
 +dd if=/dev/zero of=initrd.img bs=4096 count=1024 
 +mke2fs -F initrd.img 
 +mkdir -p mnt 
 +mount -o loop initrd.img mnt 
 +cp -a /initrd/* mnt/ 
 +umount mnt 
 +gzip initrd.img 
 +mkimage -a 0x800000 -e 0x800000 -n 'boot ramdisk' -A arm -O linux -T ramdisk -C gzip -d initrd.img.gz initrd.uImage 
 +</file> 
 + 
 +And make it executable 
 + 
 +<code> 
 +192:~# chmod +x make_uinitrd 
 +</code> 
 + 
 +Now get the mdadm package: 
 + 
 +<code> 
 +192:/etc# apt-get install mdadm 
 +</code> 
 + 
 +If it asks you for arrays needed for the root filesystem, you can say 
 +"None", and not to start MD arrays automatically. 
 + 
 +Now put mdadm onto the initrd: 
 + 
 +<code> 
 +192:~# cp /sbin/mdadm /initrd/bin/ 
 +</code> 
 + 
 +Now you can create the RAID arrays.  If you have one disk, I still 
 +recommend using RAID so you can mirror the second disk if you add it. 
 + 
 +For two disks: 
 + 
 +<code> 
 +192:/etc# mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/sda2 /dev/sdb2 
 +192:/etc# mdadm --create /dev/md1 --level=1 --raid-devices=2 /dev/sda3 /dev/sdb3 
 +</code> 
 + 
 +If you have one disk: 
 + 
 + 
 +<code> 
 +192:/etc# mdadm --create /dev/md0 --level=1 --force --raid-devices=1 /dev/sda2 
 +192:/etc# mdadm --create /dev/md1 --level=1 --force --raid-devices=1 /dev/sda3 
 +</code> 
 + 
 +It may ask you questions, just tell it "yes".  Now create the 
 +filesystem on /dev/md0. 
 + 
 +<code> 
 +192:/etc# mke2fs -j /dev/md0 
 +</code> 
 + 
 +We will make md1 into an LVM later.  Now copy everything into the new 
 +filesystem: 
 + 
 +<code> 
 +192:/# umount /mnt 
 +192:/# cd /mnt 
 +192:/mnt# mkdir hd_root nfs_root 
 +192:/mnt# mount /dev/md0 hd_root 
 +kjournald starting.  Commit interval 5 seconds 
 +EXT3 FS on md0, internal journal 
 +EXT3-fs: mounted filesystem with ordered data mode. 
 +192:/mnt# mount -o bind / nfs_root 
 +192:/mnt# cp -a nfs_root/* hd_root 
 +192:/mnt# mkdir hd_root/old_root 
 +</code> 
 + 
 +Now let's edit the fstab on the disk: 
 + 
 +<code> 
 +192:/mnt# vi hd_root/etc/fstab 
 +</code> 
 + 
 +Remove the comments from the /dev/sda1 and /dev/md0 lines.  If you 
 +have a second disk, you can remove the comment form /dev/sdb1.  We can 
 +also edit the network config: 
 + 
 +<code> 
 +192:/mnt# vi hd_root/etc/network/interfaces 
 +</code> 
 + 
 +Delete the line that says "auto lo" and uncomment the next "auto" line. 
 + 
 +Now we are ready to boot set up to boot from disk.  Create the initrd: 
 + 
 +<code> 
 +192:/mnt# cd /root 
 +192:~# ./make_uinitrd 
 +1024+0 records in 
 +1024+0 records out 
 +4194304 bytes (4.2 MB) copied, 2.7383 seconds, 1.5 MB/s 
 +mke2fs 1.40-WIP (14-Nov-2006) 
 +Filesystem label= 
 +OS type: Linux 
 +Block size=1024 (log=0) 
 +Fragment size=1024 (log=0) 
 +1024 inodes, 4096 blocks 
 +204 blocks (4.98%) reserved for the super user 
 +First data block=1 
 +Maximum filesystem blocks=4194304 
 +1 block group 
 +8192 blocks per group, 8192 fragments per group 
 +1024 inodes per group 
 + 
 +Writing inode tables: done 
 +Writing superblocks and filesystem accounting information: done 
 + 
 +This filesystem will be automatically checked every 23 mounts or 
 +180 days, whichever comes first.  Use tune2fs -c or -i to override. 
 +Image Name:  boot ramdisk 
 +Created:      Sat Sep 15 09:05:22 2007 
 +Image Type:  ARM Linux RAMDisk Image (gzip compressed) 
 +Data Size:    1227711 Bytes = 1198.94 kB = 1.17 MB 
 +Load Address: 0x00800000 
 +Entry Point:  0x00800000 
 +</code> 
 + 
 +Now write the initrd into the flash and reboot: 
 + 
 +<code> 
 +192:~# dd if=/root/initrd.uImage of=/dev/mtdblock3 
 +192:~# reboot 
 +</code> 
 + 
 +You should boot from disk now.  Do not do the "space" "1" thing, you 
 +want to boot using the initrd you just put onto the disk. 
 + 
 +Log in as root, set the root password, and you are in a fully 
 +functional debian system.  Not much will be installed, that will 
 +depend on your needs.  64MB is plenty of room to run a server, though 
 +you may run into problems if you run programs that use X. 
 + 
 +A few other things you might want to do: 
 + 
 +Provide access to the temperature sensor: 
 +<code> 
 +server:~# cd ~/dns323-oldfs 
 +server:~/dns323-oldfs# mount -o loop image.cfs /mnt/ 
 +server:~/dns323-oldfs# cp /mnt/sbin/temperature /usr/local/sbin/ 
 +server:~/dns323-oldfs# temperature 
 +temperature - query and set the temperature sensor 
 + 
 +Usage: temperature [function] 
 + 
 +Functions: 
 + h - show this help 
 + w [1,2] degree - set temperature degree in register 1:Thyst 2:Tos 
 + g [0~2] - get temperature in register 0:temperature 1:Thyst 2:Tos 
 +server:~/dns323-oldfs# temperature g 0 
 +Temperature type : Centigrade 
 +<temperaturertc>: get temperature = 46 
 +server:~/dns323-oldfs# umount /mnt 
 +</code> 
 +I'm not sure what all the sensor values mean here. 
 + 
 +If you want to go back to the normal DNS-323 software, just restore the 
 +contents of /dev/mtdblock3: 
 + 
 +<code> 
 +192:~# dd if=/root/oldmtd/mtd3 of=/dev/mtdblock3 
 +</code> 
 + 
 +The DNS-323 may be confused about the partitions, not sure.

Navigation

Personal Tools