LS Mini: Install Gentoo

From NAS-Central Buffalo - The Linkstation Wiki
Revision as of 15:41, 3 November 2008 by Bluerain (Talk | contribs)

Jump to: navigation, search
Kurobrick.png
WARNING!

There is a possibility that you could brick your NAS with these instructions. Please make sure that you read the entire page carefully. There is a possibility that you could brick your NAS with these instructions. Please make sure that you read the entire page carefully. It is easy to recover your bricked LS Mini, but you have to disassemble it. Disassembling may void your warranty or cause severe damage of the hardware!


Linkstation Mini

Contents

You will have only one chance to make it without disassembly. Take time, it will take about hour or more.

If you were unsuccessful, don't get upset: you can go "via disassembly".

Open up and prepare stock firmware

First of all you need to get telnet access to your LS Mini: Open Stock Firmware

When in, you need to kill all unneeded processes with help of killall and ps commands.

You must come to a state similar to this:

root@LS-WSGL:~# ps | grep -v SW
  PID  Uid     VmSize Stat Command
    1 root        572 S   init       
 1012 root        200 S   /sbin/dhcpcd -L /etc/dhcpc -h LS-WSGL -t 15 -x -y -z 
 1048 root        652 S   syslogd -m 0 
 1050 root        380 S   klogd 
 1054 root        676 S   /usr/sbin/inetd 
 1865 root        620 S   /sbin/getty -L ttyS0 115200 vt100 
 2201 root        384 S   telnetd 
 2203 root       1256 S   -sh 
 3682 root        720 R   ps 

Now check that you have same RAID configuration as I had:

root@LS-WSGL:~# cat /proc/mdstat 
Personalities : [raid0] [raid1] 
md1 : active raid1 sdb2[1] sda2[0]
      5004160 blocks [2/2] [UU]
      
md10 : active raid1 sda5[0] sdb5[1]
      1003904 blocks [2/2] [UU]
      
md0 : active raid1 sda1[0] sdb1[1]
      1003904 blocks [2/2] [UU]
      
unused devices: <none>
Probably you will need to stop one of arrays absent here with mdadm -S

Prepare and repartition one of disks

Nuvola apps important.png 
WARNING!

Stock firmware cannot be reverted after this step. Please note that you will lose your warranty - don't blame me if anything goes wrong!


In the next step we will free /dev/sdb from stock firmware: LS Mini uses it as a boot drive.

root@LS-WSGL:~# mdadm -f /dev/md1 /dev/sdb2 
mdadm: set /dev/sdb2 faulty in /dev/md1
root@LS-WSGL:~# mdadm -f /dev/md10 /dev/sdb5
mdadm: set /dev/sdb5 faulty in /dev/md10
root@LS-WSGL:~# mdadm -f /dev/md0 /dev/sdb1 
mdadm: set /dev/sdb1 faulty in /dev/md0

root@LS-WSGL:~# mdadm -r /dev/md1 /dev/sdb2
mdadm: hot removed /dev/sdb2
root@LS-WSGL:~# mdadm -r /dev/md10 /dev/sdb5
mdadm: hot removed /dev/sdb5
root@LS-WSGL:~# mdadm -r /dev/md0 /dev/sdb1 
mdadm: hot removed /dev/sdb1

root@LS-WSGL:~# umount /mnt/*    
umount: /mnt/array1: not mounted
Now we need to repartition /dev/sdb:
root@LS-WSGL:~# if hdparm -z /dev/sdb > /dev/null; then echo; echo DRIVE READY; echo; fdisk /dev/sdb;\ 
else grep sdb /proc/mounts /proc/mdstat; echo Please check that sdb is not in use; fi;

DRIVE READY

The number of cylinders for this disk is set to 60801.
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/sdb: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1         125     1004031   83  Linux
/dev/sdb2             126         748     5004247+  83  Linux
/dev/sdb4             749       60801   482375722+   5  Extended
/dev/sdb5             749         873     1004031   82  Linux swap
/dev/sdb6             874       60690   480480021   83  Linux

Command (m for help): d
Partition number (1-6): 1

Command (m for help): d 
Partition number (1-6): 2

Command (m for help): d
Partition number (1-6): 3
Warning: partition 3 has empty type

Command (m for help): d
Partition number (1-6): 4

Command (m for help): d
No partition is defined yet!

Command (m for help): p

Disk /dev/sdb: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-60801, default 1): 
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-60801, default 60801): +64M

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (10-60801, default 10):     
Using default value 10
Last cylinder or +size or +sizeM or +sizeK (10-60801, default 60801): +128M

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 3
First cylinder (27-60801, default 27): 
Using default value 27
Last cylinder or +size or +sizeM or +sizeK (27-60801, default 60801): +2G   

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Selected partition 4
First cylinder (271-60801, default 271): 
Using default value 271
Last cylinder or +size or +sizeM or +sizeK (271-60801, default 60801): 
Using default value 60801

Command (m for help): t
Partition number (1-4): 1
Hex code (type L to list codes): fd

Command (m for help): t
Partition number (1-4): 2
Hex code (type L to list codes): 82
Changed system type of partition 2 to 82 (Linux swap)

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): t
Partition number (1-4): 4
Hex code (type L to list codes): fd
Changed system type of partition 4 to fd (Linux raid autodetect)

Now check that everything is right and write new partition table:

Command (m for help): p

Disk /dev/sdb: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1           9       72261   fd  Linux raid autodetect
/dev/sdb2              10          26      136552+  82  Linux swap
/dev/sdb3              27         270     1959930   fd  Linux raid autodetect
/dev/sdb4             271       60801   486215257+  fd  Linux raid autodetect

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

New RAID arrays

Create RAID1 arrays for new system:

root@LS-WSGL:~# for i in 1 3 4; do echo y | mdadm --create --verbose /dev/md$(($i+10)) \
--level=1 --raid-devices=2 /dev/sdb$i missing; done;
mdadm: /dev/sdb1 appears to contain an ext2fs file system
    size=1003904K  mtime=Thu Oct  9 10:13:37 2008
mdadm: size set to 72192K
Continue creating array? mdadm: array /dev/md11 started.
mdadm: size set to 1959808K
mdadm: array /dev/md13 started.
mdadm: size set to 486215168K
mdadm: array /dev/md14 started.

root@LS-WSGL:~# cat /proc/mdstat | grep md1[1234]
md14 : active raid1 sdb4[0]
md13 : active raid1 sdb3[0]
md11 : active raid1 sdb1[0]

Filesystems and swap

Prepare filesystems and swap, it will take some time:

root@LS-WSGL:~# for i in 11 13; do mkfs.ext3 -F /dev/md$i; done;   
<skip>
This filesystem will be automatically checked every 21 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

root@LS-WSGL:~# mkswap /dev/sdb2

Create and mount root of your new firmware:

root@LS-WSGL:~# mkdir /mnt/genlink/
root@LS-WSGL:~# mount /dev/md13 /mnt/genlink/
root@LS-WSGL:~# mkdir /mnt/genlink/boot/
root@LS-WSGL:~# mount /dev/md11 /mnt/genlink/boot/
root@LS-WSGL:~# cd /mnt/genlink/
root@LS-WSGL:/mnt/genlink# 

Firmware image

First install bzip2:

root@LS-WSGL:~# cd /
root@LS-WSGL:/# wget http://buffalo.jpfast.net/bzip2.bin.arm.tgz
root@LS-WSGL:/# tar xvzf bzip2.bin.arm.tgz 

Download and extract latest Genlink rootfs image:

root@LS-WSGL:/mnt/genlink# wget http://buffalo.nas-central.org/*/GenLink-stage3.1_arm9-*.tar.bz2
root@LS-WSGL:/mnt/genlink# tar xvjpf ./GenLink-stage3.1*.tar.bz2
Now chroot into your fresh Gentoo:
root@LS-WSGL:/mnt/genlink# mount -t proc proc proc/
root@LS-WSGL:/mnt/genlink# cp /etc/resolv.conf etc/resolv.conf 
root@LS-WSGL:/mnt/genlink# chroot .
Install kernel and proper initrd:
sh-3.2# pwd
/
sh-3.2# wget http://buffalo.nas-central.org/download/LSMini_ARM9/Distributions/Genlink/Kernel/LS-Mini-2.6.27-rc6lsmini-2008-10-09-23-39-29.tbz2
sh-3.2# tar xvjf LS-Mini-2.6.27-*.tbz2 
sh-3.2# wget http://buffalo-nas-hacking.googlecode.com/files/initrd-md13-armv5tejl-softfloat-1.0.tbz2
sh-3.2# tar xvjf initrd-md13*.tbz2 

Edit fstab to match your disks:

nano -w /etc/fstab
/dev/md13       /       ext3    defaults,noatime,errors=remount-ro      0 1
/dev/md11       /boot   ext3    defaults,noatime,errors=remount-ro,noauto      0 2
/dev/sdb2       none    swap    sw,pri=1      0 0
#/dev/sda2       none    swap    sw,pri=1      0 0

tmpfs   /tmp            tmpfs   size=5m,mode=1777       0 0
shm     /dev/shm        tmpfs   nodev,nosuid,noexec     0 0

(you can create mount point for /dev/md14 later)

Reboot

Now recheck everything and reboot your Linkstation Mini into a fresh Genlink install:

sh-3.2# exit
exit

root@LS-WSGL:/mnt/genlink# umount proc/
root@LS-WSGL:/mnt/genlink# cd /
root@LS-WSGL:/# umount -a
root@LS-WSGL:/# reboot; logout

Wait 3-5 minutes, blue power led should shut off.

Wait a couple minutes more, and then ssh to the Mini:

user@host ~ $ ssh root@<ip-address-here> 
Password: lspro

Hello, welcome to GenLSPro, running
                                         .
   .vir.                                d$b
.d$$$$$$b.    .cd$$b.     .d$$b.   d$$$$$$$$$$$b  .d$$b.      .d$$b.
$$$$( )$$$b d$$$()$$$.   d$$$$$$$b Q$$$$$$$P$$$P.$$$$$$$b.  .$$$$$$$b.
Q$$$$$$$$$$B$$$$$$$$P"  d$$$PQ$$$$b.   $$$$.   .$$$P` `$$$ .$$$P` `$$$
  "$$$$$$$P Q$$$$$$$b  d$$$P   Q$$$$b  $$$$b   $$$$b..d$$$ $$$$b..d$$$
 d$$$$$$P"   "$$$$$$$$ Q$$$     Q$$$$  $$$$$   `Q$$$$$$$P  `Q$$$$$$$P
$$$$$$$P       `"""""   ""        ""   Q$$$P     "Q$$$P"     "Q$$$P"
`Q$$P"                                  """

Linux armv5tel 2.6.27-rc6lsmini (compiled #81 Wed Oct 8 23:16:47 JST 2008)

Processor       : Feroceon rev 0 (v5l)
BogoMIPS        : 266.24
RAM             :  123 MB
Swap            :  133 MB
Uptime          : 13:04:20 up 3 min, 1 user, load average: 0.49, 0.34, 0.14
Logged on as    : root on /dev/pts/0 since Thu Oct 9 12:54:20 JST 2008
Users logged in : root # users=1

Now you can update your arrays:

GenLSPro ~ # cat /proc/mdstat 
Personalities : [raid1] 
md11 : active raid1 sdb1[0]
      72192 blocks [2/1] [U_]
      
md13 : active raid1 sdb3[0]
      1959808 blocks [2/1] [U_]
      
md14 : active raid1 sdb4[0]
      486215168 blocks [2/1] [U_]
      
unused devices: <none>
GenLSPro ~ # sfdisk -d /dev/sdb | sfdisk /dev/sda
Checking that no-one is using this disk right now ...
OK

Disk /dev/sda: 60801 cylinders, 255 heads, 63 sectors/track
Old situation:
Units = cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0

   Device Boot Start     End   #cyls    #blocks   Id  System
/dev/sda1          0+    124     125-   1004031   83  Linux
/dev/sda2        125     747     623    5004247+  83  Linux
/dev/sda3          0       -       0          0    0  Empty
/dev/sda4        748   60800   60053  482375722+   5  Extended
/dev/sda5        748+    872     125-   1004031   82  Linux swap / Solaris
/dev/sda6        873+  60689   59817- 480480021   83  Linux
New situation:
Units = sectors of 512 bytes, counting from 0

   Device Boot    Start       End   #sectors  Id  System
/dev/sda1            63    144584     144522  fd  Linux raid autodetect
/dev/sda2        144585    417689     273105  82  Linux swap / Solaris
/dev/sda3        417690   4337549    3919860  fd  Linux raid autodetect
/dev/sda4       4337550 976768064  972430515  fd  Linux raid autodetect
Warning: no primary partition is marked bootable (active)
This does not matter for LILO, but the DOS MBR will not boot this disk.
Successfully wrote the new partition table

Re-reading the partition table ...

GenLSPro / # wget http://buffalo.jpfast.net/mdadm-arm-v2.6.7.tbz2
GenLSPro / # tar xvjf mdadm-arm-v2.6.7.tbz2
sbin/mdadm
GenLSPro / # for i in 1 3 4; do mdadm --add /dev/md$(($i+10)) /dev/sda$i; done;
mdadm: added /dev/sda1
mdadm: added /dev/sda3
mdadm: added /dev/sda4

GenLSPro / # cat /proc/mdstat 
Personalities : [raid1] 
md11 : active raid1 sda1[1] sdb1[0]
      72192 blocks [2/2] [UU]
      
md13 : active raid1 sda3[2] sdb3[0]
      1959808 blocks [2/1] [U_]
      	resync=DELAYED
      
md14 : active raid1 sda4[2] sdb4[0]
      486215168 blocks [2/1] [U_]
      [>....................]  recovery =  0.1% (606272/486215168) finish=120.1min speed=67363K/sec
      
unused devices: <none>

After waiting for the /dev/md14 disk array to be repaired, give it a file system:

GenLSPro / # cat /proc/mdstat
Personalities : [raid1] 
md11 : active raid1 sdb1[0] sda1[1]
      72192 blocks [2/2] [UU]
      
md13 : active raid1 sdb3[0] sda3[1]
      1959808 blocks [2/2] [UU]
      
md14 : active raid1 sdb4[0] sda4[1]
      242027136 blocks [2/2] [UU]
GenLSPro / # mkfs.ext3 -F /dev/md14
mke2fs 1.41.1 (01-Sep-2008)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
15130624 inodes, 60506784 blocks
3025339 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=0
1847 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks: 
	32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
	4096000, 7962624, 11239424, 20480000, 23887872

Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 24 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

Then make a mount point for the disk: I chose the name /mnt/big

GenLSPro / # mkdir /mnt/big
GenLSPro / # nano /etc/fstab

Add an /etc/fstab entry and save the file:

/dev/md14       /mnt/big   ext3    defaults,noatime,nodiratime,errors=remount-ro      0 2

Then mount the directory:

GenLSPro / # mount -a
GenLSPro / # mount
rootfs on / type rootfs (rw)
/dev/root.old on /initrd type minix (rw)
/dev/root on / type ext3 (rw,errors=continue,data=ordered)
proc on /proc type proc (rw,nosuid,nodev,noexec)
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec)
udev on /dev type tmpfs (rw,nosuid,size=10240k,mode=755)
devpts on /dev/pts type devpts (rw,nosuid,noexec,gid=5,mode=620)
shm on /dev/shm type tmpfs (rw,nosuid,nodev,noexec)
tmpfs on /tmp type tmpfs (rw,size=5m,mode=1777)
/dev/md14 on /mnt/big type ext3 (rw,noatime,nodiratime)
GenLSPro / # sync
GenLSPro / # reboot

Further reading