No-copy Method of DNS-321 RAID-1 Upgrade/Upsize Using Swap Partitions

Image for post
Image for post
Photo by 🇨🇭 Claudio Schwarz | @purzlbaum on Unsplash

TL;DR

Introduction

Premise

SYSTEM INFO
Firmware version: 1.03
Volume Type: RAID 1
HARD DRIVE INFO
Slot: Left
Manufacturer: WD20EFRX-68AX9N
Model: WD20EFRX-68AX9N
Size: 2000 GB
Slot: Right
Manufacturer: WD20EFRX-68AX9N
Model: WD20EFRX-68AX9N
Size: 2000 GB
# cat /proc/cpuinfo
Processor : ARM926EJ-S rev 0 (v5l)
BogoMIPS : 266.24
Features : swp half thumb fastmult edsp
CPU implementer : 0x41
CPU architecture: 5TEJ
CPU variant : 0x0
CPU part : 0x926
CPU revision : 0
Cache type : write-back
Cache clean : cp15 c7 ops
Cache lockdown : format C
Cache format : Harvard
I size : 32768
I assoc : 1
I line length : 32
I sets : 1024
D size : 32768
D assoc : 1
D line length : 32
D sets : 1024
Hardware : Feroceon
Revision : 0000
Serial : 0000000000000000

Fun_Plug

fun_plug

fun_plug.tgz

Steps

# fdisk -u=cylinders -lDisk /dev/md0: 248.0 GB, 248041439232 bytes
2 heads, 4 sectors/track, 60556992 cylinders
Units = cylinders of 8 * 512 = 4096 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/md0 doesn't contain a valid partition tableDisk /dev/sda: 2000.4 GB, 2000398934016 bytes
255 heads, 63 sectors/track, 243201 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00066296
Device Boot Start End Blocks Id System
/dev/sda1 1 311 2490240 fd Linux raid autodetect
/dev/sda2 311 572 2097152 fd Linux raid autodetect
/dev/sda3 588 243201 1948788912 f W95 Ext'd (LBA)
/dev/sda5 589 243201 1948780864 fd Linux raid autodetect
Disk /dev/sdb: 2000.4 GB, 2000398934016 bytes
255 heads, 63 sectors/track, 243201 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0003bf4a
Device Boot Start End Blocks Id System
/dev/sdb1 1 66 530113+ 82 Linux swap / Solaris
/dev/sdb2 131 243201 1952467807+ 83 Linux
/dev/sdb4 67 130 514080 83 Linux
Partition table entries are not in disk order# fdisk -lDisk /dev/md0: 248.0 GB, 248041439232 bytes
2 heads, 4 sectors/track, 60556992 cylinders, total 484455936 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/md0 doesn't contain a valid partition tableDisk /dev/sda: 2000.4 GB, 2000398934016 bytes
255 heads, 63 sectors/track, 243201 cylinders, total 3907029168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00066296
Device Boot Start End Blocks Id System
/dev/sda1 256 4980735 2490240 fd Linux raid autodetect
/dev/sda2 4980736 9175039 2097152 fd Linux raid autodetect
/dev/sda3 9437184 3907015007 1948788912 f W95 Ext'd (LBA)
/dev/sda5 9453280 3907015007 1948780864 fd Linux raid autodetect
Disk /dev/sdb: 2000.4 GB, 2000398934016 bytes
255 heads, 63 sectors/track, 243201 cylinders, total 3907029168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0003bf4a
Device Boot Start End Blocks Id System
/dev/sdb1 63 1060289 530113+ 82 Linux swap / Solaris
/dev/sdb2 2088450 3907024064 1952467807+ 83 Linux
/dev/sdb4 1060290 2088449 514080 83 Linux
Partition table entries are not in disk order
# fdisk -c=dos -u=cylinders /dev/sdaWARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (with command 'c').
WARNING: cylinders as display units are deprecated. Use command 'u' to
change units to sectors.
Command (m for help): d
Partition number (1-5): 5
Command (m for help): d
Partition number (1-5): 3
Command (m for help): d
Partition number (1-4): 2
Command (m for help): d
Selected partition 1
Command (m for help): pDisk /dev/sda: 2000.4 GB, 2000398934016 bytes
255 heads, 63 sectors/track, 243201 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00066296
Device Boot Start End Blocks Id SystemCommand (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4, default 1): 1
First cylinder (1-243201, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-243201, default 243201): 66
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4, default 2): 4
First cylinder (67-243201, default 67):
Using default value 67
Last cylinder, +cylinders or +size{K,M,G} (67-243201, default 243201): 130
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4, default 2): 2
First cylinder (131-243201, default 131):
Using default value 131
Last cylinder, +cylinders or +size{K,M,G} (131-243201, default 243201):
Using default value 243201
Command (m for help): pDisk /dev/sda: 2000.4 GB, 2000398934016 bytes
255 heads, 63 sectors/track, 243201 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00066296
Device Boot Start End Blocks Id System
/dev/sda1 1 66 530113+ 83 Linux
/dev/sda2 131 243201 1952467807+ 83 Linux
/dev/sda4 67 130 514080 83 Linux
Partition table entries are not in disk orderCommand (m for help): t
Partition number (1-4): 1
Hex code (type L to list codes): 82
Changed system type of partition 1 to 82 (Linux swap / Solaris)
Command (m for help): pDisk /dev/sda: 2000.4 GB, 2000398934016 bytes
255 heads, 63 sectors/track, 243201 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00066296
Device Boot Start End Blocks Id System
/dev/sda1 1 66 530113+ 82 Linux swap / Solaris
/dev/sda2 131 243201 1952467807+ 83 Linux
/dev/sda4 67 130 514080 83 Linux
Partition table entries are not in disk orderCommand (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
# mkswap /dev/sda1
Setting up swapspace version 1, size = 530108 KiB
no label, UUID=########-####-####-####-############
# mke2fs -j /dev/sda4
mke2fs 1.41.14 (22-Dec-2010)
warning: Unable to get device geometry for /dev/sda4
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
Stride=0 blocks, Stripe width=0 blocks
128520 inodes, 514080 blocks
25704 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=67633152
63 block groups
8192 blocks per group, 8192 fragments per group
2040 inodes per group
Superblock backups stored on blocks:
8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409
Writing inode tables: done
Creating journal (8192 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.
# mdadm --examine --scan > /etc/mdadm.conf
# mdadm --assemble --scan
# cat /proc/mdstat
Personalities : [linear] [raid0] [raid1]
md0 : active raid1 sdb2[1]
242227968 blocks [2/1] [_U]
unused devices: <none>
# mdadm /dev/md0 --add /dev/sda2
mdadm: added /dev/sda2
# cat /proc/mdstat
Personalities : [linear] [raid0] [raid1]
md0 : active raid1 sda2[0] sdb2[1]
242227968 blocks [2/2] [UU]
unused devices: <none>
# grep "/dev/md0" /etc/mtab | awk '{ print $2 }'
/mnt/HD_a2
# lsof | grep HD_a2
smbd 2364 nobody cwd DIR 9,0 4096 2 /mnt/HD_a2
# smb stop
# umount /mnt/HD_a2
# mdadm --grow /dev/md0 --size=max
mdadm: component size of /dev/md0 has been set to 1952467712K
# e2fsck -f /dev/md0
e2fsck 1.41.14 (22-Dec-2010)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
/lost+found not found. Create<y>? yes
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/md0: ***** FILE SYSTEM WAS MODIFIED *****
/dev/md0: 17493/15147008 files (2.6% non-contiguous), 58106646/60556992 blocks
# resize2fs /dev/md0
resize2fs 1.41.14 (22-Dec-2010)
Resizing the filesystem on /dev/md0 to 488116928 (4k) blocks.
The filesystem on /dev/md0 is now 488116928 (4k) blocks long.
root@arthur-server:~# e2fsck -f /dev/md0
e2fsck 1.41.14 (22-Dec-2010)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/md0: 17493/122036224 files (2.6% non-contiguous), 64817418/488116928 blocks
# mount -t ext2 -o rw,usrquota,grpquota /dev/md0 /mnt/HD_a2
# smb start
# hd_verify -w
hd verify v1.21.08122009
Force write verify to hd
WriteMagicNumToMTD 185557
WriteMagicNumToHD 185557
# **** Remove FFP tool folders and files in SWAP partitions
# rm -rf /mnt/HD_a4/ffp*
# rm -rf /mnt/HD_b4/ffp*
# cat /proc/mdstat
Personalities : [linear] [raid0] [raid1]
md0 : active raid1 sda2[0] sdb2[1]
1952467712 blocks [2/2] [UU]
unused devices: <none>

Conclusion

Written by

Love understanding how different pieces can make something beautiful. Still comprehending that building software is part engineering, art and social science.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store