1# Getting Started {#getting_started} 2 3# Getting the Source Code {#getting_started_source} 4 5~~~{.sh} 6git clone https://github.com/spdk/spdk 7cd spdk 8git submodule update --init 9~~~ 10 11# Installing Prerequisites {#getting_started_prerequisites} 12 13The `scripts/pkgdep.sh` script will automatically install the full set of 14dependencies required to build and develop SPDK. 15 16~~~{.sh} 17sudo scripts/pkgdep.sh 18~~~ 19 20# Building {#getting_started_building} 21 22Linux: 23 24~~~{.sh} 25./configure 26make 27~~~ 28 29FreeBSD: 30Note: Make sure you have the matching kernel source in /usr/src/ 31 32~~~{.sh} 33./configure 34gmake 35~~~ 36 37There are a number of options available for the configure script, which can 38be viewed by running 39 40~~~{.sh} 41./configure --help 42~~~ 43 44Note that not all features are enabled by default. For example, RDMA 45support (and hence NVMe over Fabrics) is not enabled by default. You 46can enable it by doing the following: 47 48~~~{.sh} 49./configure --with-rdma 50make 51~~~ 52 53# Running the Unit Tests {#getting_started_unittests} 54 55It's always a good idea to confirm your build worked by running the 56unit tests. 57 58~~~{.sh} 59./test/unit/unittest.sh 60~~~ 61 62You will see several error messages when running the unit tests, but they are 63part of the test suite. The final message at the end of the script indicates 64success or failure. 65 66# Running the Example Applications {#getting_started_examples} 67 68Before running an SPDK application, some hugepages must be allocated and 69any NVMe and I/OAT devices must be unbound from the native kernel drivers. 70SPDK includes a script to automate this process on both Linux and FreeBSD. 71This script should be run as root. It only needs to be run once on the 72system. 73 74~~~{.sh} 75sudo scripts/setup.sh 76~~~ 77 78To rebind devices back to the kernel, you can run 79 80~~~{.sh} 81sudo scripts/setup.sh reset 82~~~ 83 84By default, the script allocates 2048MB of hugepages. To change this number, 85specify HUGEMEM (in MB) as follows: 86 87~~~{.sh} 88sudo HUGEMEM=4096 scripts/setup.sh 89~~~ 90 91On Linux machines HUGEMEM will be rounded up to system-default huge page 92size boundary. 93 94All available params can be viewed by running 95 96~~~{.sh} 97scripts/setup.sh help 98~~~ 99 100Example code is located in the examples directory. The examples are compiled 101automatically as part of the build process. Simply call any of the examples 102with no arguments to see the help output. If your system has its IOMMU 103enabled you can run the examples as your regular user. If it doesn't, you'll 104need to run as a privileged user (root). 105 106A good example to start with is `examples/nvme/identify`, which prints 107out information about all of the NVMe devices on your system. 108 109Larger, more fully functional applications are available in the `app` 110directory. This includes the iSCSI and NVMe-oF target. 111