Warning : This guide is not for the faint of heart. Backup data before proceeding. Here be dragons. This process involves a) compiling a kernel b) compiling a kernel driver c) adding that driver to the kernel d) creating a new LiveUSB installer containing the custom kernel+driver. Here be dragons.
Warning #2: As of November 19, 2017 hard drives using the rcraid.ko
driver do not respond to smartctl, hddtemp, or hdparm commands. I have contacted AMD support regarding the lack of S.M.A.R.T. support in Linux and am waiting for a response.
Warning #3: It seems that HDDs using rcraid.ko
do not hibernate and continuously spin.
Aug 27, 2016 AMD drivers can be a little trickier depending on whether you want to use proprietary drivers or not. By default, Ubuntu uses the open-source Radeon drivers when it detects an AMD graphics card in. If you decide you would still like to use the proprietary driver, you will need to download and install it. According to the output you posted, you need to download this driver: AMD Radeon™ HD 8670M Series GPU Drivers & Support. Click on the 'Linux x8664' box and download the zip file. The AMDGPU-PRO drivers only officially support Ubuntu, RHEL and CentOS. This means Debian, Arch, Gentoo, SUSE and etc are unofficial operating systems. If you’ve got a new AMD Radeon card, it is best to use one of the supported Linux distributions. AMD Ryzen processor & X370 motherboard (preferably Ryzen 1700 and Gigabyte X370 Gaming 5; The BIOS is configured for SATA AHCI; A working Linux (preferably Fedora 27) is installed; An empty 8+GB flash drive is available; Download the drivers. AMD provides drivers for AMD fakeRAID on their website. Binary drivers for RHEL7-3.10.0-514 and Ubuntu.
Setup assumptions
- AMD Ryzen processor & X370 motherboard (preferably Ryzen 1700 and Gigabyte X370 Gaming 5
- The BIOS is configured for SATA AHCI
- A working Linux (preferably Fedora 27) is installed
- An empty 8+GB flash drive is available
Download the drivers
Driverpack Solution
AMD provides drivers for AMD fakeRAID on their website. Binary drivers for RHEL7-3.10.0-514 and Ubuntu 16.04-4.4.0-31 are provided. If you are not using those exact distributions and kernel versions (uname -r
), the compiled drivers do not work. Fortunately, AMD also provides source code and binary blobs to compile the drivers on other distros. If compiled successfully, a rcraid.ko
kernel driver will be built that can be swapped with the ahci
driver to interface with AMD fakeRAID drives.
Remove ahci
from the kernel
My distro of choice for this endeavor was the newly released Fedora 27. Unfortunately, Fedora compiles the ahci
driver into the kernel instead of leaving it as module. If ahci
is compiled into the kernel, it cannot be removed and replaced with the rcraid
driver. To check if ahci
is a kernel module, run modprobe -r ahci
; if ahci
is removed successfully, you may not need to recompile the kernel.
Fedora provides a decent but not thorough guide to compiling a custom kernel on the Fedora Wiki.
- Install dependencies:
# dnf install fedpkg fedora-packager rpmdevtools ncurses-devel gcc
- Clone the Fedora kernel:
$ fedpkg clone -a kernel
- Build kernel dependencies
# dnf builddep kernel.spec
- Create a new branch for the RAID drivers and base it on Fedora 27
$ git checkout -b raid origin/f27
- Edit the
kernel.spec
to designate this kernel as being RAID-enabled.
$ vim kernel.spec
%define buildid .raid
- Configure the kernel to build
ahci
as a module instead of a built-in.
$ vim kernel-local
CONFIG_SATA_AHCI=m
- Configure fedpkg to only produce a release kernel
$ make nodebug`
- Build the kernel and go to lunch
$ fedpkg local
- Install the fresh kernel on your existing installation
dnf install --nogpgcheck ./x86_64/kernel-$version.rpm ./x86-64/kernel-core-$version.rpm ./x86-64/kernel-modules-$version.rpm ./x86-64/kernel-modules-extra-$version.rpm
- Reboot to verify the kernel functions properly
- Make sure
ahci
is a module in the new kernel
$ modprobe -r ahci
Driver Booster
Build AMD RAID Proprietary Driver
Unfortunately, the AMD RAID license has a very nasty license:
Notice (iv) you may not make any modification or take any action that would cause this software, or any other Dot Hill software, to fall under any GPL license or any other open source license
This tidbit is really unfortunate since the code that is provided requires some modifications to compile. Unfortunately, those changes can not be redistributed. With some hints, the necessary changes should be obvious.
- Download and extract the drivers
- Attempt to compile and fail
$ cd driver_sdk/src
$ make
- The
sigfillset
function can be found inlinux/signal.h
. This may need to be included in the appropriate file. - It appears that the AMD driver is not-GPL compliant. You can read more about MODULE_LICENSE if needed; the macro call is in
rc_init.c
- The module will need compiled against the kernel source used above.
$ make KDIR='/path/to/kernel/kernel-$version/linux-$version
- Verify that
rcraid.ko
was compiled successfully and that it loads
# modprobe rcraid.ko
At this point, there is quite a conundrum. When the SATA mode is changed from AHCI to RAID in the BIOS, the physical size of the disk reported by the HDD changes. This will cause existing Linux installations to break. If your lvm
game is strong and you're comfortable in a dracut console, feel free to prove me wrong:
Warning #4: You will probably lose all your data and have to start from scratch! If you do not want to lose all your data, skip to the next section.
- Copy
rcraid.ko
to/path/to/kernel/kernel-$version/linux-$version/drivers/scsi/
- Run
depmod
- Slip the module into the initrd with dracut
# dracut --add-driver rcraid --force
Reboot
Use lvm tools to attempt to recover the messed up partitions. The following commands may be your friend
If you manage to recover from this let me know
Build a LiveCD Installer
Amd Drivers Linux Mint
The disks need to be in RAID mode before the installation begins. There are two ways to accomplish this: with inst.dd and by spinning a new installation disk with the kernel+driver installed. Building a driver disk and loading it with inst.dd may be the better solution to this problem; however, it was unsuccessful in my attempts. Fortunately, Fedora provides an easy way to build custom LiveCDs with kickstart. Unfortunately, including a custom kernel driver in the initramfs is not immediately apparent. This can be fixed by adding the AMD kernel module code to the Linux source tree.
The AMD RAID license prevents the patch to the kernel from being distributed. However, you can build it yourself.
Change directories to the
drivers/scsi
folder$ cd kernel/kernel-$version/linux-$version/drivers/scsi
Create a git branch for the AMD RAID changes. This is necessary to generate the patch
$ git checkout -b raid
Create a folder for the AMD code and move it over
$ mkdir rcraid
$ cp driver_sdk/src/* rcraid
Create a Kconfig file for the RAID driver
$ vim rcraid/Kconfig
Modify
drivers/scsi
Kconfig to recognize rcraid$ vim drivers/scsi/Kconfig
Add the
rcraid
Makefile todrivers/scsi
Makefile
$ vim drivers/scsi/Makefile
Add all of the files to git and commit
$ git add drivers/scsi/rcraid/* drivers/scsi/Kconfig drivers/scsi/Makefile
$ git commit -m 'Patch commit for AMD fakeRAID driver'
Create the patch and copy it to kernel directory
$ git format-patch master
$ ls | grep patch
$ cp $patch.patch /path/to/kernel/
Add the patch to
kernel.spec
. FindEND OF PATCH DEFINITIONS
. Just above, there will be sayPatch498: another-patch.patch
. Add a line beneath it with the patch created above$ vim kernel.spec
Patch499: 0000-amd-raid.patch
Add the AMD_RCRAID configuration option to
kernel-local
CONFIG_AMD_RCRAID=m
- Recompile the kernel
$ fedpkg local
- Create a dnf repo in the output directory
$ cd ./x86_64
$ createrepo .
- Get the dependencies to build the Fedora LiveCD
# dnf install livecd-tools spin-kickstarts
- Copy the example kickstart files to a convenient location
$ cp /usr/share/spin-kickstarts/* .
Modify
fedora-live-base.ks
to use the compiled kernel in ./x86_64/Create a
local.ks
file and add our kernel repository information to itModify
fedora-live-workstation.ks
to include the repository kickstart file%include local.ks
Build LiveCD
# livecd-creator --config=fedora-live-workstation.ks --fslabel=Fedora-RAID --cache=/var/cache/live
Burn
Fedora-RAID.iso
to a flash drive located at/dev/sdc
# dd if=Fedora-RAID of=/dev/sdc
Reboot the machine with the USB flash drive plugged in, enter the BIOS, and change the drive type to RAID.
At the GRUB boot menu, hit
e
to edit the kernel boot paramters and blacklist theahci
modulelinux .... modprobe.blacklist=ahci
Hit Ctrl+x to continue booting to a Fedora installer that will recognize the RAID disks!
Did this information save you hours of needlessly recompiling, rebooting, and almost returning your Ryzen for an i7? Are your disks working in RAID? Say thanks and help keep this site ad & analytics free by using my Amazon Affilliate URL. Or, consider donating some BTC (1DNwgPQMfoWZqnH78yt6cu4WukJa3h8P1f
) or ETH (0xf3c4a78c24D34E111f272Ac2AC72b1f01ba52DF3
).