How to mount Android as CD-ROM?

烂漫一生 提交于 2019-12-08 09:41:27

问题


I have Galaxy S4 with custom ROM and kernel. I need to mount ISO image from sdcard to Windows/Linux PC as CD-ROM.
There's a "DriveDroid" app that works fine, but I need to do it manually (as a study). Windows 8 writes that "Device needs to be formatted".
code (bash script)

# Disable USB
echo 0 > /sys/class/android_usb/android0/enable

# Set Vendor and Product IDs
echo 0x04e8 > /sys/class/android_usb/android0/idVendor
echo 0x6860 > /sys/class/android_usb/android0/idProduct

# Set mass_storage mode
echo mass_storage > /sys/class/android_usb/android0/functions

# Enable CD-ROM and make read-only (ERROR HERE!)
echo 1 > /sys/class/android_usb/android0/f_mass_storage/lun0/cdrom
echo 1 > /sys/class/android_usb/android0/f_mass_storage/lun0/ro

# Set path to ISO
echo /mnt/shell/emulated/0/obraz.iso > /sys/class/android_usb/android0/f_mass_storage/lun0/file

# Enable USB
echo 1 > /sys/class/android_usb/android0/enable

However, both cdrom and ro files are still set to 0. What else should I do to make them "1" ?


回答1:


# Disable USB
echo 0 | tee /sys/class/android_usb/android0/enable

# Set Vendor and Product IDs
echo 0x04e8 | tee /sys/class/android_usb/android0/idVendor
echo 0x6860 | tee /sys/class/android_usb/android0/idProduct

# Set mass_storage mode
echo mass_storage | tee /sys/class/android_usb/android0/functions

# Enable CD-ROM and make read-only
echo 1 | tee /sys/class/android_usb/android0/f_mass_storage/lun*/ro

# Set path to ISO
echo | tee /sys/class/android_usb/android0/f_mass_storage/lun*/file
echo <YOUR-IMAGE-FILE-PATH> | tee /sys/class/android_usb/android0/f_mass_storage/lun*/file

# Enable USB
echo 1 | tee /sys/class/android_usb/android0/enable

It is work on my phone. (Asus T00F - android 7.1.2)




回答2:


Before writing 1 to "cdrom" and "ro" I had to empty "file" file. Thanks @FrozenCOW (Developer of DriveDroid) for help!

# Clear path to ISO
echo "" > /sys/class/android_usb/android0/f_mass_storage/lun0/file

# Enable CD-ROM and make read-only (ERROR HERE!)
echo 1 > /sys/class/android_usb/android0/f_mass_storage/lun0/cdrom
echo 1 > /sys/class/android_usb/android0/f_mass_storage/lun0/ro

# Set path to ISO
echo /mnt/shell/emulated/0/obraz.iso > /sys/class/android_usb/android0/f_mass_storage/lun0/file


来源:https://stackoverflow.com/questions/29686904/how-to-mount-android-as-cd-rom

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!