You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何使用VBoxManage为VirtualBox中的磁盘设置SCSI主机编号?

How to Set SCSI Host Numbers for VirtualBox Disks with VBoxManage

Nice question! Let’s walk through exactly how to set the SCSI host number for your disks in VirtualBox using VBoxManage—I’ve done this a few times with multi-disk VMs, so I’ll break it down step by step.

1. First, Set Up a SCSI Controller (If You Haven’t Already)

Since you were using SATA for your existing 30 disks, you’ll need to add a SCSI controller to your CentOS 7.4 VM first. Pick a controller type compatible with CentOS 7.4—LsiLogic is a reliable default, but LsiLogicSAS or BusLogic also work:

VBoxManage storagectl "YourCentOSVMName" --name "SCSI Controller" --add scsi --controller LsiLogic --hostiocache on
  • --hostiocache enables host-side IO caching (optional but recommended for better performance with some workloads).

2. Assign a Custom SCSI Host Number to the Controller

The SCSI host number is tied to the controller itself. To set a custom host number (e.g., 5), use the setextradata command:

VBoxManage setextradata "YourCentOSVMName" "VBoxInternal/Devices/lsi/0/Config/HostNumber" "5"
  • Note the lsi segment: this matches the controller type you chose. Swap it for buslogic if you used BusLogic, or lsisas for LsiLogicSAS.
  • The 0 is the controller instance number—if you add multiple SCSI controllers, increment this to 1, 2, etc.

3. (Optional) Assign Custom Target IDs to Individual Disks

If you want to specify exact target IDs for each SCSI disk (instead of letting VirtualBox auto-assign them), you have two options:

Option A: Assign During Disk Attachment

When creating and attaching a disk, use --port to set the target ID and --device for the LUN (usually 0 for standard disks):

# Create a fixed-size VDI (matching your existing SATA disk configuration)
VBoxManage createmedium disk --filename "scsi-disk-0.vdi" --size 100 --format VDI --variant fixed
# Attach it to SCSI controller port 3 (target ID 3), LUN 0
VBoxManage storageattach "YourCentOSVMName" --storagectl "SCSI Controller" --port 3 --device 0 --type hdd --medium "scsi-disk-0.vdi"

Option B: Override Existing Assignments with setextradata

If you already attached disks and want to tweak their target IDs later:

VBoxManage setextradata "YourCentOSVMName" "VBoxInternal/Devices/lsi/0/Config/Target3/LUN0/PortNumber" "0"

This maps the disk on SCSI port 0 to target ID 3.

4. Verify Your Configuration

Before starting the VM, double-check your extra data settings to confirm everything is correct:

VBoxManage getextradata "YourCentOSVMName" enumerate

Once the VM is running, install lsscsi in CentOS to see the host number and target IDs in action:

yum install -y lsscsi
lsscsi

You’ll see output like this, where 5 is your custom host number and 3 is the target ID:

[5:3:0:0]    disk    ATA      VBOX HARDDISK    1.0   /dev/sdb

内容的提问来源于stack exchange,提问作者Will Johnson

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.21 07:09:22