You are not logged in.

#1 2014-04-05 10:30:58

enihcam
Member
From: China
Registered: 2009-12-20
Posts: 165

[SOLVED] How to emulate the linux box as a USB storage device?

I heard some keywords 'OTG', 'Host-to-Host', etc.. but still didn't find a complete tutorial to do this:

How to emulate my NAS machine as a USB storage device so my laptop can mount it as a disk?

Thanks,
Enihcam.

Last edited by enihcam (2014-04-06 04:40:10)

Offline

#2 2014-04-05 12:15:25

tomk
Forum Fellow
From: Ireland
Registered: 2004-07-21
Posts: 9,838

Re: [SOLVED] How to emulate the linux box as a USB storage device?

Is there some reason you can't connect over a network? After all, that's what the N in NAS stands for.

Last edited by tomk (2014-04-05 16:51:50)

Offline

#3 2014-04-05 15:55:40

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 13,142

Re: [SOLVED] How to emulate the linux box as a USB storage device?

Is the NAS machine an Arch Box?  I ask, because this is where most of the configuration will take place.

(edit) I think you will, at the very least, require a custom kernel with the following enabled:

 CONFIG_USB_MASS_STORAGE:                                                                                                            │  
  │                                                                                                                                     │  
  │ The Mass Storage Gadget acts as a USB Mass Storage disk drive.                                                                      │  
  │ As its storage repository it can use a regular file or a block                                                                      │  
  │ device (in much the same way as the "loop" device driver),                                                                          │  
  │ specified as a module parameter or sysfs option.                                                                                    │  
  │                                                                                                                                     │  
  │ This driver is an updated replacement for the deprecated                                                                            │  
  │ File-backed Storage Gadget (g_file_storage).                                                                                        │  
  │                                                                                                                                     │  
  │ Say "y" to link the driver statically, or "m" to build                                                                              │  
  │ a dynamically linked module called "g_mass_storage".                                                                                │  
  │                                                                                                                                     │  
  │ Symbol: USB_MASS_STORAGE [=n]                                                                                                       │  
  │ Type  : tristate                                                                                                                    │  
  │ Prompt: Mass Storage Gadget                                                                                                         │  
  │   Defined at drivers/usb/gadget/Kconfig:746                                                                                         │  
  │   Depends on: <choice> && BLOCK [=y]                                                                                                │  
  │   Location:                                                                                                                         │  
  │     -> Device Drivers                                                                                                               │  
  │       -> USB support (USB_SUPPORT [=y])                                                                                             │  
  │         -> USB Gadget Support (USB_GADGET [=m])                                                                                     │  
  │           -> USB Gadget Drivers (<choice> [=m])                                                                                     │  

Last edited by ewaller (2014-04-05 16:03:04)


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
You assume people are rational and influenced by evidence.  You must not work with the public much. -- Trilby
----
How to Ask Questions the Smart Way

Offline

#4 2014-04-06 04:24:32

enihcam
Member
From: China
Registered: 2009-12-20
Posts: 165

Re: [SOLVED] How to emulate the linux box as a USB storage device?

tomk wrote:

Is there some reason you can't connect over a network? After all, that's what the N in NAS stands for.

The N is for grabbing data from external network. From inside, I'd also like my TV to access my NAS via USB, because my TV has no Ethernet port.

Last edited by enihcam (2014-04-06 04:25:00)

Offline

#5 2014-04-06 04:28:42

enihcam
Member
From: China
Registered: 2009-12-20
Posts: 165

Re: [SOLVED] How to emulate the linux box as a USB storage device?

ewaller wrote:

Is the NAS machine an Arch Box?  I ask, because this is where most of the configuration will take place.

(edit) I think you will, at the very least, require a custom kernel with the following enabled:

 CONFIG_USB_MASS_STORAGE:                                                                                                            │  
  │                                                                                                                                     │  
  │ The Mass Storage Gadget acts as a USB Mass Storage disk drive.                                                                      │  
  │ As its storage repository it can use a regular file or a block                                                                      │  
  │ device (in much the same way as the "loop" device driver),                                                                          │  
  │ specified as a module parameter or sysfs option.                                                                                    │  
  │                                                                                                                                     │  
  │ This driver is an updated replacement for the deprecated                                                                            │  
  │ File-backed Storage Gadget (g_file_storage).                                                                                        │  
  │                                                                                                                                     │  
  │ Say "y" to link the driver statically, or "m" to build                                                                              │  
  │ a dynamically linked module called "g_mass_storage".                                                                                │  
  │                                                                                                                                     │  
  │ Symbol: USB_MASS_STORAGE [=n]                                                                                                       │  
  │ Type  : tristate                                                                                                                    │  
  │ Prompt: Mass Storage Gadget                                                                                                         │  
  │   Defined at drivers/usb/gadget/Kconfig:746                                                                                         │  
  │   Depends on: <choice> && BLOCK [=y]                                                                                                │  
  │   Location:                                                                                                                         │  
  │     -> Device Drivers                                                                                                               │  
  │       -> USB support (USB_SUPPORT [=y])                                                                                             │  
  │         -> USB Gadget Support (USB_GADGET [=m])                                                                                     │  
  │           -> USB Gadget Drivers (<choice> [=m])                                                                                     │  

Yes, it is.

After mobprobe the module. How to redirect it to a specific folder?

Offline

#6 2014-04-06 04:39:46

enihcam
Member
From: China
Registered: 2009-12-20
Posts: 165

Re: [SOLVED] How to emulate the linux box as a USB storage device?

enihcam wrote:
ewaller wrote:

Is the NAS machine an Arch Box?  I ask, because this is where most of the configuration will take place.

(edit) I think you will, at the very least, require a custom kernel with the following enabled:

 CONFIG_USB_MASS_STORAGE:                                                                                                            │  
  │                                                                                                                                     │  
  │ The Mass Storage Gadget acts as a USB Mass Storage disk drive.                                                                      │  
  │ As its storage repository it can use a regular file or a block                                                                      │  
  │ device (in much the same way as the "loop" device driver),                                                                          │  
  │ specified as a module parameter or sysfs option.                                                                                    │  
  │                                                                                                                                     │  
  │ This driver is an updated replacement for the deprecated                                                                            │  
  │ File-backed Storage Gadget (g_file_storage).                                                                                        │  
  │                                                                                                                                     │  
  │ Say "y" to link the driver statically, or "m" to build                                                                              │  
  │ a dynamically linked module called "g_mass_storage".                                                                                │  
  │                                                                                                                                     │  
  │ Symbol: USB_MASS_STORAGE [=n]                                                                                                       │  
  │ Type  : tristate                                                                                                                    │  
  │ Prompt: Mass Storage Gadget                                                                                                         │  
  │   Defined at drivers/usb/gadget/Kconfig:746                                                                                         │  
  │   Depends on: <choice> && BLOCK [=y]                                                                                                │  
  │   Location:                                                                                                                         │  
  │     -> Device Drivers                                                                                                               │  
  │       -> USB support (USB_SUPPORT [=y])                                                                                             │  
  │         -> USB Gadget Support (USB_GADGET [=m])                                                                                     │  
  │           -> USB Gadget Drivers (<choice> [=m])                                                                                     │  

Yes, it is.

After mobprobe the module. How to redirect it to a specific folder?

modprobe g_mass_storage file=/path/to/emulate

Thanks everyone.

Offline

#7 2014-04-06 05:08:26

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 13,142

Re: [SOLVED] How to emulate the linux box as a USB storage device?

Cool!  I must try this


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
You assume people are rational and influenced by evidence.  You must not work with the public much. -- Trilby
----
How to Ask Questions the Smart Way

Offline

Board footer

Powered by FluxBB