Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- tomas@ubuntu:~$ sudo su
- [sudo] password for tomas:
- #clear boot partition
- root@ubuntu:/home/tomas# dd if=/dev/zero of=/dev/sdb bs=512 count=64260
- 64260+0 records in
- 64260+0 records out
- 32901120 bytes (33 MB) copied, 1.56911 s, 21.0 MB/s
- # check
- root@ubuntu:/home/tomas# /sbin/sfdisk -l /dev/sdb
- Disk /dev/sdb: 60801 cylinders, 255 heads, 63 sectors/track
- sfdisk: ERROR: sector 0 does not have an msdos signature
- /dev/sdb: unrecognized partition table type
- No partitions found
- # fdisk reads lines of the form <start> <size> <id> <bootable>
- # When a field is absent or empty, a default value is used.
- # The default value of size is as much as possible (until next partition or end-of-disk).
- root@ubuntu:/home/tomas/1# echo 4,244,fd>DSKPART
- root@ubuntu:/home/tomas/1# echo 248,32,fd>>DSKPART
- root@ubuntu:/home/tomas/1# echo 280,123,fd>>DSKPART
- root@ubuntu:/home/tomas/1# echo 403,,fd>>DSKPART
- root@ubuntu:/home/tomas/1# /sbin/sfdisk --force /dev/sdb <./DSKPART
- Disk /dev/sdb: 60801 cylinders, 255 heads, 63 sectors/track
- sfdisk: ERROR: sector 0 does not have an msdos signature
- /dev/sdb: unrecognized partition table type
- Old situation:
- No partitions found
- New situation:
- Units = cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0
- Device Boot Start End #cyls #blocks Id System
- /dev/sdb1 4 247 244 1959930 fd Linux raid autodetect
- /dev/sdb2 248 279 32 257040 fd Linux raid autodetect
- /dev/sdb3 280 402 123 987997+ fd Linux raid autodetect
- /dev/sdb4 403 60800 60398 485146935 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 ...
- # if you have a disc with partitions
- # now look for automounted raid devices and stop this raid arrays
- # in ubuntu i have md_d1 / md_d0 / md_d3
- root@ubuntu:/home/tomas/1# cat /proc/mdstat
- Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10]
- md_d1 : active raid1 sdb2[0]
- 256960 blocks [2/1] [U_]
- md_d0 : active raid1 sdb1[0]
- 1959808 blocks [2/1] [U_]
- md_d3 : active raid1 sdb3[0]
- 987904 blocks [2/1] [U_]
- # and stop this raid arrays!!
- root@ubuntu:/home/tomas/1# mdadm --stop /dev/md_d0
- root@ubuntu:/home/tomas/1# mdadm --stop /dev/md_d1
- root@ubuntu:/home/tomas/1# mdadm --stop /dev/md_d3
- root@ubuntu:/home/tomas/1# mdadm --zero-superblock /dev/sdb1
- root@ubuntu:/home/tomas/1# mdadm --zero-superblock /dev/sdb2
- root@ubuntu:/home/tomas/1# mdadm --zero-superblock /dev/sdb3
- root@ubuntu:/home/tomas/1# mdadm --zero-superblock /dev/sdb4
- # make three raid partitions (md0 md1 md3)
- # type y for "yes" !
- root@ubuntu:/home/tomas/1# mdadm --create /dev/md0 -l 1 -n 2 /dev/sdb1 missing
- mdadm: /dev/sdb1 appears to contain an ext2fs file system
- size=1959808K mtime=Thu Jan 1 01:00:02 1970
- mdadm: /dev/sdb1 appears to be part of a raid array:
- level=raid1 devices=2 ctime=Tue Feb 12 23:58:30 2008
- Continue creating array? y
- mdadm: array /dev/md0 started.
- root@ubuntu:/home/tomas/1# mdadm --create /dev/md1 -l 1 -n 2 /dev/sdb2 missing
- mdadm: /dev/sdb2 appears to be part of a raid array:
- level=raid1 devices=2 ctime=Tue Dec 8 00:07:57 2009
- Continue creating array? y
- mdadm: array /dev/md1 started.
- root@ubuntu:/home/tomas/1# mdadm --create /dev/md3 -l 1 -n 2 /dev/sdb3 missing
- mdadm: /dev/sdb3 appears to contain an ext2fs file system
- size=987904K mtime=Thu Jan 1 01:00:03 1970
- mdadm: /dev/sdb3 appears to be part of a raid array:
- level=raid1 devices=2 ctime=Tue Dec 8 00:08:06 2009
- Continue creating array? y
- mdadm: array /dev/md3 started.
- #clear 4. partition
- root@ubuntu:/home/tomas/1# dd if=/dev/zero of=/dev/sdb4 bs=512 count=1
- 1+0 records in
- 1+0 records out
- 512 bytes (512 B) copied, 0.00614513 s, 83.3 kB/s
- # format the raid partitions
- root@ubuntu:/home/tomas/1# mkfs.ext3 /dev/md0
- mke2fs 1.41.9 (22-Aug-2009)
- Filesystem label=
- OS type: Linux
- Block size=4096 (log=2)
- Fragment size=4096 (log=2)
- 122640 inodes, 489952 blocks
- 24497 blocks (5.00%) reserved for the super user
- First data block=0
- Maximum filesystem blocks=503316480
- 15 block groups
- 32768 blocks per group, 32768 fragments per group
- 8176 inodes per group
- Superblock backups stored on blocks:
- 32768, 98304, 163840, 229376, 294912
- Writing inode tables: done
- Creating journal (8192 blocks): done
- Writing superblocks and filesystem accounting information: done
- This filesystem will be automatically checked every 32 mounts or
- 180 days, whichever comes first. Use tune2fs -c or -i to override.
- root@ubuntu:/home/tomas/1# mkswap /dev/md1
- mkswap: /dev/md1: warning: don't erase bootbits sectors
- on whole disk. Use -f to force.
- Setting up swapspace version 1, size = 256956 KiB
- no label, UUID=5afd945c-90ec-4cbf-8ce2-06d25b5f8a30
- root@ubuntu:/home/tomas/1# mkfs.ext3 /dev/md3
- mke2fs 1.41.9 (22-Aug-2009)
- Filesystem label=
- OS type: Linux
- Block size=4096 (log=2)
- Fragment size=4096 (log=2)
- 61824 inodes, 246976 blocks
- 12348 blocks (5.00%) reserved for the super user
- First data block=0
- Maximum filesystem blocks=255852544
- 8 block groups
- 32768 blocks per group, 32768 fragments per group
- 7728 inodes per group
- Superblock backups stored on blocks:
- 32768, 98304, 163840, 229376
- Writing inode tables: done
- Creating journal (4096 blocks): done
- Writing superblocks and filesystem accounting information: done
- This filesystem will be automatically checked every 31 mounts or
- 180 days, whichever comes first. Use tune2fs -c or -i to override.
- # download the latest firmware - also see /proto/SxM_webui/admin/fw_chk.php
- root@ubuntu:/home/tomas/1# wget http://cache.websupport.wdc.com/wdhxnc-01.00.16.img -O ./fw.img
- --2009-12-12 16:51:41-- http://cache.websupport.wdc.com/wdhxnc-01.00.16.img
- Resolving cache.websupport.wdc.com... 81.22.36.106
- Connecting to cache.websupport.wdc.com|81.22.36.106|:80... connected.
- HTTP request sent, awaiting response... 200 OK
- Length: 48864982 (47M) [text/plain]
- Saving to: `./fw.img'
- 100%[===========================================================>] 48,864,982 145K/s in 5m 46s
- 2009-12-12 16:57:35 (138 KB/s) - `./fw.img' saved [48864982/48864982]
- # "decode" the firmware image and clean up
- dd skip=0 count=1 bs=5120 if=./fw.img of=./tmp_img1
- dd skip=15 count=1 bs=5120 if=./fw.img of=./tmp_img2
- cp ./fw.img ./fw_img.orig
- dd seek=0 count=1 bs=5120 if=./tmp_img2 of=./fw.img
- dd skip=1 seek=1 bs=5120 if=./fw_img.orig of=./fw.img
- cp ./fw.img ./fw_img.orig
- dd seek=15 count=1 bs=5120 if=./tmp_img1 of=./fw.img
- dd skip=16 seek=16 bs=5120 if=./fw_img.orig of=./fw.img
- rm ./tmp_img1
- rm ./tmp_img2
- rm ./fw_img.orig
- # extract gzipped image .tar.gz
- root@ubuntu:/home/tomas/1# tar zxf ./fw.img
- # check if md5sum matches
- root@ubuntu:/home/tomas/1# md5sum -c upgrd-pkg-1nc.wdg.md5
- upgrd-pkg-1nc.wdg: OK
- # unpack firmware to /fw
- root@ubuntu:/home/tomas/1# mkdir ./fw
- root@ubuntu:/home/tomas/1# SKIP=`awk '/^__ARCHIVE_FOLLOWS__/ {print NR +1; exit 0 }' ./upgrd-pkg-1nc.wdg`
- root@ubuntu:/home/tomas/1# echo $SKIP
- 18
- root@ubuntu:/home/tomas/1# tail -n+${SKIP} ./upgrd-pkg-1nc.wdg | gunzip | /bin/tar xm -C ./fw
- # check md5sums
- root@ubuntu:/home/tomas/1# cd ./fw
- root@ubuntu:/home/tomas/1/fw# md5sum -c md5sum.lst
- packing.lst: OK
- reserve.list: OK
- reserve.sh: OK
- rootfs.arm.ext2: OK
- u-boot.wrapped: OK
- uImage: OK
- uImage.1: OK
- upgrade1.sh: OK
- upgrade1-xdelta.sh: OK
- upgrade2.sh: OK
- uUpgradeRootfs: OK
- root@ubuntu:/home/tomas/1/fw# cd ..
- # mount
- root@ubuntu:/home/tomas/1# mkdir ./sdb1
- root@ubuntu:/home/tomas/1# mkdir ./sdb3
- root@ubuntu:/home/tomas/1# mkdir ./rootfs
- root@ubuntu:/home/tomas/1# mount -o rw,noatime /dev/md0 ./sdb1
- root@ubuntu:/home/tomas/1# mount -o rw,noatime /dev/md3 ./sdb3
- root@ubuntu:/home/tomas/1# mount -o loop,ro,noatime ./fw/rootfs.arm.ext2 ./rootfs
- # rootfs: copy files to /sdb1
- root@ubuntu:/home/tomas/1# cp -a ./rootfs/* ./sdb1
- # /var: copy files to /sdb3
- root@ubuntu:/home/tomas/1# cp -a ./rootfs/var/* ./sdb3
- # set the factory_restore flag -> that rebuild a clean md2=sda4 after reboot
- root@ubuntu:/home/tomas/1# echo final_tested_ok > ./sdb1/etc/mfgtest_state
- root@ubuntu:/home/tomas/1# touch ./sdb1/etc/.factory_restore
- # !!!! if you have a non WDC Disc !!!!!
- # use an editor and comment out following lines 166 and 169 in
- # proto/SxM_webui/admin/tools/factoryDefault.sh
- mdadm --assemble /dev/md0 /dev/sdb1
- root@ubuntu:/home/tomas/1# cat -n ./sdb1/proto/SxM_webui/admin/tools/factoryDefault.sh | head -170l | tail -8l
- 163 if [ "$MODEL" != "WWLXN" ]; then
- 164 let DISK_COUNT=DISK_COUNT+1
- 165 cat /sys/block/sdb/device/model | grep WDC >/dev/null 2>&1
- 166 # if [ "$?" -eq "0" ]; then
- 167 let WD_DISK_COUNT=WD_DISK_COUNT+1
- 168 DISK2=sdb
- 169 # fi
- 170 fi
- # the file system is ready -> stop Raid
- root@ubuntu:/home/tomas/1# umount ./sdb1
- root@ubuntu:/home/tomas/1# umount ./sdb3
- root@ubuntu:/home/tomas/1# umount ./rootfs
- root@ubuntu:/home/tomas/1# mdadm --stop /dev/md0
- mdadm: stopped /dev/md0
- root@ubuntu:/home/tomas/1# mdadm --stop /dev/md1
- mdadm: stopped /dev/md1
- root@ubuntu:/home/tomas/1# mdadm --stop /dev/md3
- mdadm: stopped /dev/md3
- root@ubuntu:/home/tomas/1# sync
Advertisement
Add Comment
Please, Sign In to add comment