How to build a Custom Block-Based Linux Kernel Driver

  • 7005873
  • 29-Apr-2010
  • 27-Feb-2019


PlateSpin Protect 10.x and above
PlateSpin Forge 3.x and above
PlateSpin Migrate 9.x and above


The PlateSpin blkwatch module must be built for the specific kernel running on the Linux system. PlateSpin products come with pre-compiled versions of the blkwatch module for many non-debug Linux distributions (both 32 and 64 bit ). For a complete list of pre‑compiled blkwatch drivers for your PlateSpin product, see "Pre‑compiled blkwatch Drivers for Linux Distributions" in the product User Guide. To access the User Guide for your PlateSpin product and release version, see the PlateSpin Documentation website (

Machines that run a Linux kernel not shipped by the vendor for distributions listed above are not supported by the supplied versions of the blkwatch module. However, it is possible to recompile the blkwatch module for systems that are running any of the supported distributions with a non-standard kernel (user-built or debug). To use the blkwatch module with such kernels, it must be recompiled for the specific (source workload) kernel and incorporated back into the PlateSpin product.


On the PlateSpin server, navigate to the Platespin application's installation directory, as applicable to the environment:
 C:\Program Files\PlateSpin Migrate Server
 C:\Program Files\PlateSpin Protect Server
 D:\Program Files\PlateSpin Forge Server
1. Open the '.\Packages\9D470BFF-E30F-4015-83D8-4D308A8C8B1B' folder and copy the file named '1.package' (or '2.package', if using Forge 3.3 HotFix 2 or Protect 10.3 HotFix 2) out to a temp directory.

2. Rename 1.package file with .zip extension ( Extract the contents of file to this temporary folder.

3. Use ssh / Winscp or a usb key to copy the 'src' subfolder to the Linux machine that is capable of building modules for the specific kernel. To build modules for a specific kernel, it is required that both a kernel development package (kernel-devel for RHEL or kernel-source for SLES) for the corresponding target kernel and a gcc compiler be installed on the linux machine. If those are missing, please install them before moving forward.

4. Navigate to the 'src' directory on the Linux machine and run the following command:


This will produce a 'blkwatch.ko' file in the 'src' directory.

5. Run the following command to get the release string of the kernel:

'uname -r'

6. Go back to the PlateSpin server and create a subfolder in the temporary folder where the package file was extracted (as in step 2). Create a new subfolder for this customer driver using the following naming convention:

CustomKernel-<release string>-<architecture>
Or you may run the below command to get durectly the full name for the folder. See illustration as an example:
awk 'BEGIN { ("uname -r" | getline var1); ("uname -m" | getline var2); printf "CustomKernel-%s-%s\n",var1,var2;}'
***It is important that the naming of the subfolder is done exactly as stated above (with hyphen sign)***
Replace <release string> with the actual string you obtained in step 5 and <architecture> with 'x86' for 32-bit platforms or with 'x86_64' for 64-bit platforms.
Note: The release string may contain an architecture, like this:

In that case the folder name will look like this:


7. Copy the blkwatch.ko produced in step 4 to the subfolder created in step 6.

8. Compress the contents of temporary folder (see note below in bold) using the .ZIP target format. Make sure that the compressed file contains all the folders that were extracted in step 2, in addition to the new one created in step 6. Rename the new archive to '1.package' (replace .zip extension with .package).

***Make sure to only archive the contents within the temp folder, NOT the temporary folder itself.  If the folder is archived it will create an additional layer in the package, causing no block-based components to be found***

9. Copy the '1.package' file produced above to the original folder location ('C:\Program Files\PlateSpin Migrate Server\Packages\9D470BFF-E30F-4015-83D8-4D308A8C8B1B') as in step 1. The custom kernel module is now installed and ready for use.
10. Before rerunning the job again, remove the /usr/lib/ofx directory from the source workload using ssh or console. Rerun the job.

Additional Information

When building the blkwatch.ko file output similar to the following should be seen:
make -C /lib/modules/2.6.18-308.el5/build M=/root/BBT/src modules
make[1]: Entering directory `/usr/src/kernels/2.6.18-308.el5-x86_64'
The second line indicates the directory used, which should match the kernel for which the blkwatch.ko file is being built.  If the output differs, especially if it points to a kernel other than the intended one, that can lead to the build failing or the blkwatch.ko file being invalid.  Using the above example as a correct output, the following would be an incorrect output on the same system:
make -C /lib/modules/2.6.18-308.el5/build M=/root/BBT/src modules
make[1]: Entering directory `/usr/src/redhat/SOURCES/linux-'
In order to correct this, follow the solutions below.
Solution 1:

If kernel-devel (RedHat) or kernel-source (SLES) is not installed, install it.  Both this package and gcc are required to properly build blkwatch.ko files.  If this package is not installed, or not installed for the correct kernel version, the build will fail or the blkwatch.ko file will not be correct.
Solution 2:
The symbolic link may be incorrect.  Using the examples given above, these commands will restore the symbolic link:
rm -f /lib/modules/2.6.18-308.el5/build
ln -s /usr/src/kernel/2.6.18-308.el5-x86_64 /lib/modules/2.6.18-308.el5/build