13

My TV can record to USB-storage, which is quite common. What I would like was to record to my NAS instead, where there's plenty of room and recordings can be shared and managed better. So I'm looking for an adapter-thingy (hw/sw) that will make my NAS appear to the TV as a USB block storage device. Any ideas? Googling has turned up nothing.

Please note that this is the exact opposite of the very common scenario of making a USB device available as a networked drive. There are tons of solutions for that, so let me stress that I'm looking for the opposite: make my NAS appear as a physical USB drive that can plug straight into my TV, like so:

[NAS] ——— Ethernet ——— [adapter] ——— USB ——— [TV]
6
  • Have you found a good device, yet? I'm looking, too - and I'd prefer a device with cable bound LAN for better performance. – BlaM Sep 1 '11 at 16:12
  • The simplest solution would be to buy instead a usb stick. These go today up to 512 gb. – harrymc Feb 16 '15 at 7:07
  • 2
    Another note on the bounty: answers that require buying an entire desktop PC to implement aren't particularly helpful either. Ideally I'd like a small, dedicated device for this. – detly Feb 16 '15 at 22:43
  • @detly: A usb stick fits exactly that requirement. – harrymc Feb 18 '15 at 21:13
  • 2
    @harrymc I thought it was pretty clear that both I and the OP don't want to constantly, manually shuffle files across from one storage device to another. But if you know of a USB stick that can access an SMB share while providing access to it via the USB, post that as an answer. – detly Feb 18 '15 at 21:50
2

I know that this post is quite old but I've stumbled across it when I was looking for a solution for the same problem. I haven't seen a ready-made solution that you can buy, but several do it yourself (DIY) approaches.

Those DIY approaches are therefore all based on building your own "adapter". The adapter is a Linux-based computer, e.g. a single-board computer (SBC) such as the Raspberry Pi. It acts as a USB mass storage device ("flash drive") to your smart TV on the one side and accesses (read and write) a network attached data storage (NAS) on the other side.

                 iSCSI via                              Mass Storage
                TCP/IP via                            Device Class via
[NAS] ————— Ethernet or Wi-Fi ———— [Linux computer] ———————— USB ————————— [Smart TV]

Matt Olan has realized this approach earlier this year when he has tried to store games and backups of his PlayStation 4 earlier this year: https://matt.olan.me/making-a-piscsi-usb-drive-part-1/ and https://matt.olan.me/making-a-piscsi-usb-drive-part-2/ - he has also done some performance measurements.

Getting started with an installation of the Linux operating system (OS) on the SBC

If you use a Raspberry Pi based SBC you should start with a Linux installation. The current version of the Raspberry Pi OS (previously called Raspbian) can be downloaded from https://www.raspberrypi.org/software/.

You can then also follow the guide on https://www.raspberrypi.org/documentation/configuration/wireless/headless.md to set up your Raspberry Pi headlessly, i.e. you can already modify the contents (the boot folder) on the SD card. You can also start with SSH being enabled (by creating a new empty file named ssh inside the boot directory). Then use raspi-config to change further settings.

Providing a mass storage device to your smart TV

Usually a computer acts as a USB host. What we need here instead is a computer acting as a USB slave device. The hardware of the computer needs to provide a USB On-The-Go (OTG) port. In Linux speak this kind of system is also called a USB gadget. You will need to modify your Linux installation.

The USB driver dwc2 needs to be used in /boot/config.txt and /etc/modules.

The "Mass Storage Gadget" (MSG) is used here. It "provides support for the USB Mass Storage class. It can appear to a host as a set of up to 8 SCSI disk drives (called Logical Units often referred to as LUNs, even though it technically stands for Logical Unit Number), although most of the time a single LUN is all you will need. The information stored for each LUN must be maintained by the gadget somewhere, either in a normal file or in a block device such as a disk partition or even a ramdisk. This file or block device is called the backing storage for the gadget (...)." (source: http://www.linux-usb.org/gadget/file_storage.html)

The module g_mass_storage is loaded via modprobe pointing to that backing storage:

sudo modprobe g_mass_storage file=/dev/sd... stall=0

We will use a block device as provided via iSCSI, see below.

(There's also a nice article about only making the Pi Zero W a USB flash drive, so without the connection to the NAS on the other side. Some parts still apply for our scenario: https://magpi.raspberrypi.org/articles/pi-zero-w-smart-usb-flash-drive - Hint: If you take this approach make sure that your container file is large enough for your Smart TV. I just discovered that my LG TV only accepts flash drives with a capacity of at least 4 GBytes.)

Acessing your NAS

Limitation: You cannot directly provide access to a directory shared in the network as a backing storage for the gadget. The underlying communication protocol of your NAS often is Server Message Block (SMB) or Common Internet File System (CIFS) or Network File System (NFS).

"The g_mass_storage module needs a block device or a flat file, most network shares aren't either." (source: https://www.raspberrypi.org/forums/viewtopic.php?t=220468)

Instead, it requires your NAS to provide an iSCSI, an Internet Small Computer Systems Interface, "an Internet Protocol (IP)-based storage networking standard for linking data storage facilities. It provides block-level access to storage devices by carrying SCSI commands over a TCP/IP network. iSCSI is used to facilitate data transfers over intranets (...)." (source: https://en.wikipedia.org/wiki/ISCSI)

As it is based on TCP/IP networks, it is basically independent from the underlying link layer, i.e. you should be able to access it both via a wired Ethernet connection or wireless Wi-Fi. This depends on your local setup. Keep in mind, that the throughput via Ethernet should be higher.

You need to ask your NAS' user manual on how to enable it as an iSCSI target.

On the SBC running Linux, you need to perform some more steps to initiate an iSCSI connection to your NAS. Matt Olan has a pretty nice description in the "Method" section of https://matt.olan.me/making-a-piscsi-usb-drive-part-1/ - it also describes the previous steps of setting up the mass storage gadget as sketched above.

Hardware selection hints

  • Some of the Raspberry Pi SBCs connect their USB to a USB hub or tie the USB ID pin permanently to ground on their printed circuit boards. This does not make them usable as USB slave device via USB OTG.
  • Dependent on your SBC, you may only have either Wi-Fi or Ethernet connectivity.
  • You might want to pick a SBC with USB 3.0 OTG to achieve higher data rates. Make sure that "super-speed" is used and not "high-speed" only.
  • Raspberry Pi Zero W and the Raspberri Pi 4 Model B seem to work (no guarantee).
  • Matt Olan has first used a Raspberry Pi Zero W (USB 2.0 OTG, WiFi) and then a RockPi 4b (USB 3.0 OTG).

Alternate way without iSCSI support

If your NAS does not provide an iSCSI, a different approach can be taken. The files on the NAS are accessed via SMB.

           SMB or NFS or … via                          Mass Storage
            usually TCP/IP via                        Device Class via
[NAS] ————— Ethernet or Wi-Fi ———— [Linux computer] ———————— USB ————————— [Smart TV]

But, as mentioned earlier, SMB access is not supported with g_mass_storage and this is why we need to take a work-around:

  • a backing storage on the adapter is created and provided to the Smart TV (USB host)
  • it needs to be created as a file with a filesystem in it
  • this is done by using dd, fdisk and mkdosfs (for partitioning and creation of a FAT32 filesystem; the settings like sectors and cylinders should be chosen to match g_mass_storage and your file)
  • access on the gadget can be performed using the loop device driver to map the partition with the backing storage, then mount it (mount -t vfat)
  • mutual exclusive access of the backing storage: it can only be accessed by either the USB host or the adapter itself at once: "Only one system (normally, the USB host) may write to the backing storage, and if one system is writing that data, no other should be reading it." (source: http://www.linux-usb.org/gadget/file_storage.html)
  • therefore, the data needs to be copied between adapter and NAS:
    • e.g. from the adapter to the NAS after a movie has been recorded
    • e.g. from the NAS to the adapter before watching a recorded movie from the adapter
  • further info and instructions can be found here: http://www.linux-usb.org/gadget/file_storage.html (English), https://raspberrypi.stackexchange.com/questions/112957/mount-smb-share-as-file (English) and https://forum-raspberrypi.de/forum/thread/36132-usb-gadget-mass-storage-emulation/ (German)

The drawback of this approach is that you need to synchronize/schedule accesses to the backing storage. Copying the data from A to B and vice versa will take some time and you will need additional steps to automate this.

Other attempts

  • I do not recall the reference but the approach mentioned above seems to require a Linux kernel version >= 4.4.
  • If your Smart TV supports the Media Transfer Protocol (MTP) you may be able to take a different approach.
  • Matt Olan has mentioned that some "NAS manufacturers such as QNAP offer support for direct USB storage"
  • I've read short summaries about QEMU's Virtual VFAT Filesystem (vvfat), but I am not sure if it can be applied in this scenario.
2

I looked a bit further and the "Infinite USB Memory"-stick from Infinitec claims to do just this. Unfortunately it gets a pretty bad review from Engadget where it was reviewed yesterday (what an incredible coincidence, as I've been thinking about this for quite some time!). But while this particular product may not work very well it does actually offer the exact functionality I was looking for.

2
  • "Infinite USB Memory"? Nice. Maybe the implementation is not good, but the concept can be used to create a better one. – Bobson Mar 11 '12 at 20:26
  • That first link is broken. Does this device (or a similar one) still exist? – detly Apr 27 '15 at 0:18
2

If your NAS is a Linux-based PC, maybe, just maybe you might, with a lot of work, get something like this PCI USB 2.0 Peripheral Controller to work. This PCI card adds a "peripheral side" USB port to your system, NOT a "host side" port. So the possibility is to turn your entire PC into a USB device connectible to another PC. I know Linux has support for "USB Gadgets" - with the proper programs running it would certainly seem possible.

If your NAS can expose Samba shares, you might be able to do something with a rooted Android phone. On my Droid, the SD card appears internally as /mnt/sdcard. Running Samba on it is certainly possible. I've never tried anything like mount -t cifs //192.168.X.X/mysambashare /mnt/sdcard/mysambashare and then tried to use the phone as a USB storage device ... If I have time to try it, I'll update.

1
  • A pity that is was never updated. An idea stays as that. – JackGrinningCat Feb 25 '19 at 18:05
0

Have you tried connecting the NAS as a mapped network drive (so it shows up with a drive letter (H: for example)) rather than trying to use it as a network share accessible by //address/folder?

I've actually just gone blank but I believe you can map a network drive by right clicking on my computer or my network (assuming this is windows), I forget which.

If you aren't on windows, do please update us so we can help further.

Thanks.

2
  • 4
    Thanks for the suggestion, but the networked drive must appear as a USB-device to my TV so there's no pc involved. I should have made this clearer and have just added a crude illustration to the question. – Richard Flamsholt Nov 26 '10 at 23:25
  • My apologies. Got me on that one. – WoodE Nov 26 '10 at 23:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.