Guest User

Untitled

a guest
Mar 28th, 2010
897
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 9.32 KB | None | 0 0
  1. tomas@ubuntu:~$ sudo su
  2. [sudo] password for tomas:
  3.  
  4. #clear boot partition
  5. root@ubuntu:/home/tomas# dd if=/dev/zero of=/dev/sdb bs=512 count=64260
  6. 64260+0 records in
  7. 64260+0 records out
  8. 32901120 bytes (33 MB) copied, 1.56911 s, 21.0 MB/s
  9.  
  10. # check
  11. root@ubuntu:/home/tomas# /sbin/sfdisk -l /dev/sdb
  12. Disk /dev/sdb: 60801 cylinders, 255 heads, 63 sectors/track
  13. sfdisk: ERROR: sector 0 does not have an msdos signature
  14.  /dev/sdb: unrecognized partition table type
  15. No partitions found
  16.  
  17. # fdisk reads lines of the form     <start> <size> <id> <bootable>
  18. # When a field is absent or empty, a default value is used.
  19. # The default value of size is as much as possible (until next partition or end-of-disk).
  20. root@ubuntu:/home/tomas/1# echo 4,244,fd>DSKPART
  21. root@ubuntu:/home/tomas/1# echo 248,32,fd>>DSKPART
  22. root@ubuntu:/home/tomas/1# echo 280,123,fd>>DSKPART
  23. root@ubuntu:/home/tomas/1# echo 403,,fd>>DSKPART
  24. root@ubuntu:/home/tomas/1# /sbin/sfdisk --force /dev/sdb <./DSKPART
  25. Disk /dev/sdb: 60801 cylinders, 255 heads, 63 sectors/track
  26. sfdisk: ERROR: sector 0 does not have an msdos signature
  27.  /dev/sdb: unrecognized partition table type
  28. Old situation:
  29. No partitions found
  30. New situation:
  31. Units = cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0
  32.  
  33.    Device Boot Start     End   #cyls    #blocks   Id  System
  34. /dev/sdb1          4     247     244    1959930   fd  Linux raid autodetect
  35. /dev/sdb2        248     279      32     257040   fd  Linux raid autodetect
  36. /dev/sdb3        280     402     123     987997+  fd  Linux raid autodetect
  37. /dev/sdb4        403   60800   60398  485146935   fd  Linux raid autodetect
  38. Warning: no primary partition is marked bootable (active)
  39. This does not matter for LILO, but the DOS MBR will not boot this disk.
  40. Successfully wrote the new partition table
  41. Re-reading the partition table ...
  42.  
  43. # if you have a disc with partitions
  44. # now look for automounted raid devices and stop this raid arrays
  45. # in ubuntu i have md_d1 / md_d0 / md_d3
  46. root@ubuntu:/home/tomas/1# cat /proc/mdstat
  47. Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10]
  48. md_d1 : active raid1 sdb2[0]
  49.       256960 blocks [2/1] [U_]
  50. md_d0 : active raid1 sdb1[0]
  51.       1959808 blocks [2/1] [U_]
  52. md_d3 : active raid1 sdb3[0]
  53.       987904 blocks [2/1] [U_]
  54.  
  55. # and stop this raid arrays!!
  56. root@ubuntu:/home/tomas/1# mdadm --stop /dev/md_d0
  57. root@ubuntu:/home/tomas/1# mdadm --stop /dev/md_d1
  58. root@ubuntu:/home/tomas/1# mdadm --stop /dev/md_d3
  59. root@ubuntu:/home/tomas/1# mdadm --zero-superblock /dev/sdb1
  60. root@ubuntu:/home/tomas/1# mdadm --zero-superblock /dev/sdb2
  61. root@ubuntu:/home/tomas/1# mdadm --zero-superblock /dev/sdb3
  62. root@ubuntu:/home/tomas/1# mdadm --zero-superblock /dev/sdb4
  63.  
  64.  
  65. # make three raid partitions (md0 md1 md3)
  66. # type y for "yes" !
  67. root@ubuntu:/home/tomas/1# mdadm --create /dev/md0 -l 1 -n 2  /dev/sdb1 missing
  68. mdadm: /dev/sdb1 appears to contain an ext2fs file system
  69.     size=1959808K  mtime=Thu Jan  1 01:00:02 1970
  70. mdadm: /dev/sdb1 appears to be part of a raid array:
  71.     level=raid1 devices=2 ctime=Tue Feb 12 23:58:30 2008
  72. Continue creating array? y
  73. mdadm: array /dev/md0 started.
  74. root@ubuntu:/home/tomas/1# mdadm --create /dev/md1 -l 1 -n 2  /dev/sdb2 missing
  75. mdadm: /dev/sdb2 appears to be part of a raid array:
  76.     level=raid1 devices=2 ctime=Tue Dec  8 00:07:57 2009
  77. Continue creating array? y
  78. mdadm: array /dev/md1 started.
  79. root@ubuntu:/home/tomas/1# mdadm --create /dev/md3 -l 1 -n 2  /dev/sdb3 missing
  80. mdadm: /dev/sdb3 appears to contain an ext2fs file system
  81.     size=987904K  mtime=Thu Jan  1 01:00:03 1970
  82. mdadm: /dev/sdb3 appears to be part of a raid array:
  83.     level=raid1 devices=2 ctime=Tue Dec  8 00:08:06 2009
  84. Continue creating array? y
  85. mdadm: array /dev/md3 started.
  86.  
  87. #clear 4. partition
  88. root@ubuntu:/home/tomas/1# dd if=/dev/zero of=/dev/sdb4 bs=512 count=1
  89. 1+0 records in
  90. 1+0 records out
  91. 512 bytes (512 B) copied, 0.00614513 s, 83.3 kB/s
  92.  
  93. # format the raid partitions
  94. root@ubuntu:/home/tomas/1# mkfs.ext3 /dev/md0
  95. mke2fs 1.41.9 (22-Aug-2009)
  96. Filesystem label=
  97. OS type: Linux
  98. Block size=4096 (log=2)
  99. Fragment size=4096 (log=2)
  100. 122640 inodes, 489952 blocks
  101. 24497 blocks (5.00%) reserved for the super user
  102. First data block=0
  103. Maximum filesystem blocks=503316480
  104. 15 block groups
  105. 32768 blocks per group, 32768 fragments per group
  106. 8176 inodes per group
  107. Superblock backups stored on blocks:
  108.     32768, 98304, 163840, 229376, 294912
  109.  
  110. Writing inode tables: done                            
  111. Creating journal (8192 blocks): done
  112. Writing superblocks and filesystem accounting information: done
  113.  
  114. This filesystem will be automatically checked every 32 mounts or
  115. 180 days, whichever comes first.  Use tune2fs -c or -i to override.
  116.  
  117. root@ubuntu:/home/tomas/1# mkswap /dev/md1
  118. mkswap: /dev/md1: warning: don't erase bootbits sectors
  119.        on whole disk. Use -f to force.
  120. Setting up swapspace version 1, size = 256956 KiB
  121. no label, UUID=5afd945c-90ec-4cbf-8ce2-06d25b5f8a30
  122.  
  123. root@ubuntu:/home/tomas/1# mkfs.ext3 /dev/md3
  124. mke2fs 1.41.9 (22-Aug-2009)
  125. Filesystem label=
  126. OS type: Linux
  127. Block size=4096 (log=2)
  128. Fragment size=4096 (log=2)
  129. 61824 inodes, 246976 blocks
  130. 12348 blocks (5.00%) reserved for the super user
  131. First data block=0
  132. Maximum filesystem blocks=255852544
  133. 8 block groups
  134. 32768 blocks per group, 32768 fragments per group
  135. 7728 inodes per group
  136. Superblock backups stored on blocks:
  137.     32768, 98304, 163840, 229376
  138.  
  139. Writing inode tables: done                            
  140. Creating journal (4096 blocks): done
  141. Writing superblocks and filesystem accounting information: done
  142.  
  143. This filesystem will be automatically checked every 31 mounts or
  144. 180 days, whichever comes first.  Use tune2fs -c or -i to override.
  145.  
  146. # download the latest firmware - also see /proto/SxM_webui/admin/fw_chk.php
  147. root@ubuntu:/home/tomas/1# wget http://cache.websupport.wdc.com/wdhxnc-01.00.16.img -O ./fw.img
  148. --2009-12-12 16:51:41--  http://cache.websupport.wdc.com/wdhxnc-01.00.16.img
  149. Resolving cache.websupport.wdc.com... 81.22.36.106
  150. Connecting to cache.websupport.wdc.com|81.22.36.106|:80... connected.
  151. HTTP request sent, awaiting response... 200 OK
  152. Length: 48864982 (47M) [text/plain]
  153. Saving to: `./fw.img'
  154. 100%[===========================================================>] 48,864,982   145K/s   in 5m 46s  
  155. 2009-12-12 16:57:35 (138 KB/s) - `./fw.img' saved [48864982/48864982]
  156.  
  157. # "decode" the firmware image and clean up
  158. dd skip=0 count=1 bs=5120 if=./fw.img of=./tmp_img1
  159. dd skip=15 count=1 bs=5120 if=./fw.img of=./tmp_img2
  160. cp ./fw.img ./fw_img.orig
  161. dd seek=0 count=1 bs=5120 if=./tmp_img2 of=./fw.img
  162. dd skip=1 seek=1 bs=5120 if=./fw_img.orig of=./fw.img
  163. cp ./fw.img ./fw_img.orig
  164. dd seek=15 count=1 bs=5120 if=./tmp_img1 of=./fw.img
  165. dd skip=16 seek=16 bs=5120 if=./fw_img.orig of=./fw.img
  166. rm ./tmp_img1
  167. rm ./tmp_img2
  168. rm ./fw_img.orig
  169.  
  170. # extract gzipped image .tar.gz
  171. root@ubuntu:/home/tomas/1# tar zxf ./fw.img
  172.  
  173. # check if md5sum matches
  174. root@ubuntu:/home/tomas/1# md5sum -c upgrd-pkg-1nc.wdg.md5
  175. upgrd-pkg-1nc.wdg: OK
  176.  
  177. # unpack firmware to /fw
  178. root@ubuntu:/home/tomas/1# mkdir ./fw
  179. root@ubuntu:/home/tomas/1# SKIP=`awk '/^__ARCHIVE_FOLLOWS__/ {print NR +1; exit 0 }' ./upgrd-pkg-1nc.wdg`
  180. root@ubuntu:/home/tomas/1# echo $SKIP
  181. 18
  182. root@ubuntu:/home/tomas/1# tail -n+${SKIP} ./upgrd-pkg-1nc.wdg | gunzip  | /bin/tar xm -C ./fw
  183.  
  184. # check md5sums
  185. root@ubuntu:/home/tomas/1# cd ./fw
  186. root@ubuntu:/home/tomas/1/fw# md5sum -c md5sum.lst
  187. packing.lst: OK
  188. reserve.list: OK
  189. reserve.sh: OK
  190. rootfs.arm.ext2: OK
  191. u-boot.wrapped: OK
  192. uImage: OK
  193. uImage.1: OK
  194. upgrade1.sh: OK
  195. upgrade1-xdelta.sh: OK
  196. upgrade2.sh: OK
  197. uUpgradeRootfs: OK
  198. root@ubuntu:/home/tomas/1/fw# cd ..
  199.  
  200. # mount
  201. root@ubuntu:/home/tomas/1# mkdir ./sdb1
  202. root@ubuntu:/home/tomas/1# mkdir ./sdb3
  203. root@ubuntu:/home/tomas/1# mkdir ./rootfs
  204. root@ubuntu:/home/tomas/1# mount -o rw,noatime /dev/md0 ./sdb1
  205. root@ubuntu:/home/tomas/1# mount -o rw,noatime /dev/md3 ./sdb3
  206. root@ubuntu:/home/tomas/1# mount -o loop,ro,noatime ./fw/rootfs.arm.ext2 ./rootfs
  207.  
  208.  
  209. # rootfs: copy files to /sdb1
  210. root@ubuntu:/home/tomas/1# cp -a ./rootfs/* ./sdb1
  211.  
  212. # /var: copy files to /sdb3
  213. root@ubuntu:/home/tomas/1# cp -a ./rootfs/var/* ./sdb3
  214.  
  215.  
  216. # set the factory_restore flag -> that rebuild a clean md2=sda4 after reboot
  217. root@ubuntu:/home/tomas/1# echo final_tested_ok > ./sdb1/etc/mfgtest_state
  218. root@ubuntu:/home/tomas/1# touch ./sdb1/etc/.factory_restore
  219.  
  220. # !!!! if you have a non WDC Disc !!!!!
  221. # use an editor and comment out following lines 166 and 169 in
  222. # proto/SxM_webui/admin/tools/factoryDefault.sh
  223. mdadm --assemble /dev/md0 /dev/sdb1
  224.  
  225. root@ubuntu:/home/tomas/1# cat -n ./sdb1/proto/SxM_webui/admin/tools/factoryDefault.sh | head -170l | tail -8l
  226.    163  if [ "$MODEL" != "WWLXN" ]; then
  227.    164    let DISK_COUNT=DISK_COUNT+1
  228.    165    cat /sys/block/sdb/device/model | grep WDC >/dev/null 2>&1
  229.    166  #  if [ "$?" -eq "0" ]; then
  230.    167        let WD_DISK_COUNT=WD_DISK_COUNT+1
  231.    168        DISK2=sdb
  232.    169  #  fi
  233.    170  fi
  234. # the file system is ready -> stop Raid
  235. root@ubuntu:/home/tomas/1# umount ./sdb1
  236. root@ubuntu:/home/tomas/1# umount ./sdb3
  237. root@ubuntu:/home/tomas/1# umount ./rootfs
  238. root@ubuntu:/home/tomas/1# mdadm --stop /dev/md0
  239. mdadm: stopped /dev/md0
  240. root@ubuntu:/home/tomas/1# mdadm --stop /dev/md1
  241. mdadm: stopped /dev/md1
  242. root@ubuntu:/home/tomas/1# mdadm --stop /dev/md3
  243. mdadm: stopped /dev/md3
  244. root@ubuntu:/home/tomas/1# sync
Advertisement
Add Comment
Please, Sign In to add comment