xref: /aosp_15_r20/external/crosvm/docs/book/src/devices/scsi.md (revision bb4ee6a4ae7042d18b07a98463b9c8b875e44b39)
1# SCSI (experimental)
2
3crosvm supports
4[virtio-scsi](https://docs.oasis-open.org/virtio/virtio/v1.2/csd01/virtio-v1.2-csd01.html#x1-3430006)
5devices that work as block devices for the guest.
6
7The step for setting up a block device is similar to the virtio-blk device. After setting up the
8block device, pass it with `--scsi-block` flag so the disk will be exposed as `/dev/sda`,
9`/dev/sdb`, etc. The device can be mounted with the `mount` command.
10
11```sh
12crosvm run \
13  --scsi-block disk.img
14  ... # usual crosvm args
15```
16
17## Flags & Options
18
19The `--scsi-block` parameter supports additional options and flags to enable features and control
20disk parameters.
21
22### Read-only
23
24To expose the scsi device as a read-only disk, you can add the `ro` flag after the disk image path:
25
26```sh
27crosvm run \
28  --scsi-block disk.img,ro
29  ... # usual crosvm args
30```
31
32### Rootfs
33
34If you use a scsi device as guest's rootfs, you can add the `root` flag to the `--scsi-block`
35parameter:
36
37```sh
38crosvm run \
39  --scsi-block disk.img,root
40  ... # usual crosvm args
41```
42
43This flag automatically adds a `root=/dev/sdX` kernel parameter with the corresponding virtio-scsi
44device name and read-only (`ro`) or read-write (`rw`) option depending on whether the `ro` flag has
45also been specified or not.
46
47### Block size
48
49- Syntax: `block_size=BYTES`
50- Default: `block_size=512`
51
52The `block_size` option overrides the reported block size (also known as sector size) of the
53virtio-scsi device. This should be a power of two larger than or equal to 512.
54