Adding SCSI Controller / SCSI Disks to KVM-based Guests

http://www.tokiwinter.com/adding-scsi-controller-scsi-disks-to-kvm-based-guests/

Following on from my previous article I wanted to add a SCSI disk to a KVM-based guest (hostname: mars). The guest was installed via kickstart with all volumes on /dev/vdaI’d seen conflicting reports of SCSI support (the fact you can’t add the SCSI controller/disks through virt-manager, for example) so I wanted to create a SCSI disk and attach it to the host at /dev/sda.

I first used my new best friend fallocate to fast-allocate the required image:

Next, I created the appropriate XML configuration for the new disk device:

Trying to attach this device via virsh yielded the following unpleasantness:

OK – let’s jump onto the guest and see what’s going on. First, I installed lspci and lsscsi so that I could diagnose the issue …

… and ran lspci:

OK – so there is a SCSI controller available, but it’s for the virtio block devices. Looking at theRed Hat Documentation we need to add a SCSI controller of type virtio-scsi. This can also be confirmed by the lack of output from the following command:

Let’s create a simple XML configuration file for our new SCSI controller:

And add it to our guest configuration:

Dumping the guest domain’s XML should now show the controller added to the configuration:

On the guest, lspci should show the new controller added:

The controller appears as “Device 1004“. I was then able to add the disk device as an appropriate SCSI drive:

And on the guest, fdisk proves it’s there:

As does a quick probe with lsscsi:

As I like making things difficult for myself, I’ll be placing a btrfs filesystem on this and playing around with volumes – but that’s something for another article :)

It’s worth noting that whilst the VM configuration within virt-manager shows that there is now a SCSI controller associated with the guest, it still will not allow the creation of SCSI disks – you’ll need to use virsh (at least you will on virt-manager version 0.9.0).


<think>我们正在处理用户在使用tleap时遇到的错误:当尝试加载leaprc.GLYCAM_06j-1文件时,系统提示“is a directory”。这意味着用户可能错误地输入了一个目录路径而不是文件路径。以下将逐步解决此问题。 ### 问题分析 在AmberTools中,力场文件通常存储在`$AMBERHOME/dat/leap/cmd`目录下。用户遇到的错误通常由以下原因引起: 1. **路径输入错误**:可能将目录路径当作文件加载 2. **环境变量设置不当**:`$AMBERHOME`未正确设置 3. **文件缺失**:GLYCAM力场未正确安装 ### 解决步骤 #### 1. **验证AmberTools安装** 首先确认AmberTools已正确安装并设置了环境变量: ```bash # 检查AMBERHOME环境变量 echo $AMBERHOME # 验证tleap可执行文件 which tleap ``` 如果`$AMBERHOME`未设置,请根据安装方式配置: - 源码安装:在安装目录执行`source amber.sh`(或`amber.csh`) - 预编译版本:根据文档设置路径 #### 2. **定位GLYCAM力场文件** GLYCAM力场文件应位于: ``` $AMBERHOME/dat/leap/cmd/leaprc.GLYCAM_06j-1 ``` 使用以下命令检查文件是否存在: ```bash ls $AMBERHOME/dat/leap/cmd/leaprc.GLYCAM_06j-1 ``` 若文件不存在,则需重新安装GLYCAM力场或完整安装AmberTools。 #### 3. **正确加载命令** 在tleap中加载时**仅需文件名**,无需路径: ```tleap # 正确方式(自动搜索cmd目录) source leaprc.GLYCAM_06j-1 ``` 错误示例(绝对路径会导致目录识别错误): ```tleap source /path/to/AmberTools/dat/leap/cmd/leaprc.GLYCAM_06j-1 # 避免! ``` #### 4. **常见错误处理** | 错误现象 | 解决方案 | |---------|----------| | `File 'leaprc.GLYCAM_06j-1' not found` | 检查`$AMBERHOME/dat/leap/cmd`目录是否存在该文件 | | `is a directory` | 删除source命令中的路径前缀,仅保留文件名 | | `GLYCAM residue not recognized` | 确保加载顺序:先蛋白质力场,后糖力场[^3] | #### 5. **完整加载示例** ```tleap # 标准糖蛋白体系加载流程 source leaprc.protein.ff14SB # 先加载蛋白质力场 source leaprc.GLYCAM_06j-1 # 再加载糖力场(注意仅文件名) source leaprc.water.tip3p # 加载水模型 # 构建葡萄糖分子 glc = sequence { GL4P } savepdb glc glucose.pdb ``` ### 安装问题排查 如果确认文件缺失,需重新安装GLYCAM: 1. **AmberTools≥22用户**:GLYCAM已集成,无需单独安装 2. **旧版用户**:从[GLYCAM官网](glycam.org)下载并手动安装 ```bash # 手动安装示例(需管理员权限) cp downloaded_glycam_files/* $AMBERHOME/dat/leap/lib/ cp downloaded_glycam_files/cmd/* $AMBERHOME/dat/leap/cmd/ ``` ### 验证操作 成功加载后,在tleap中执行: ```tleap list ``` 输出应包含: ``` > Object types: GLYCAM_06j-1 force field > Residues: GL4P MAN GALP ... ``` ### 进阶提示 - **多力场混合**:同时使用蛋白质、核酸和糖力场时,加载顺序应为: 1. 通用力场(如ff14SB) 2. 专用力场(GLYCAM) 3. 溶剂模型[^3] - **参数检查**:使用`parmchk2`验证糖分子参数 ```bash parmchk2 -i glucose.pdb -f pdb -o glucose.frcmod ``` §§相关问题§§ 1. 如何解决AmberTools安装过程中出现的netcdf库链接错误?[^1] 2. tleap加载多个力场时出现参数冲突应如何解决? 3. 如何验证GLYCAM力场在糖分子模拟中的能量收敛性?</think>### 解决 "tleap source leaprc.GLYCAM_06j-1 is a directory" 错误 #### 🔍 问题原因分析 当出现 `is a directory` 错误时,通常表示: 1. **文件路径混淆**:尝试加载了目录而非文件 2. **安装不完整**:GLYCAM力场未正确安装(常见于源码编译时的库缺失问题[^1]) 3. **环境变量错误**:`$AMBERHOME` 路径配置不当 #### ✅ 逐步解决方案 ##### 步骤 1:验证 AmberTools 安装完整性 检查关键文件是否存在: ```bash # 检查GLYCAM力场文件 ls $AMBERHOME/dat/leap/cmd/leaprc.GLYCAM_06j-1 # 检查依赖库(解决引用[1]的netcdf错误) ls $AMBERHOME/include/netcdf.h ``` 若文件缺失,需重新安装。 ##### 步骤 2:修复依赖库问题(针对引用[1]的错误) ```bash # 安装缺失的ZLIB库(Ubuntu示例) sudo apt-get install zlib1g-dev # 重新编译AmberTools cd $AMBERHOME make clean ./configure -python make install ``` ##### 步骤 3:正确加载力场 在 tleap 中使用**完整路径**加载: ```tleap source $AMBERHOME/dat/leap/cmd/leaprc.GLYCAM_06j-1 ``` ##### 步骤 4:验证力场加载 ```tleap > list ``` 成功加载时输出应包含: ``` GLYCAM_06j-1 force field parameters Residues: GL4P, MAN, GALP... ``` #### ⚠️ 常见错误场景处理 | 错误场景 | 解决方案 | |---------|----------| | `File not found` | 运行 `amber.python -m pdb4amber -i` 修复安装 | | `Permission denied` | 执行 `chmod +x $AMBERHOME/dat/leap/cmd/*` | | `NetCDF link error` | 重装 netcdf 库:`conda install -c conda-forge netcdf4` | | 多力场冲突 | 加载顺序:先蛋白质力场(ff14SB),再糖力场(GLYCAM)[^3] | #### 📝 正确操作示例 ```tleap # 标准加载流程 source leaprc.protein.ff14SB source $AMBERHOME/dat/leap/cmd/leaprc.GLYCAM_06j-1 # 显式路径 # 创建糖分子 glc = sequence { GL4P } solvateBox glc TIP3PBOX 10.0 savepdb glc glucose.pdb ``` #### 🔧 预防措施 1. **安装验证**:运行测试用例 ```bash cd $AMBERHOME/test make test.serial ``` 2. **环境配置**:在 `~/.bashrc` 添加 ```bash export AMBERHOME=/path/to/amber export PATH=$AMBERHOME/bin:$PATH ``` > 💡 **提示**:AmberTools 22+ 版本已优化库依赖问题,建议升级[^2]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值