Driver Disk Installation Guide for ARC-11XX/ARC12XX/ARC16XX/18XX RAID Controller 
on Ubuntu 16.04.7 x86_64 server(kernel 4.4.0-186, 4.4.0-210) and desktop(kernel 4.15.0-112, 4.15.0-142)
=================================================================================
=================================================================================
Linux SCSI driver technical support 
Mail address: support@areca.com.tw
Web site: www.areca.com.tw
==================================================================================
==================================================================================
 
**********************************************************************************   
1. Contents									**
**********************************************************************************

readme.txt	- the installation guide of Areca Raid driver for Ubuntu
arcmsr-ubuntu16.04.7.zip	- Areca RAID driver disk for system installation
arcmsr_1.50.0X.05-ubuntu16.04.7_k4.4.0-186_x86_64.deb  - driver for x86_64 system, kernel 4.4.0-186
arcmsr_1.50.0X.05-ubuntu16.04.7_k4.15.0-112_x86_64.deb  - driver for x86_64 system, kernel 4.15.0-112
arcmsr-1.50.00.05-source-only.dkms.tar.gz - DKMS enabled driver source code
arcmsr-1.50.0X.05-20210429.zip	- driver source code

**********************************************************************
2. First time Installation                                 	    **
**********************************************************************

   Extract arcmsr-ubuntu16.04.7.zip to an USB flash drive.

A. Install ubuntu server

	1) Insert the Areca driver USB flash disk to target system.
	2) Start Ubuntu installation by booting from Ubuntu installation DVD disc.
	3) On the Welcom screen, select "Install Ubuntu Server", then press Enter.
	4) At "Select a language" screen, Press "CTRL+ALT+F2" to switch to console.
	   Login with username 'ubuntu' and empty password.
	5) Type the following commands:
	   # mkdir /arcmsr /tmp/arcmsr
	   # mount /dev/sda1 /arcmsr
	   # cp -f /arcmsr/* /tmp/arcmsr
	   # umount /arcmsr
	6) Remove the USB flash drive from the USB port and then type:
	   # cd /tmp/arcmsr
	   # sh pre-install.sh
	7) Press "Alt+F1" back to installation screen.
	8) Continue the installation process. 
	9) Do not reboot after the installation is complete. press "Ctrl+Alt+F2" to
	   switch to console 2 and type the following commands:
	   # mkdir /target/tmp/arcmsr
	   # cp /tmp/arcmsr/* /target/tmp/arcmsr
	   # chroot /target
	   # cd /tmp/arcmsr
	   # sh post-install.sh
	   # exit
	10) Press "Alt+F1" to continue. 

B. Install ubuntu Desktop

	1) Insert the Areca driver USB flash disk to target system.
	2) Start Ubuntu installation by booting from Ubuntu installation DVD disc.
	3) On the Ubuntu menu, stay cursor at "Try Ubuntu without installing", then press Enter.
	4) At Ubuntu desktop, open a terminal console.
	5) Type the following commands:
	   # mount
	   Find the driver USB device /dev/sda1 mount point, and unmount it.
	   # sudo mkdir /arcmsr /tmp/arcmsr
	   # sudo mount /dev/sda1 /arcmsr
	   # sudo cp -f /arcmsr/* /tmp/arcmsr
	   # sudo umount /arcmsr
	6) Remove the USB flash drive from the USB port and then type:
	   # cd /tmp/arcmsr
	   # sudo sh pre-install.sh
	7) Click th "Install Ubuntu 16.04.7 LTS" icon, to start Ubuntu system installation.
	8) Do not reboot after the installation is complete.
	   Switch to terminal console and type the following commands:
	   # mkdir /target/tmp/arcmsr
	   # cp /tmp/arcmsr/* /target/tmp/arcmsr
	   # sudo chroot /target
	   # cd /tmp/arcmsr
	   # sudo sh post-install.sh
	   # exit
	9) Now you can restart the system. 

**********************************************************************
3. Installing raid driver on an Existing System	
**********************************************************************

	# sudo dpkg -i arcmsr_1.50.0X.05-ubuntu16.04.7_k4.x.0-xx_x86_64.deb
	where 4.x.0-xx is kernel version, install the right driver package to match your kernel

	# sudo depmod -a
	# sudo update-initramfs -u

	Reboot you system to make arcmsr driver take effect.

**********************************************************************************
4. To install DKMS enabled tarball of arcmsr driver on an Existing System.
**********************************************************************************
	Before using DKMS, you must install DKMS package. You can install dkms as following.
	# sudo apt-get install dkms

	Copy arcmsr DKMS enabled tarball to home directory.
	In order to load tarball into the DKMS tree, you must use the following command:

	# sudo dkms ldtarball --archive=./arcmsr-<module version>-source-only.dkms.tar.gz
	where <module version> could be, e.g., 1.50.00.05
	arcmsr source code will be added to DKMS tree.
	
	To build arcmsr driver module
	# sudo dkms build -m arcmsr -v <module version>
	
	To install arcmsr driver module
	# sudo dkms install -m arcmsr -v <module version>


	If you are upgrading linux kernel, then you have to install the corresponding linux-headers-<kernelver> before
	reboot your system. New kernel image can be find in /boot, corresponding new linux header can be find in /usr/src.
	If you can not find new linux header in /usr/src, you can install it as following.
	# sudo apt-get install linux-headers-<kernelver>
	where <kernelver> could be, e.g., 4.4.0-186-generic.
	
	After installed linux header files, DKMS service will build and install arcmsr driver for new kernel automatically.

**********************************************************************************
5. To compile arcmsr driver on an Existing System.
**********************************************************************************
        if your target kernel version is not (uname -r), then replace following
        $(uname -r) by target kernel version

	Unzip arcmsr-1.50.0X.05-20210429.zip to a directory and change to.
	# sudo make KDIR=/lib/modules/$(uname -r)/build
	# sudo cp -f arcmsr.ko /lib/modules/$(uname -r)/kernel/drivers/scsi/arcmsr/
	# sudo depmod -a $(uname -r)
	# sudo update-initramfs -u -k $(uname -r)
	# sudo insmod arcmsr.ko

**********************************************************************************
6. To support Areca thunderbolt devices
**********************************************************************************

NOTE!!! a. To support Areca thunderbolt devices, ARC-8050Tx, kernel version must be >= v4.15.0
        b. To support thunderbolt cable hotplug, arcmsr driver must be >= v1.40.0X.05-20180309.
           This version's driver was built-in in Linux kernel since v4.17.

To install a new kernel >= v4.15.0:
========================================================
Download kernel and headers file form http://kernel.ubuntu.com/~kernel-ppa/mainline/
You have to install linux-headers-..._all.deb, linux-headers-..._amd64.deb, linux-image-..._amd64.deb, linux-modules-..._amd64.deb
e.g.:
   # wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.19.27/linux-headers-4.19.27-041927_4.19.27-041927.201903051835_all.deb
   # wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.19.27/linux-headers-4.19.27-041927-generic_4.19.27-041927.201903051835_amd64.deb
   # wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.19.27/linux-image-unsigned-4.19.27-041927-generic_4.19.27-041927.201903051835_amd64.deb
   # wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.19.27/linux-modules-4.19.27-041927-generic_4.19.27-041927.201903051835_amd64.deb
   # sudo dpkg -i *.deb
   # sudo grub-mkconfig -o /boot/grub/grub.cfg


	For Ubuntu 16.04.7 to support Areca thunderbolt 2 & 3 devices, ARC-8050T2/T3 series,
	it needs root user to authorise permission after connect the thunderbolt devices.

	1. Find the thunderbolt deivce's location.
	   # ls /sys/bus/thunderbolt/devices
	   0-0 0-3 domain0			
	   (On your system, list could be: 0-0 0-1 domain0. If so, replace 0-3 by 0-1 in below)

	   # cat /sys/bus/thunderbolt/devices/0-3/vendor_name
	   areca

	   # cat /sys/bus/thunderbolt/devices/0-3/device_name
	   ARC8050-T3(or ARC8050-T2)

	2. Give an authorised permission to thunderbolt devices
	   # su
	   # echo 1 > /sys/bus/thunderbolt/devices/0-3/authorised
	   Now detecting devices start, just a moment you will can access thunderbolt devices.


**********************************************************************************
7. To set driver parameters value
**********************************************************************************
    arcmsr provided driver parameters setting since v1.30.0X.25.
    Multiple Driver parameters can be set at a time.
    e.g. # insmod arcmsr.ko host_can_queue=72 cmd_per_lun=16

    Setting parameter value out of range will be ignored, parameter remain default value.

    a. To list what driver parameter can be set, parameter default value and value range.
       # modinfo arcmsr

    b. To set driver parameter when you manually install driver.
       (This method will be infeasible if your system was boot from areca Raid volume.)
       e.g. to set parameter host_can_queue value to 64
       # sudo rmmod arcmsr
       # sudo insmod /lib/modules/$(uname -r)/kernel/drivers/scsi/arcmsr/arcmsr.ko host_can_queue=64

    c. To set driver parameter during booting from grub menu.
       When grub menu display, use UP and DOWN arrow key to move cursor to booting target.
       Type e to edit, move cursor to end of line that include "linux   /boot/vmlinuz-x.xx.xx ....."
       Append driver parameter to there.(e.g. to set parameter host_can_queue value to 64)

       linux   /boot/vmlinuz-4.15.0-112..... ... ... $vt_handoff arcmsr.host_can_queue=64

    d. To set driver parameter for every boot up.
       e.g. to set parameter host_can_queue value to 64
       # sudo gedit /boot/grub/grub.cfg
       Append driver parameter setting to end of line that include "linux   /boot/vmlinuz-x.xx.xx ....."

       linux   /boot/vmlinuz-4.15.0-112..... ... ... $vt_handoff arcmsr.host_can_queue=64

    e. To verify parameter setting is correct.
       1. To locate adapter parameter directory
          # cat /sys/class/scsi_host/hostX/proc_name
                where hostX could be host0, host1, ...
          The correct output should be arcmsr. If output is (null), check host_fw_model and host_driver_version.
          # cat /sys/class/scsi_host/hostX/host_fw_model
          # cat /sys/class/scsi_host/hostX/host_driver_version

       2. List host_can_queue value
          #  cat /sys/class/scsi_host/hostX/can_queue

       3. List cmd_per_lun value
          #  cat /sys/class/scsi_host/hostX/cmd_per_lun

       4. List cmd_timeout value
          #  cat /sys/block/sdX/device/cmd_timeout
             where sdX could be sda, sdb, ...
