Welcome! Log In Create A New Profile

Advanced

Debian on Synology RS816 (Armada 385)

Posted by zifxify 
Re: Debian on Synology RS816 (Armada 385)
July 08, 2019 02:35AM
@bodhi

I'm embarrassed!!

Having just slated a work colleague for a stupid mistake on our firewall I then notice I have doubled up on mtdparts=!!!

setenv mtdparts 'mtdparts=mtdparts=spi0.0:4m(boot),-(spi-rootfs)'

I will now try to squeeze down the crack in the floorboards
Re: Debian on Synology RS816 (Armada 385)
July 08, 2019 04:46AM
Richard,

> Having just slated a work colleague for a stupid
> mistake on our firewall I then notice I have
> doubled up on mtdparts=!!!
>
>
> setenv mtdparts
> 'mtdparts=mtdparts=spi0.0:4m(boot),-(spi-rootfs)'
>
>

Very common typo :)

-bodhi
===========================
Forum Wiki
bodhi's corner
Re: Debian on Synology RS816 (Armada 385)
July 17, 2019 10:39PM
@bodhi

I have been bribed to forego my long term leave and am back in my office.

I am under some pressure to get the RS816 back into service for a project and the whereabouts of the second unit is still unknown, I know you were also holidaying but I wasn't sure of your return date ?

If it works for you and we can get to the tutorials before our agreed mid August date that would help me a lot.

Richard
Re: Debian on Synology RS816 (Armada 385)
July 17, 2019 11:52PM
Richard,

I will be back before the 12th. If you are pressed for time with the 2nd unit for works, then please go ahead install it. Works is always more much important than what we do here :)

We'll do the tutorial whenever it is convenient, sometime in next month. Even though we won't have a stock unit to test, it should be doable.

-bodhi
===========================
Forum Wiki
bodhi's corner
Re: Debian on Synology RS816 (Armada 385)
July 18, 2019 07:57PM
@bodhi

Thanks for the update on your holiday movements and trust you are having a great break :)

I think you may have missed from my post that at this time I only have one unit, the other went missing from my desk on the first week of my holiday and no one knows where it went.

It now looks like I will need to press the unit back into service prior to your return and once deployed it may be a few months before I could release it back for the tutorials. On a more positive note this unit is stock and will be left like that for the project it is going to be used for and hence will be stock for the tutorials.

One possibility I could offer to undertake would be to do the tutorial steps alone documenting each command and output then PM those to you or just place in a clean thread for you to check and compile into the final tutorials on your return. I think I have gleaned enough knowledge to do this and where my memory is foggy I can refer to the existing thread. It would be better if we did this together, in my view, but in the circumstances maybe its an acceptable way forward ?
Re: Debian on Synology RS816 (Armada 385)
July 18, 2019 11:56PM
Richard,

> One possibility I could offer to undertake would
> be to do the tutorial steps alone documenting each
> command and output then PM those to you or just
> place in a clean thread for you to check and
> compile into the final tutorials on your return. I
> think I have gleaned enough knowledge to do this
> and where my memory is foggy I can refer to the
> existing thread. It would be better if we did this
> together, in my view, but in the circumstances
> maybe its an acceptable way forward ?

Sure, please go ahead and send me PM.

-bodhi
===========================
Forum Wiki
bodhi's corner
Re: Debian on Synology RS816 (Armada 385)
July 19, 2019 06:25AM
@bodhi

I will try to get this done over the weekend but I have just downloaded linux-5.1.7-mvebu-tld-1 and note from the config file that raid1 is compiled as a module.

CONFIG_MD_RAID1=m

This will not work for the raid installation with zImage in flash we need raid1 built in to bring the rootfs up.

We could use my kernel then sed the appropriate changes for the tutorial or skip the raid installation and just do the zImage to flash and raw hdd on a single disk using your linux-5.1.7-mvebu-tld-1 ?
Re: Debian on Synology RS816 (Armada 385)
July 19, 2019 10:22AM
Richard,

I have built and tested 5.1.11-mvebu-tld-1, which will provide built-in kernel modules for RAID and LVM. But I have not released it.

Quote

- Enable RAID and LVM as kernel builtin modules (we can boot with RAID or LVM without needing to load uInitrd first. In previous kernel version RAID and LVM drivers were loadable modules).

You can assume that it will be in the Debian Buster rootfs Debian-5.1.11-mvebu-tld-1-rootfs-bodhi.tar.bz2.

-bodhi
===========================
Forum Wiki
bodhi's corner
Re: Debian on Synology RS816 (Armada 385)
September 25, 2019 02:59AM
Hi Richard,

A reminder that the new kernel needs some changes in u-boot envs.

Linux Kernel 5.2.9 MVEBU package and Debian armhf rootfs

Quote

...
Latest released kernel: linux-5.2.9-mvebu-tld-1 (20 Aug 2019)
...

Updated 20 Aug 2019:

Kernel linux-5.2.9-mvebu-tld-1 package has been uploaded.

New in this release:

- Keep MTD and NAND drivers as builtin kernel drivers (to overcome a mainline kernel regression for MTD and NAND).
- Pickup security patches from mainline.

Important Note for all boxes: The new kernel zImage has increased in size significantly that it will no longer work to be used in booting with the Marvell u-boot typically installed in these Armada boxes. To make it more resilient (avoid messing with u-boot envs again when the kernel image size increases), from this kernel version, we need to boot with uImage. Please see this post for an example how to adjust u-boot envs using the Thecus N2350

Basically, we need to boot with uImage starting this version linux-5.2.9-mvebu-tld-1. So let's go back to the RS816 booting envs and modify that.

When you boot with kernel in flash, then you need to copy uImage to flash (previously was zImage).

-bodhi
===========================
Forum Wiki
bodhi's corner



Edited 1 time(s). Last edit at 09/25/2019 03:26AM by bodhi.
Re: Debian on Synology RS816 (Armada 385)
September 25, 2019 03:26AM
Richard,

Please post your current u-boot envs here. I think I've lost track of what is the latest envs to boot from SPI flash. A few month off will do that :)

-bodhi
===========================
Forum Wiki
bodhi's corner
Re: Debian on Synology RS816 (Armada 385)
September 25, 2019 03:34AM
@bodhi
Ah, I had missed that bit, basically I didn't read any of the post I just grabbed the rootfs.

I hadn't had any issues with my own setup because my kernel is stripped back to bare essentials and still quite small, hence I didn't stop to think something may have changed.

I'm a bit confused though I thought uImage was an initramfs plus a u-boot header and hence would't that be bigger than zImage ? Anyway I best go read the thread first which may have the answers waiting for me :-)

Richard
Re: Debian on Synology RS816 (Armada 385)
September 25, 2019 03:45AM
@bodhi
Memory refreshed
So zImage with dtb embedded avoiding the need to load the dtb separately.

I will have a go at this tomorrow.

Richard
Re: Debian on Synology RS816 (Armada 385)
September 25, 2019 05:13AM
@bodhi

That worked :-)
Booted with usb envs

setenv ipaddr 192.168.1.19
setenv serverip 192.168.1.1
setenv usb_setup 'setenv usbActive 1; setenv usbType 3; usb start;'                
setenv load_initrd_addr 0x3000000
setenv load_image_addr 0x02000000
setenv load_image 'echo loading uImage from tftpserver ...; tftpboot $load_image_addr uImage'
setenv load_initrd 'echo loading uInitrd from tftpserver ...; tftpboot $load_initrd_addr uInitrd'
setenv set_bootargs 'setenv bootargs "console=ttyS0,115200 root=LABEL=rootfs rootdelay=20 $mtdparts earlyprintk=serial"'
setenv bootcmd_exec 'echo Booting Debian . . .; run usb_setup;  run set_bootargs; setenv fdt_skip_update yes; setenv initrd_high 0xffffffff; run load_image; run load_initrd; bootm $load_image_addr $load_initrd_addr'
setenv bootcmd 'run bootcmd_exec; run bootspi'

I guess for the tutorial it would be a good idea to recover the space currently reserved for the DTB our current split is

setenv mtdparts 'mtdparts=spi0.0:896k(u-boot),64k(dtb),7104k(kernel),-(env)'

And would become
setenv mtdparts 'mtdparts=spi0.0:896k(u-boot),7168k(kernel),-(env)'

The bit I still haven't got my head around is the final boot envs (I really do need to learn address calculations) Our current final envs are:
setenv mtdparts 'mtdparts=spi0.0:896k(u-boot),64k(dtb),7104k(kernel),-(env)'

setenv boot_config_spi 'setenv image_addr_spi 0x0F0000; setenv image_size_spi 0x006f0000; setenv dtb_addr_spi 0x0E0000; setenv dtb_size_spi 0x010000; sf probe 0 50000000'

setenv load_image_spi 'echo loading zImage from flash ...; sf read $load_image_addr $image_addr_spi $image_size_spi'

setenv load_dtb_spi 'echo loading DTB from flash ...; sf read $loadaddr_dt $dtb_addr_spi $dtb_size_spi'

setenv set_bootargs 'setenv bootargs "console=ttyS0,115200 root=/dev/md0 rootdelay=20  $mtdparts earlyprintk=serial"'

setenv bootcmd_exec 'echo Booting Debian ...; run set_bootargs; setenv fdt_skip_update yes; setenv initrd_high 0xffffffff; run boot_config_spi; run load_image_spi; run load_dtb_spi; bootz $load_image_addr - $load_dtb_addr'

setenv bootcmd 'mw 0xf10a2620 0x251; mw 0xf10a2e20 0x251; usb xhciinit; run bootcmd_exec; run bootspi'

Can you point me in the right direction boot_config_spi bit please.

Richard

EDIT
Missed your last post I think I was posting at the same time.



Edited 1 time(s). Last edit at 09/25/2019 05:24AM by richjn.
Re: Debian on Synology RS816 (Armada 385)
September 25, 2019 05:34AM
Hi Richard,

I did keep notes on the SPI flash and the calculation. This is something quite tedious that we don't want to recreate. So I will take a look to refresh my memory.

If you could, in a single post, list the other envs set when we test reading kernel uImage and uInitrd from HDD.

I guess I need to take some time do a reread on what we did! I actually forgot the details about the various boot envs options on this box :)) there has been a lot happening for me personally in the last few months (nothing bad) and that put other things in the brain cells storage somewhere.

-bodhi
===========================
Forum Wiki
bodhi's corner
Re: Debian on Synology RS816 (Armada 385)
September 25, 2019 05:47AM
@bodhi

>> If you could, in a single post, list the other envs set when we test reading kernel uImage and uInitrd from HDD.
No problem but it will be tomorrow before I can get on to it.

Perhaps its easier for both of us just to leave the MTD partitions as is it's only 64k at the end of the day, I'm fairly confident I can modify our existing envs to just remove the DTB bits, That would resolve the uImage in NAND install for a raid tutorial or were you wanting to revisit uImage in HDD raw sector install as well for an alternate install option in the tutorial ?

Richard
Re: Debian on Synology RS816 (Armada 385)
September 25, 2019 06:19AM
Richard,

richjn Wrote:
-------------------------------------------------------
> @bodhi
>
> >> If you could, in a single post, list the other
> envs set when we test reading kernel uImage and
> uInitrd from HDD.
> No problem but it will be tomorrow before I can
> get on to it.

Please take your time! I will busy tomorrow.

>
> Perhaps its easier for both of us just to leave
> the MTD partitions as is it's only 64k at the end
> of the day, I'm fairly confident I can modify our
> existing envs to just remove the DTB bits

That's what my thinking too. We should not remove DTB mtd. It might come back in use someday. Only 64KB anyway.

> That
> would resolve the uImage in NAND install for a
> raid tutorial or were you wanting to revisit
> uImage in HDD raw sector install as well for an
> alternate install option in the tutorial ?
>

I like to make uImage and uInitrd in raw sector HDD rootfs the 1st section.
The 2nd would be uImage in flash and RAID (your configuration).

We should think of the 3rd section later.

-bodhi
===========================
Forum Wiki
bodhi's corner
Re: Debian on Synology RS816 (Armada 385)
September 25, 2019 04:05PM
@bodhi

For a single HDD Raw sector install our final approach was:

Prepare uImage
cd /boot
cp -a zImage zImage.fdt
cat /boot/dts/armada-385-synology-rs816.dtb >> zImage.fdt
mkimage -A arm -O linux -T kernel -C none -a 0x00008000 -e 0x00008000 -n Linux-5.2.9-mvebu-tld-1 -d zImage.fdt uImage

DD to HDD
dd if=uImage of=/dev/sda bs=1M seek=10

And boot env
Marvell>> scsi init
Marvell>> setenv load_image_addr 0x02000000
Marvell>> setenv load_image 'echo loading uImage from raw HDD ...; scsi device 0; scsi read $load_image_addr 0x5000 0x2F00'
Marvell>> setenv set_bootargs 'setenv bootargs "console=ttyS0,115200 root=/dev/sda1 rootdelay=20 $mtdparts earlyprintk=serial"'
Marvell>> setenv bootcmd_exec 'echo Booting Debian . . .; run set_bootargs; setenv fdt_skip_update yes; setenv initrd_high 0xffffffff; run load_image; bootm $load_image_addr'
Marvell>> setenv bootcmd 'run bootcmd_exec; run bootspi'

For a single HDD gpt partition ext4 the install procedure is just zImage in NAND and the same boot env except LABEL= wont work

setenv set_bootargs 'setenv bootargs "console=ttyS0,115200 root=/dev/sda2 initrd=/dev/sda1/initrd.img-5.2.9-tld-1 rootdelay=20  $mtdparts earlyprintk=serial"'

My memory was in the end we didn't need the initrd= bit but it does no harm to have it there.
Also in a multi disk install /dev/sda is the second drive from the left /dev/sdb the first drive so people adding drives after the initial install will need to adjust envs to account for this. This is one of the reasons this type of install was unattractive to me.

Richard

EDIT 2
We would need to incorporate the "scsi init" into a saveable env in the Raw sector method.



Edited 2 time(s). Last edit at 09/25/2019 05:18PM by richjn.
Re: Debian on Synology RS816 (Armada 385)
September 26, 2019 04:48AM
@bodhi

I have re-run the install procedure using uImage and everything works out ok but I have added some issues / suggestions for the Buster rootfs to the bottom of this post.

To boot from USB rootfs we use:
setenv ipaddr 192.168.1.19 
setenv serverip 192.168.1.1 
setenv usb_setup 'setenv usbActive 1; setenv usbType 3; usb start;' 
setenv load_dtb_addr 0x1000000 
setenv load_initrd_addr 0x3000000 
setenv load_image_addr 0x02000000 
setenv load_image 'echo loading zImage from tftpserver ...; tftpboot $load_image_addr zImage' 
setenv load_initrd 'echo loading uInitrd from tftpserver ...; tftpboot $load_initrd_addr uInitrd' 
setenv load_dtb 'echo loading DTB from tftpserver ...; tftpboot $load_dtb_addr armada-385-synology-rs816.dtb' 
setenv set_bootargs 'setenv bootargs "console=ttyS0,115200 root=LABEL=rootfs rootdelay=20 $mtdparts earlyprintk=serial"' 
setenv bootcmd_exec 'echo Booting Debian . . .; run usb_setup; run set_bootargs; setenv fdt_skip_update yes; setenv initrd_high 0xffffffff; run load_image; run load_initrd; run load_dtb; bootz $load_image_addr $load_initrd_addr $load_dtb_addr' 
setenv bootcmd 'run bootcmd_exec; run bootspi' 
boot

After the rootfs install we reboot still from tftp but booting to /dev/md0 not the USB with:
Marvell>> 
setenv ipaddr 192.168.1.250 
setenv serverip 192.168.1.1 
setenv load_image_addr 0x02000000 
setenv load_image 'echo loading uImage from tftpserver ...; tftpboot $load_image_addr uImage'
setenv set_bootargs 'setenv bootargs "console=ttyS0,115200 root=/dev/md0 rootdelay=20 $mtdparts earlyprintk=serial"' 
setenv bootcmd_exec 'echo Booting Debian . . .; run set_bootargs; setenv fdt_skip_update yes; setenv initrd_high 0xffffffff; run load_image; bootm $load_image_addr -' 
setenv bootcmd 'run bootcmd_exec; run bootspi' 
boot
From here we can backup the original MTD partitions and sort out fw_config etc we then reboot with the above but adding mtdparts as:
mtdparts 'mtdparts=spi0.0:896k(u-boot),64k(dtb),7104k(kernel),-(env)'
We can then create the flash images and install those before a final reboot to set the saveable envs as:
setenv mtdparts 'mtdparts=spi0.0:896k(u-boot),64k(dtb),7104k(kernel),-(env)' 
setenv boot_config_spi 'setenv image_addr_spi 0x0F0000; setenv image_size_spi 0x006f0000; sf probe 0 50000000' 
setenv load_image_spi 'echo loading uImage from flash ...; sf read $load_image_addr $image_addr_spi $image_size_spi' 
setenv set_bootargs 'setenv bootargs "console=ttyS0,115200 root=/dev/md0 rootdelay=20 $mtdparts earlyprintk=serial"' 
setenv bootcmd_exec 'echo Booting Debian ...; run set_bootargs; setenv fdt_skip_update yes; setenv initrd_high 0xffffffff; run boot_config_spi; run load_image_spi; bootm $load_image_addr -' 
setenv bootcmd 'run bootcmd_exec; run bootspi' 
saveenv


A couple of issues / suggestions with your Buster rootfs

1) parted is not installed although its not essential it is what I have used for the tutorial. Obviously it can be installed once the usb rootfs is booted but probably better if it were already installed.

2) mdadm is not installed, this is a bigger issue because although you can install it from the usb rootfs you then need to cary out extra steps to get things to work including having to recreate tftp images once you have a raid setup prior to rebooting for next step of the install. In addition you having to install it again once you have chrooted. It's only my view but I think this one should be attended to sooner rather than later. If it helps I can upload a copy of your rootfs where the only additions I have made are to install parted, mdadm and lvm2 ? (lvm2 is the next suggestion)

3) Just a suggestion but would it be an idea to add lvm2 to the rootfs ? Although I personally have no interest in it Synology does use it and others may want to where having it already installed in the rootfs is an advantage for the same reasons as mdadm.



Edited 1 time(s). Last edit at 09/26/2019 05:05AM by richjn.
Re: Debian on Synology RS816 (Armada 385)
September 26, 2019 02:39PM
PLEASE DO NOT ATTEMPT TO USE THIS DRAFT TUTORIAL UNTIL IT HAS BEEN MOVED TO THE WIKI

@bodhi
Draft tutorial

Synology RS816 tutorial
In this turorial we will install native Debian onto the RS816 utilising the exsisting disks in a raid setup. As with all things Linux there are numorous ways you could ammend these instructions to end up with your chosen configuration, this tutorial makes no attempt to cover those options and leaves those decisions up to the individual to decide.

Please note this tutorial will lead to the destruction of all existing data so remember to BACKUP FIRST.

There are four main steps to the tutorial plus an extra step if you choose to return to stock Synology:

A) Prepare the installation media (this media can then be used for any of the supported devices listed HERE)

B) Re-partition the HDD's, install the rootfs then chroot into the new install and adjust configurations

C) Backup the exsisting NAND partitions, prepare flash images and re-flash NAND

D) Make final adjutments to boot envs

E) Restore the saved NAND partitions and default envs in case you wish to return the NAS to stock.


Part A) Prepare USB media

1) Download the Debian Buster rootfs Debian-5.2.9-mvebu-tld-1-rootfs-bodhi.tar.bz2 from https://forum.doozan.com/read.php?2,32146
This tarball includes kernel image 5.2.9-mvebu-tld-1

2) From any linux box we prepare your USB media by creating a single partition and formatting it to ext3 with a label of "rootfs" my USB is recognised as /dev/sdb1 adjust to suit your actual device.

Partition
parted /dev/sdb 
GNU Parted 3.2 
Using /dev/sdb 
Welcome to GNU Parted! Type 'help' to view a list of commands. 
(parted) mklabel msdos 
(parted) mkpart primary 0% 100% 
(parted) q
Format new partition
mkfs.ext3 -L rootfs /dev/sdb1

3) Mount the USB and extract the downloaded rootfs tarball onto it also copy the tarball to the USB for later use.
mount /dev/sdb1 /mnt
tar -C /mnt -xjvf Debian-5.2.9-mvebu-tld-1-rootfs-bodhi.tar.bz2 
sync && sync 
cp -a Debian-5.2.9-mvebu-tld-1-rootfs-bodhi.tar.bz2 /mnt/root && sync

4) Prepare boot images and copy to your tftp server root in my case this is /var/tftpboot adjust to suit your own.
cd /boot
cp -a zImage-5.2.9-mvebu-tld-1 zImage.fdt
cat dts/armada-385-synology-rs816.dtb >> zImage.fdt
mkimage -A arm -O linux -T kernel -C none -a 0x00008000 -e 0x00008000 -n Linux-5.2.9-mvebu-tld-1 -d zImage.fdt uImage
mkimage -A arm -O linux -T ramdisk -C gzip -a 0x00000000 -e 0x00000000 -n initramfs-5.2.9-mvebu-tld-1 -d initrd.img-5.2.9-mvebu-tld-1 uInitrd
cp -a uImage uInitrd /var/tftpboot/ 
cd 
umount /dev/sdb1
The USB media is now ready for use.

Part B) Re-partition the HDD's, install the rootfs then chroot into the new install and adjust configurations

You have backed up your data haven't you!! Your data will not be recoverable after following the next steps

1) Partially remove the HDD's from the drive bays, this is important because it ensures the USB is recognised as /dev/sda and makes mistakes less likely whilst also simplifying later commands.

2) Hook up a serial console to your RS816 I used putty here (set speed to 115200) start the RS816 and interrupt the boot by spamming Control + c

3) From the Marvell>> prompt enter the following one line at a time but adjust to suit the actual ip address of your tftp server.
setenv ipaddr 192.168.1.19
setenv serverip 192.168.1.1
setenv usb_setup 'setenv usbActive 1; setenv usbType 3; usb start;'                
setenv load_initrd_addr 0x3000000
setenv load_image_addr 0x02000000
setenv load_image 'echo loading uImage from tftpserver ...; tftpboot $load_image_addr uImage'
setenv load_initrd 'echo loading uInitrd from tftpserver ...; tftpboot $load_initrd_addr uInitrd'
setenv set_bootargs 'setenv bootargs "console=ttyS0,115200 root=LABEL=rootfs rootdelay=20 $mtdparts earlyprintk=serial"'
setenv bootcmd_exec 'echo Booting Debian . . .; run usb_setup;  run set_bootargs; setenv fdt_skip_update yes; setenv initrd_high 0xffffffff; run load_image; run load_initrd; bootm $load_image_addr $load_initrd_addr'
setenv bootcmd 'run bootcmd_exec; run bootspi'
boot

4) Login and prepare install enviroment (default root password is "root")
Now re-insert the HDD drives into their bays and allow time to spin up.
In this tutorial we using a 30GB 4 drive raid1 for the rootfs 2GB raid1 for swap and the remainder raid10 for data.
This following will work regardless of the size of your HDD's but you can adjust to use any raid level or mount point to suit your needs.
Check for automatically started arrays
cat /proc/mdstat
You may see a number of entries like below or no entries
Personalities : [linear] [raid0] [raid1] [raid10] [raid6] [raid5] [raid4] [multipath] [faulty]
md127 : active (auto-read-only) raid10 sde3[2] sdd3[3] sdc3[1] sdb3[0] 
7804393088 blocks super 1.2 64K chunks 2 near-copies [4/4] [UUUU] 

unused devices: <none>
For each entry you see you need to run the following, in this case only md127 showed up
mdadm --manage --stop /dev/md127
And recheck
cat /proc/mdstat 
Personalities : [linear] [raid0] [raid1] [raid10] [raid6] [raid5] [raid4] [multipath] [faulty]
unused devices: <none>
Re-run the above command until you see the above output.
Next we delete the raid super blocks you can safley ignore any "Unrecognised md component device" errors
mdadm --zero-superblock /dev/sd[b-e]1 
mdadm --zero-superblock /dev/sd[b-e]2 
mdadm --zero-superblock /dev/sd[b-e]3 
mdadm --zero-superblock /dev/sd[b-e]4 
mdadm --zero-superblock /dev/sd[b-e]5 
mdadm --zero-superblock /dev/sd[b-e]6
We then re-partition the disks again adjust to suit your own needs, you can ignore any errors from systemd-udevd.
parted /dev/sdb 
(parted) p 
Model: ATA ST4000VN008-2DR1 (scsi) 
Disk /dev/sdb: 4001GB 
Sector size (logical/physical): 512B/4096B 
Partition Table: gpt 
Disk Flags: 

Number Start End Size File system Name Flags 
1 1049kB 2551MB 2550MB ext4 raid 
2 2551MB 4699MB 2147MB linux-swap(v1) raid 
3 4832MB 4001GB 3996GB raid
For each listed partition run (in my case there are 3)
(parted) rm 1
(parted) rm 2 
(parted) rm 3
We then add a new partition table.
(parted) mklabel gpt 
Warning: The existing disk label on /dev/sdb will be destroyed and all data on 
this disk will be lost. Do you want to continue? 
Yes/No? yes
And create our new partions.
(parted) mkpart primary 0% 30GiB 
(parted) mkpart primary 30GiB 32GiB 
(parted) mkpart primary 32GiB 100% 
(parted) set 1 raid on 
(parted) set 2 raid on 
(parted) set 3 raid on
You should now have a table layout similar to below dependant on the size of your disks.
(parted) p 
Model: ATA ST4000VN008-2DR1 (scsi) 
Disk /dev/sdb: 4001GB 
Sector size (logical/physical): 512B/4096B 
Partition Table: gpt 
Disk Flags: 

Number Start End Size File system Name Flags 
1 1049kB 32.2GB 32.2GB primary raid 
2 32.2GB 34.4GB 2147MB primary raid 
3 34.4GB 4001GB 3966GB primary raid
We can now exit parted
(parted) q
Repeat the above process for /dev/sdc /dev/sdd and /dev/sde
We then create the arrays again confirm and ignore any errors by entering "y"
We start with 30GB raid 1 for rootfs
mdadm --create /dev/md0 --level=1 --meta=0.9 --raid-devices=4 /dev/sd[b-e]1
Check progress until it completes its sync (about 5 mins)
cat /proc/mdstat 
Personalities : [linear] [raid0] [raid1] [raid10] [raid6] [raid5] [raid4] [multipath] [faulty]
md0 : active raid1 sde1[3] sdd1[2] sdc1[1] sdb1[0] 
31456192 blocks [4/4] [UUUU] 
[=========>...........] resync = 46.6% (14677056/31456192) finish=2.1min speed=130101K/sec 

unused devices: <none>
And then onto 2GB raid1 for swap
mdadm --create /dev/md1 --level=1 --meta=0.9 --raid-devices=4 /dev/sd[b-e]2
And check progress as above until it completes sync
And lastly the remainder of the disk capacity raid10 for data or home partition Note: not stating --meta= will default to meta 1.2 which is what we want.
mdadm --create /dev/md10 --level=10 --raid-device=4 /dev/sd[b-e]3
And check sync is progreesing we will not wait for this as it can take a while but do not write data to it untill it has finnished, the remainder of this tutorial only writes minimal data there. You should see an output similar to below.
cat /proc/mdstat 
Personalities : [linear] [raid0] [raid1] [raid10] [raid6] [raid5] [raid4] [multipath] [faulty]
md10 : active raid10 sde3[3] sdd3[2] sdc3[1] sdb3[0] 
7746662400 blocks super 1.2 512K chunks 2 near-copies [4/4] [UUUU] 
[>....................] resync = 0.2% (20792448/7746662400) finish=642.3min speed=200454K/sec 
bitmap: 58/58 pages [232KB], 65536KB chunk 

md1 : active raid1 sde2[3] sdd2[2] sdc2[1] sdb2[0] 
2097088 blocks [4/4] [UUUU] 

md0 : active raid1 sde1[3] sdd1[2] sdc1[1] sdb1[0] 
31456192 blocks [4/4] [UUUU] 

unused devices: <none>

5) Format our new raids, mount them and extract the rootfs to it. The USB was prepared using ext3 which ensures compatability with all supported devices but the RS816 is fine with ext4 which is what I use here.
Rootfs (you can ignore errors about existing filesystems and confirm 'y')
mkfs.ext4 /dev/md0
Swap
mkswap /dev/md1
Data / Home
mkfs.ext4 /dev/md10
And mount them to mount, I am mounting the raid10 array to /home but adjust to suit your needs.
mount /dev/md0 /mnt 
mkdir /mnt/home 
mount /dev/md10 /mnt/home 
swapon /dev/md1
Next we extract the copy of the rootfs we took earlier onto our new partitions
tar -C /mnt -xjvf Debian-5.1.11-mvebu-tld-1-rootfs-bodhi.tar.bz2 
sync && sync

6) chroot into our new install and configure the enviroment
mount -t proc proc /mnt/proc 
mount --rbind /sys /mnt/sys 
mount --rbind /dev /mnt/dev 
chroot /mnt /bin/bash
Setup /etc/fstab below is mine adjust to suit yours
cat /etc/fstab 
# <file system> <mount point> <type> <options> <dump> <pass> 
/dev/md0 / ext4 errors=remount-ro 0 1 
/dev/md1 none swap defaults 0 0 
/dev/md10 /home ext4 defaults 0 2 
tmpfs /tmp tmpfs defaults 0 0
Setup /etc/mdadm/mdadm.conf first we check it looks sensible then redirect the otput to the config file and finaly edit it.
mdadm --detail --scan 
ARRAY /dev/md0 metadata=0.90 UUID=86ae6e16:d98a9a28:9d4deba6:47ca997f 
ARRAY /dev/md1 metadata=0.90 UUID=1d9000c5:4c90cacf:9d4deba6:47ca997f 
ARRAY /dev/md10 metadata=1.2 name=debian:10 UUID=a6ef8383:52ce1289:a164b5e8:d6d74079

mdadm --detail --scan >> /etc/mdadm/mdadm.conf
Heres my mdadm.conf the important bits are "DEVICE partitions" and to check the arrays are present.
cat /etc/mdadm/mdadm.conf 
DEVICE partitions 
HOMEHOST <system> 
MAILADDR root 

ARRAY /dev/md0 metadata=0.90 UUID=86ae6e16:d98a9a28:9d4deba6:47ca997f 
ARRAY /dev/md1 metadata=0.90 UUID=1d9000c5:4c90cacf:9d4deba6:47ca997f 
ARRAY /dev/md10 metadata=1.2 name=debian:10 UUID=a6ef8383:52ce1289:a164b5e8:d6d74079
Next we regenerate the boot images note: uInitrd is not needed here.
update-initramfs -u
Edit /etc/fw_env.config as below.
cat /etc/fw_env.config 
# MTD device name Device offset Env. size Flash sector size Number of sectors 
/dev/mtd1 0x0000 0x80000 0x20000
Set a new root password
passwd
This stage is now complete and we exit the system.
exit 
poweroff

Part C) Backup the exsisting NAND partitions, prepare flash images and re-flash NAND

Boot the system and interupt by spamming Control + c then from the Marvell>> prompt enter the following
setenv ipaddr 192.168.1.250 
setenv serverip 192.168.1.1 
setenv load_image_addr 0x02000000 
setenv load_image 'echo loading uImage from tftpserver ...; tftpboot $load_image_addr uImage'
setenv set_bootargs 'setenv bootargs "console=ttyS0,115200 root=/dev/md0 rootdelay=20 $mtdparts earlyprintk=serial"' 
setenv bootcmd_exec 'echo Booting Debian . . .; run set_bootargs; setenv fdt_skip_update yes; setenv initrd_high 0xffffffff; run load_image; bootm $load_image_addr -' 
setenv bootcmd 'run bootcmd_exec; run bootspi' 
boot
First we take backups of the mtd's in case we want to revert
Check existing mtds look like the following if not stop do not continue!! and ask for help on this forum
cat /proc/mtd 
dev: size erasesize name 
mtd0: 00400000 00001000 "boot" 
mtd1: 00400000 00001000 "spi-rootfs"
If all good then proceed
dd if=/dev/mtd0 of=mtd0.stock.rs816 bs=4096k conv=sync 
dd if=/dev/mtd1 of=mtd1.stock.rs816 bs=4096k conv=sync
Copy them somewhere safe, here I'm copying them to another server with scp
scp mtd0.stock.rs816 mtd1.stock.rs816 root@192.168.1.1:/root/
Next we reboot setting up the enviroment to flash uImage, reboot and interupt boot again.
setenv ipaddr 192.168.1.250 
setenv serverip 192.168.1.1 
setenv mtdparts 'mtdparts=spi0.0:896k(u-boot),64k(dtb),7104k(kernel),-(env)' 
setenv load_image_addr 0x02000000 
setenv load_image 'echo loading uImage from tftpserver ...; tftpboot $load_image_addr uImage'
setenv set_bootargs 'setenv bootargs "console=ttyS0,115200 root=/dev/md0 rootdelay=20 $mtdparts earlyprintk=serial"' 
setenv bootcmd_exec 'echo Booting Debian . . .; run set_bootargs; setenv fdt_skip_update yes; setenv initrd_high 0xffffffff; run load_image; bootm $load_image_addr -' 
setenv bootcmd 'run bootcmd_exec; run bootspi' 
boot
Check mtd's look like the following if not stop do not continue!! and ask for help on these forums
cat /proc/mtd 
dev: size erasesize name 
mtd0: 000e0000 00001000 "u-boot" 
mtd1: 00010000 00001000 "dtb" 
mtd2: 006f0000 00001000 "kernel" 
mtd3: 00020000 00001000 "env"
If all good we prepare the uImage
cp -a /boot/zImage-5.2.9-mvebu-tld-1 zImage.fdt
cat /boot/dts/armada-385-synology-rs816.dtb >> zImage.fdt
mkimage -A arm -O linux -T kernel -C none -a 0x00008000 -e 0x00008000 -n Linux-5.2.9-mvebu-tld-1 -d zImage.fdt uImage
dd if=uImage of=rs816.uImage.mtd2.kwb bs=7104k conv=sync
Now we flash the images
flashcp -v rs816.uImage.mtd2.kwb /dev/mtd2

Part D) Make final adjutments to boot envs

Reboot and interupt again to Marvel>>
setenv mtdparts 'mtdparts=spi0.0:896k(u-boot),64k(dtb),7104k(kernel),-(env)' 
setenv boot_config_spi 'setenv image_addr_spi 0x0F0000; setenv image_size_spi 0x006f0000; sf probe 0 50000000' 
setenv load_image_spi 'echo loading uImage from flash ...; sf read $load_image_addr $image_addr_spi $image_size_spi' 
setenv set_bootargs 'setenv bootargs "console=ttyS0,115200 root=/dev/md0 rootdelay=20 $mtdparts earlyprintk=serial"' 
setenv bootcmd_exec 'echo Booting Debian ...; run set_bootargs; setenv fdt_skip_update yes; setenv initrd_high 0xffffffff; run boot_config_spi; run load_image_spi; bootm $load_image_addr -' 
setenv bootcmd 'run bootcmd_exec; run bootspi' 
saveenv
And finally
reset
Allow to reboot and enjoy!

Part E) Restore the saved NAND partitions and default envs in case you wish to return the NAS to stock.

Interupt boot by spamming Control + c and enter the following.
setenv mtdparts 'mtdparts=spi0.0:4m(boot),-(spi-rootfs)'
boot
Check mtd's look like the following if not stop do not continue!! and ask for help on these forums
cat /proc/mtd 
dev: size erasesize name 
mtd0: 00400000 00001000 "boot" 
mtd1: 00400000 00001000 "spi-rootfs"
If all good we can re-flash the mtd's
flashcp -v mtd0.stock.rs816.kwb /dev/mtd0
flashcp -v mtd1.stock.rs816.kwb /dev/mtd1
We now reboot and interupt again to the Marvell>> prompt.
setenv mtdparts 'mtdparts=spi0.0:4m(boot),-(spi-rootfs)'
setenv bootcmd 'mw 0xf10a2620 0x251;mw 0xf10a2e20 0x251;usb xhciinit; run bootspi'
saveenv
reset
Allow to reboot and you can now discover the NAS via Synology discovery and commence a clean install.

EDIT
Copy pasted the wrong boot env at Part B step 3)

EDIT 2
A few heading changes no changes to commands



Edited 5 time(s). Last edit at 09/27/2019 03:34PM by richjn.
Re: Debian on Synology RS816 (Armada 385)
September 26, 2019 02:47PM
Are you planning to configure flash-kernel to automate updating the uImage for this device?
Re: Debian on Synology RS816 (Armada 385)
September 26, 2019 03:16PM
Thanks Richard!

I will take a close read and post again.

-bodhi
===========================
Forum Wiki
bodhi's corner
Re: Debian on Synology RS816 (Armada 385)
September 26, 2019 04:05PM
1000001101000 Wrote:
-------------------------------------------------------
> Are you planning to configure flash-kernel to
> automate updating the uImage for this device?

Actually I had not even heard of flash-kernel, sounds like a good idea but I will leave that for others to add as I have no experience of it.

Richard
Re: Debian on Synology RS816 (Armada 385)
September 26, 2019 04:07PM
bodhi Wrote:
-------------------------------------------------------
> Thanks Richard!
>
> I will take a close read and post again.


I did a silly copy paste of the wrong set of env, I have edited the tutorial.

Richard
Re: Debian on Synology RS816 (Armada 385)
September 26, 2019 04:21PM
1000001101000 Wrote:
-------------------------------------------------------
> Are you planning to configure flash-kernel to
> automate updating the uImage for this device?

I don't plan to add that to the rootfs. I prefer to generate the uboot images for kernel files manually.

-bodhi
===========================
Forum Wiki
bodhi's corner
Re: Debian on Synology RS816 (Armada 385)
September 26, 2019 04:49PM
right on

. I'm not sure how I'd feel about it if I was flashing mtdblock devices but it makes kernel updates pretty painless when booting from a disk.
Re: Debian on Synology RS816 (Armada 385)
September 26, 2019 06:10PM
Post deleted



Edited 1 time(s). Last edit at 09/26/2019 08:55PM by richjn.
Re: Debian on Synology RS816 (Armada 385)
September 26, 2019 08:19PM
Richard,


> In case it is useful I have uploaded your Buster
> rootfs to the link below.
It's unchanged apart
> from the installation of parted, mdadm and lvm2.

Please don't do that :) When you have modified the released rootfs, it should not be called the same name.

The released tarball has md5 and sha256 hashes associated with it. That's how people can be sure about its integrity.

I don't think a special tarball is needed. I will markup the installation instruction when I have time to do it.

Please remove the link.

-bodhi
===========================
Forum Wiki
bodhi's corner



Edited 2 time(s). Last edit at 09/26/2019 08:27PM by bodhi.
Re: Debian on Synology RS816 (Armada 385)
September 26, 2019 09:01PM
@bodhi
I was just trying to save you some time and had intended the download for you only with the thought you would replace your own Buster rootfs download with it and obviously update your md5 hashes etc. I have nonetheless removed the link as you requested.

bodhi Wrote:
-------------------------------------------------------
> I don't think a special tarball is needed.

I don't agree with you on that one I'm afraid.

Richard
Re: Debian on Synology RS816 (Armada 385)
September 27, 2019 04:48PM
Thanks Richard!

-bodhi
===========================
Forum Wiki
bodhi's corner
Re: Debian on Synology RS816 (Armada 385)
September 27, 2019 08:09PM
@bodhi

Please don't read the following as me suggesting you should drop everything else / give up your weekend for this but I thought I should at least make you aware of upcoming events.

The RS816 has been returned to stock in preparation for a new contract we have secured commencing next week, however, it is a public holiday weekend here (Monday off) so it would be possible to do a full test run of any changes you wish to make to the tutorial to the extent you felt those changes warranted testing up to and including Monday.

If that proves undoable I am happy to test procedures after this contract ends which is about 4 weeks time, assuming everything goes well, as there is usually a gap between jobs.

Richard
Author:

Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: