如何在 Linux 复合 USB 小工具中热交换大容量存储 LUN 备份文件?
How do I hot-swap a mass storage LUN backing file in the Linux composite USB gadget?
切入正题
Linuxcomposite USB gadget mass storage功能是否支持其LUN媒体备份文件的热插拔?如果是这样,有人让它工作吗?
背景
Linux USB composite gadget includes a Mass Storage function which can support multiple logical units, each of which maps to a drive image file (like FAT or ISO). From what I can tell, the Mass Storage function appears to inherit some or all of it's configuration interface from the previous standalone g_mass_storage gadget
文档暗示您可以将存储映像装载为大容量存储 LUN,然后稍后卸载它并重新装载新的存储映像,其方式类似于物理 CD/DVD 驱动器会工作。我正在尝试访问的正是这个功能。
我试过的
我正在使用 insmod/modprobe 和 rmmod 挂载和卸载映射到 ISO 映像的单个 LUN。 modprobe 参数是 Edison 配置的修改版本,它用于公开其 "firmware update" 驱动器映像。
USB slave 是一个 Intel Edison 开发板 运行 一个稍微修改过的 Yocto 构建,主机是 OS X 10.10.2:
# Step 1: mount an ISO
modprobe g_multi file=/home/root/first_image.iso removable=1 ro=1 stall=0 idVendor=0x8087 idProduct=0x0A9E iProduct=Edison iManufacturer=Intel
# at this point, the ISO appears on the host (I'm testing with OS X)
# Step 2, at some later time
rmmod g_multi
# The storage disappears from the OS X desktop.
# It does not seem to complain unless you had files open on the media
# Step 3: mount a different ISO
modprobe g_multi file=/home/root/second_image.iso removable=1 ro=1 stall=0 idVendor=0x8087 idProduct=0x0A9E iProduct=Edison iManufacturer=Intel
# The operation appears to work on the device side,
# but the new media does not appear in OS X.
# You can usually get it to work by unplugging the USB cable,
# which presumably resets the port somehow.
我试图找到一种在软件控制下重置 OTG 设备端口的方法。这可能是最终的解决方案。
我还没有(还)尝试使用 configfs 接口构建和配置设备。这也可能是一个选项,但我仍在研究相关文档。
谢谢!
至少在:
$ uname -r
4.9.87
我找到了这个:
$ find /sys -type f -a -name file
/sys/devices/soc0/soc/2100000.aips-bus/2184000.usb/ci_hdrc.0/gadget/lun0/file
/sys/module/g_multi/parameters/file
前缀在很大程度上取决于您的硬件,但 gadget/lun0/file 前缀是可写的。然后你会:
echo "/where/is/your/file" >.../lun0/file
瞧。当然,正如 OP 所暗示的那样,您需要传递 go g_file 的 removable=1。
要"eject"设备,您只需执行以下操作:
echo >.../lun0/file
如果文件系统仍然安装在主机上,最后一个可能会失败。
切入正题
Linuxcomposite USB gadget mass storage功能是否支持其LUN媒体备份文件的热插拔?如果是这样,有人让它工作吗?
背景
Linux USB composite gadget includes a Mass Storage function which can support multiple logical units, each of which maps to a drive image file (like FAT or ISO). From what I can tell, the Mass Storage function appears to inherit some or all of it's configuration interface from the previous standalone g_mass_storage gadget
文档暗示您可以将存储映像装载为大容量存储 LUN,然后稍后卸载它并重新装载新的存储映像,其方式类似于物理 CD/DVD 驱动器会工作。我正在尝试访问的正是这个功能。
我试过的
我正在使用 insmod/modprobe 和 rmmod 挂载和卸载映射到 ISO 映像的单个 LUN。 modprobe 参数是 Edison 配置的修改版本,它用于公开其 "firmware update" 驱动器映像。
USB slave 是一个 Intel Edison 开发板 运行 一个稍微修改过的 Yocto 构建,主机是 OS X 10.10.2:
# Step 1: mount an ISO
modprobe g_multi file=/home/root/first_image.iso removable=1 ro=1 stall=0 idVendor=0x8087 idProduct=0x0A9E iProduct=Edison iManufacturer=Intel
# at this point, the ISO appears on the host (I'm testing with OS X)
# Step 2, at some later time
rmmod g_multi
# The storage disappears from the OS X desktop.
# It does not seem to complain unless you had files open on the media
# Step 3: mount a different ISO
modprobe g_multi file=/home/root/second_image.iso removable=1 ro=1 stall=0 idVendor=0x8087 idProduct=0x0A9E iProduct=Edison iManufacturer=Intel
# The operation appears to work on the device side,
# but the new media does not appear in OS X.
# You can usually get it to work by unplugging the USB cable,
# which presumably resets the port somehow.
我试图找到一种在软件控制下重置 OTG 设备端口的方法。这可能是最终的解决方案。
我还没有(还)尝试使用 configfs 接口构建和配置设备。这也可能是一个选项,但我仍在研究相关文档。
谢谢!
至少在:
$ uname -r
4.9.87
我找到了这个:
$ find /sys -type f -a -name file
/sys/devices/soc0/soc/2100000.aips-bus/2184000.usb/ci_hdrc.0/gadget/lun0/file
/sys/module/g_multi/parameters/file
前缀在很大程度上取决于您的硬件,但 gadget/lun0/file 前缀是可写的。然后你会:
echo "/where/is/your/file" >.../lun0/file
瞧。当然,正如 OP 所暗示的那样,您需要传递 go g_file 的 removable=1。
要"eject"设备,您只需执行以下操作:
echo >.../lun0/file
如果文件系统仍然安装在主机上,最后一个可能会失败。