Advertisement
VolleMelk

Debian on LS-WVL

Mar 17th, 2013
4,632
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 13.12 KB | None | 0 0
  1. # ------------------------------------------------------------------------------------- #
  2. #                                   Debian on LS-WVL                                    #
  3. # ------------------------------------------------------------------------------------- #
  4.  
  5. # I have a Buffalo LS-WVL. I bought it with drives, so it does NOT have NAND.
  6.  
  7. # I wanted my NAS to have it's brains back, so I decided to install Debian. Then I
  8. # compiled a vanilla 3.8.3 kernel using patches by hato.
  9.  
  10. # Credits
  11. # -------
  12. # * The Buffalo NAS-Central wiki: http://buffalo.nas-central.org/wiki/Debian_Squeeze_on_LS-WXL
  13. # * hato (http://forum.buffalo.nas-central.org/memberlist.php?mode=viewprofile&u=5411). Without
  14. #   him this would not have been possible. Thank you very much!
  15.  
  16. # Goal
  17. # ----
  18. # It all started with me wanting to run OpenVPN. I quickly found out that the stock Buffalo
  19. # kernel does not support tun/tap. And here it began.. If only they would've let that module
  20. # in. Here I tried my best to document my journey.
  21.  
  22. # After this guide, you will have a LS-WVL running Debian Squeeze with a kernel 3.8.3 in RAID1
  23.  
  24. # You will loose your Buffalo webinterface. If you like, you can replace it with webmin. You
  25. # will also loose LED indications, and you can also uninstall NasNavigator. Doesn't work either.
  26.  
  27. # If you are planning on compiling the kernel after his guide, go ahead and open up the kernel compile
  28. # guide (Step 6) so you can read some notes you should be aware
  29.  
  30. # I am assuming you are ALWAYS logging in as root (except instructed otherwise)
  31.  
  32. # Liability and TFTP
  33. # ------------------
  34. # Everything you do is your own responsibility. Expect to brick your device several times
  35. # (I did, COUNTLESS times). But the LS-WVL HAS TFTP support! Here (http://pastebin.com/5sY24CTQ)
  36. # you can read how it's done. I promise you, it works.
  37.  
  38. # You are expected to format all your partitions/drives. So save all your data somewhere else.
  39.  
  40. # TFTP is described here: http://pastebin.com/5sY24CTQ
  41.  
  42. # Files
  43. # -----
  44. # http://members.ziggo.nl/roodgoudzilver/lswvl/
  45. # * TFTP Boot                       - To unbrick your NAS (info: http://pastebin.com/5sY24CTQ)
  46. # * LSRecovery                      - To reset your linkstation to factory defaults
  47.                               (ONLY works when running stock firmware!)
  48. # * kernel/lswvl_config_by_hato.config          - .config file to compile the kernel
  49. # * kernel/lswvl_support_and_mv-cesa_dma_3.8_x_x.patch  - Patch to make the kernel compatible with LS-WVL
  50.  
  51. # Further reading & sources
  52. # -------------------------
  53. # * vi          - linux text editor: http://www.cs.colostate.edu/helpdocs/vi.html
  54. # * nano        - another linux text editor: https://www.linux.com/learn/tutorials/325049:linuxables-introduction-to-the-nano-text-editor
  55. # * netconsole      - log kernel printk messages over UDP: https://www.kernel.org/doc/Documentation/networking/netconsole.txt
  56. # * netcat for windows: http://joncraton.org/blog/46/netcat-for-windows
  57. # * screen      - http://ss64.com/bash/screen.html
  58. # * mdadm cheatsheet    - http://www.ducea.com/2009/03/08/mdadm-cheat-sheet/
  59.  
  60. # * http://forum.buffalo.nas-central.org/viewtopic.php?f=73&t=25941#p159615
  61. # * http://buffalo.nas-central.org/wiki/Debian_Squeeze_on_LS-WXL
  62.  
  63. # Update 2013-04-13: Fan control works! See here: http://pastebin.com/ch7TuxED
  64.  
  65. # ---
  66.  
  67. # Preperation
  68. # -----------
  69. # I can suggest you set your router so that your NAS always gets the same IP address. This way,
  70. # it shouldn't get lost. I never lost my NAS this way.
  71.  
  72. # Step 1: Root access
  73. # -------------------
  74. # Before we can start, you need root access to the NAS. If you don't have it, you can flash
  75. # Shonk's LS Series 1.64 mod1a firmware (here: http://forum.buffalo.nas-central.org/viewtopic.php?f=68&t=23603)
  76. # It is possible that you cannot enter the webinterface. I did not manage to reset the LS-WVL
  77. # to factory settings. I used an official Buffalo tool called LSRecovery.exe. After this, you can
  78. # login to the Buffalo Webinterface using admin/password.
  79.  
  80. # Check if you have SSH. If not, telnet in. username: admin. password: password
  81.  
  82. su
  83. passwd          # change root password
  84. vi /etc/melco/info  # Google for a guide on vi for linux.
  85.  
  86. # Scroll down, find
  87. # TELNET=on
  88. # SSH=off
  89. # Change SSH=off to SSH=on save and
  90.  
  91. reboot
  92.  
  93. # Check if you can SSH the NAS using root (and the password you just changed). If all works, carry on!
  94.  
  95. # Step 2: Configure RAID
  96. # ----------------------
  97. # Use the Buffalo Webinterface to setup the RAID. Login (admin/password), go to System -> Storage.
  98. # I am assuming we are using RAID1, if not do your homework because partitions will change.
  99.  
  100. # Here is the trick. It takes around 980 minutes to sync RAID1. If I had to wait 980 minutes each time I
  101. # bricked my NAS, it would've taken me YEARS. So, we are going to interrupt the sync process:
  102. # Make sure the RAID is configured (The orange LED is blinking indicating it is rebuilding the array)
  103. # * Turn off the NAS using the switch on the back
  104. # * Remove drive 2
  105. # * Turn on the NAS using the powerswitch
  106. # The NAS will boot, the red error light will blink and the red bay light will turn on. This is good.
  107. # We now have a degraded array: it's missing one drive, but the /dev/md0 device exists but is only
  108. # addressing one drive (/dev/sda or /dev/sdb). Once we have the NAS up and running we will
  109. # use mdadm to add the second drive back to the array and let it rebuild.
  110.  
  111. # more on this here: http://forum.buffalo.nas-central.org/viewtopic.php?f=77&t=28559&p=168261#p168261
  112.  
  113. # Step 3: Prepare Debian Squeeze root filesystem (http://buffalo.nas-central.org/wiki/Debian_Squeeze_on_LS-WXL)
  114. # ----------------------------------------------
  115.  
  116. # SSH to the NAS. Login as root, and you can stay in ~/
  117.  
  118. wget http://ftp.us.debian.org/debian/pool/main/d/debootstrap/debootstrap_1.0.46_all.deb
  119. dpkg -i debootstrap_1.0.46_all.deb
  120.  
  121. which ar >/dev/null || ln -s /bin/busybox /usr/bin/ar  # fix ar link
  122.  
  123. mkdir debian-armel-rootfs
  124. debootstrap --verbose --arch armel squeeze debian-armel-rootfs http://ftp.us.debian.org/debian
  125.  
  126. # This will take some time. When you see
  127. # I: Base system installed successfully.
  128. # debootstrap is done.
  129.  
  130. # Copy kernel modules from stock kernel:
  131.  
  132. cp /boot/initrd.buffalo debian-armel-rootfs/tmp/
  133. LANG=C chroot debian-armel-rootfs/ /bin/bash
  134. cd /tmp
  135. dd if=initrd.buffalo of=initrd.gz ibs=64 skip=1
  136. gunzip initrd.gz
  137. mkdir INITRD
  138. mount -t ext2 -o loop initrd INITRD
  139. cp -R INITRD/lib/modules/* /lib/modules/
  140. umount INITRD
  141. rmdir INITRD
  142. rm initrd*
  143.  
  144. # Adding missing devices
  145.  
  146. apt-get install makedev
  147. ln -s /sbin/makedev /dev/MAKEDEV
  148. mount -t proc proc /proc
  149. cd /dev
  150. mv .udev .oldudev
  151. MAKEDEV generic
  152. MAKEDEV md
  153. mv .oldudev  .udev
  154. umount /proc
  155.  
  156. # Edit /etc/apt/sources.list
  157.  
  158. nano /etc/apt/sources.list
  159. deb http://ftp.us.debian.org/debian squeeze main
  160. deb http://security.debian.org/ squeeze/updates main contrib
  161.  
  162. # Save and exit nano
  163.  
  164. apt-get update
  165.  
  166. # Install mdadm
  167.  
  168. apt-get --no-install-recommends install mdadm
  169.  
  170. # Ignore any errors. Update mdadm.conf
  171.  
  172. exit                                                # exit from chroot
  173. cp /etc/mdadm.conf debian-armel-rootfs/etc/mdadm/
  174. LANG=C chroot debian-armel-rootfs/ /bin/bash        # back again
  175.  
  176. # Configure locales
  177.  
  178. apt-get install locales
  179. dpkg-reconfigure locales
  180.  
  181. # Create /etc/fstab
  182. cat >/etc/fstab <<EOF
  183. # /etc/fstab: static file system information.
  184. #
  185. # file system   mount point type    options         dump pass
  186. /dev/md2    /       xfs defaults,noatime    0    1
  187. /dev/md0    /boot       ext3    rw,nosuid,nodev     0    2
  188. /dev/md10   none        swap    sw          0    0
  189. proc        /proc       proc    defaults        0    0
  190. EOF
  191.  
  192. # Network: Edit /etc/network/interfaces to match your LAN configuration:
  193. # (We are assigning both eth0 and eth1, my NAS used eth1, but other NAS use eth0
  194. # and I am not able to figure out which one uses which one. AFAIK, it is indicated
  195. # in the Buffalo Web Interface on the left. Unable to check now, I already am at Squeeze)
  196.  
  197. nano /etc/network/interfaces
  198.  
  199. # We always want the loopback interface.
  200. auto lo
  201. iface lo inet loopback
  202.  
  203. # DHCP for Ethernet connection
  204. auto eth0
  205. iface eth0 inet dhcp
  206.  
  207. auto eth1
  208. iface eth1 inet dhcp
  209.  
  210. # Example static IP setup: (broadcast and gateway are optional)
  211. # auto eth0
  212. # iface eth0 inet static
  213. #     address 192.168.0.42
  214. #     network 192.168.0.0
  215. #     netmask 255.255.255.0
  216. #     broadcast 192.168.0.255
  217. #     gateway 192.168.0.1
  218.  
  219. # Save file and exit nano
  220.  
  221. echo "hostname" > /etc/hostname             # Change hostname to something sensible (NAS for example)
  222.  
  223. # Install SSHD
  224.  
  225. apt-get install openssh-server
  226. passwd root
  227. mkdir ~/.ssh
  228. exit
  229. cp /root/.ssh/au* debian-armel-rootfs/root/.ssh/
  230. LANG=C chroot debian-armel-rootfs/ /bin/bash        # back again
  231.  
  232. nano  /etc/ssh/sshd_config              # Check that PermitRootLogin yes is uncommented
  233.  
  234. # Prepare rootfs archive
  235.  
  236. aptitude clean
  237. exit
  238. tar zcvf squeeze-armel-rootfs.tgz -C debian-armel-rootfs .
  239.  
  240. # Now you have a complete rootfs for Debian squeeze armel. Put a copy of squeeze-armel-rootfs.tgz on
  241. # your computer (for example in nas/debian)
  242.  
  243. # Step 4: Create an INITRD
  244. # ------------------------
  245.  
  246. # These steps are literally copied and pasted from the 'Debian Squeeze on LS-WXL', they are just here
  247. # for the record.
  248.  
  249. chroot debian-armel-rootfs/ /bin/bash
  250. apt-get install busybox
  251. apt-get install uboot-mkimage
  252.  
  253. cd /tmp
  254. dd if=/dev/zero of=initrd bs=1k count=0 seek=3K
  255. mke2fs -F -m 0 -b 1024 initrd
  256. tune2fs -c0 -i0 initrd
  257. mkdir INITRD
  258. mount -o loop initrd INITRD
  259.  
  260. mkdir -p INITRD/{bin,lib,dev,etc/mdadm,proc,sbin}
  261. cp -a /dev/{null,console,tty,sd{a,b,c,d}?,md*} INITRD/dev/
  262.  
  263. cp /bin/busybox INITRD/bin/
  264. cp /sbin/mdadm INITRD/sbin
  265. cp /lib/{libm.so.6,libc.so.6,libgcc_s.so.1,ld-linux.so.3} INITRD/lib
  266.  
  267. cat > INITRD/linuxrc <<EOF
  268. #!/bin/busybox sh
  269.  
  270. # Mount the /proc and /sys filesystems.
  271. mount -t proc none /proc
  272. mount -t sysfs none /sys
  273.  
  274. echo 'DEVICE /dev/sd??*' > /etc/mdadm/mdadm.conf
  275. mdadm -Eb /dev/sd??* >> /etc/mdadm/mdadm.conf
  276. mdadm -As --force
  277.  
  278. # use /dev/md1 as root
  279. # echo "0x901" > /proc/sys/kernel/real-root-dev
  280. # use /dev/md2 as root
  281. echo "0x902" > /proc/sys/kernel/real-root-dev
  282. # use /dev/sda6 as root
  283. # echo "0x806" > /proc/sys/kernel/real-root-dev
  284. # use /dev/sdb6 as root
  285. # echo "0x822" > /proc/sys/kernel/real-root-dev
  286.  
  287. # Clean up.
  288. umount /proc
  289. umount /sys
  290. EOF
  291. chmod +x INITRD/linuxrc
  292.  
  293. umount INITRD
  294. gzip initrd
  295. mkimage -A arm -O linux -T ramdisk -C gzip -a 0x0 -e 0x0 -n initrd -d initrd.gz initrd.buffalo
  296.  
  297. gunzip initrd.gz
  298. mount -o loop initrd INITRD
  299.  
  300. nano INITRD/linuxrc
  301. # Comment   echo "0x902" > /proc/sys/kernel/real-root-dev
  302. # Uncomment # echo "0x901" > /proc/sys/kernel/real-root-dev
  303. # Save and quit
  304.  
  305. umount INITRD
  306. gzip initrd
  307. mkimage -A arm -O linux -T ramdisk -C gzip -a 0x0 -e 0x0 -n initrd -d initrd.gz initrd.buffalo.final
  308. rmdir INITRD
  309.  
  310. # Exit the chrooted environment.
  311. exit
  312.  
  313. # We have now created two initrd files:
  314. # initrd.buffalo    - Temporary initrd
  315. # initrd.buffalo.final  - Final initrd (Will be used forever!)
  316. # Make a copy of these two files on your computer! See next paragraph why
  317.  
  318. # IMPORTANT
  319. # Make sure you have a copy of initrd.buffalo, initrd.buffalo.final and squeeze-armel-rootfs.tgz
  320. # on your computer. If you brick the NAS from here on, you will only have to do these steps:
  321. # * Unbrick your nas using TFTP: http://pastebin.com/5sY24CTQ
  322. # * Open the NAS (Enable SSH: Step 1)
  323. # * Copy initrd.buffalo, initrd.buffalo.final and squeeze-armel-rootfs.tgz to ~/
  324. # * Continue with Step 5!
  325. # If you do not perform these three steps, and your NAS bricks you have to prepare the whole
  326. # chroot again, and create the initrds again. Make a backup, and you can just use the
  327. # ones you just created :)
  328.  
  329. # Step 5: Installation
  330. # --------------------
  331.  
  332. # See here: http://pastebin.com/6nXswgf3
  333.  
  334. # Step 6: Compiling the kernel
  335. # ----------------------------
  336.  
  337. # See here: http://pastebin.com/9aKT3z3i
  338.  
  339. # Step 7: Post-installation setup
  340. # -------------------------------
  341.  
  342. # Now you have Debian Squeeze with 3.8.3 kernel. Last things:
  343.  
  344. apt-get install ntp                     # NTP (keeps the clock in sync)
  345. dpkg-reconfigure tzdata                     # Configure timezone
  346. apt-get install sudo less usbutils bzip2 mc linuxlogo psmisc    # Useful packages
  347.  
  348. # Webmin
  349. wget http://prdownloads.sourceforge.net/webadmin/webmin_1.620_all.deb
  350. apt-get install libnet-ssleay-perl openssl libauthen-pam-perl libio-pty-perl apt-show-versions libapt-pkg-perl
  351. dpkg -i webmin_1.620_all.deb                    # On my NAS, this took nearly 10 minutes
  352. # For more information, see http://buffalo.nas-central.org/wiki/Webmin_to_remotely_administer_your_LinkStation
  353.  
  354. # Cleaning up (You can choose to keep or move these files yourself)
  355. rm lswvl_config_by_hato.config          # kernel .config file
  356. rm lswvl_support_and_mv-cesa_dma_3.8*.patch # lswvl patch for kernel 3.8
  357. rm webmin_1.620_all.deb             # if you installed webmin, you don't need this anymore
  358.  
  359. # Step 7: Recontructing the RAID array
  360. # ------------------------------------
  361.  
  362. # Last thing we have to do, get the RAID array back together.
  363.  
  364. # See here: http://pastebin.com/pWWrkzQB
  365.  
  366. # Final notes:
  367. # ------------
  368. # This guide was created by VolleMelk. As stated before, I only gathered all the guides and information
  369. # I used for my own NAS. Credits where credits are due. Any questions? I can recommend
  370. # http://http://forum.buffalo.nas-central.org/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement