Bike Forums

Bike Forums (https://www.bikeforums.net/forum.php)
-   Foo (https://www.bikeforums.net/foo/)
-   -   Linux as a USB device? (https://www.bikeforums.net/foo/524406-linux-usb-device.html)

mlts22 03-26-09 11:36 AM

Linux as a USB device?
 
This is something I have not been able to find much on, but this is for a project I'm tinkering with:

How can one make Linux (or BSD) appear to another machine as a USB device, and is there hardware that would allow this? I'm not meaning a USB host that uses a type "A" port, but a USB device that uses a type "B" port. I'd like to build a machine that uses Linux and LVM capabilities, and where I can plug it into another machine, have it appear as plain USB hard disk.

The goal is to make a "mini SAN" where I can plug four machines into the Linux box, each seeing different volumes while in reality, the volumes are just chunks carved from LVM partitions. Is this possible at all? My goal is to make an embedded box that boots up, asks for a hardware crypto card and PIN, mounts multiple partitions via encrypted loopback and makes them available as plain removable USB drives to whatever hosts are plugged in.

KingTermite 03-26-09 11:42 AM

I'm a bit confused still as to what it is you are trying to do.

Do you to plug in a linux machine in to another linux machine and have it show up as a USB hard disk? If so, then why does port type matter? You can get an A/B converter if needed, right?

mlts22 03-26-09 11:53 AM


Originally Posted by KingTermite (Post 8604191)
I'm a bit confused still as to what it is you are trying to do.

Do you to plug in a linux machine in to another linux machine and have it show up as a USB hard disk? If so, then why does port type matter? You can get an A/B converter if needed, right?

The port type matters because it tells which is the USB host, and which is the device. A B socket means that that is a device, while an A plug means that it is the host which gives commands.

What I want to do is have other machines plug into the Linux machine, using a normal A-B cable just like you do with any other removable drive. The Linux box is going to be handling an encryption layer and a LVM layer for RAID. The computers plugged into it just see a removable disk.

KingTermite 03-26-09 12:06 PM


Originally Posted by mlts22 (Post 8604310)
The port type matters because it tells which is the USB host, and which is the device. A B socket means that that is a device, while an A plug means that it is the host which gives commands.

What I want to do is have other machines plug into the Linux machine, using a normal A-B cable just like you do with any other removable drive. The Linux box is going to be handling an encryption layer and a LVM layer for RAID. The computers plugged into it just see a removable disk.

It sounds like something that would definitely need driver/kernel support. It doesn't sound like anything I've heard of being done already. Interesting idea.

Scummer 03-26-09 01:02 PM

hmm.. how about this approach:
http://www.linux-usb.org/usbnet/

Just use an iSCSI driver to access the partitions from the hosts to your Linux iSCSI target.

tjwarren 03-26-09 01:02 PM

You can't go USB directly between two machines; you need to go through a USB hub.

Why not just make it Network Attached Storage?

mlts22 03-26-09 01:19 PM


Originally Posted by tjwarren (Post 8604906)
You can't go USB directly between two machines; you need to go through a USB hub.

Why not just make it Network Attached Storage?

In theory you can, however, the machine must have an ability to run as a USB device, which I have not found any way to do so.

This is solving a different issue than NAS. What this machine is doing is providing secure access to disk volumes that are not being passed over any network. If I find a way to get this working with eSATA, this mini-SAN machine can replace the boot drives of 3-4 computers. Coupled with an encryption layer, this will allow people to work on some very sensitive data without any additional security measures needed.

The goal is to have a mini SAN head that uses SATA, and USB instead of fiber channel. This will allow this technology to be used in a lot more places such as small businesses.

MrCrassic 03-26-09 01:37 PM


Originally Posted by mlts22 (Post 8604149)
This is something I have not been able to find much on, but this is for a project I'm tinkering with:

How can one make Linux (or BSD) appear to another machine as a USB device, and is there hardware that would allow this? I'm not meaning a USB host that uses a type "A" port, but a USB device that uses a type "B" port. I'd like to build a machine that uses Linux and LVM capabilities, and where I can plug it into another machine, have it appear as plain USB hard disk.

The goal is to make a "mini SAN" where I can plug four machines into the Linux box, each seeing different volumes while in reality, the volumes are just chunks carved from LVM partitions. Is this possible at all? My goal is to make an embedded box that boots up, asks for a hardware crypto card and PIN, mounts multiple partitions via encrypted loopback and makes them available as plain removable USB drives to whatever hosts are plugged in.

I see what you want to do. I don't think you need Linux to accomplish this, but here's a rough flow of what I think you have in mind:

- Insert device into USB port.
- Device is powered, begins booting Linux internally.
- Linux is at login state, and prompts user to login to device.
- User logs in, Linux auto-mounts write-accessible partition. Signals device to signal Windows to mount the path.
- Path is mounted, and is now accessible until disconnected.

One problem I can see here is preserving data at disconnect. I learned recently that file systems do not sync data immediately; the data to be written is cached and then is synced a few seconds later, when it automatically syncs all cached data. Unless you plan to mount the filesystem to sync everything at write time (which will make for a very slow storage device), a dirty shutdown might corrupt data.

Another foreseeable problem is operating system integrity. What happens if, for some unknown reason, one of the system files gets corrupted and cannot boot the next time around? What happens if the bootloader gets corrupted? You will need to plan for those events.

The obvious issue is resources and economics. This device is going to need a small CPU, RAM and Flash RAM for storage. How can you build a device that includes all of these in a small and cost-effective package when hardware-based encryption is much cheaper and, in most cases, more secure?

I think that this is an interesting idea that could be extended much further than just storage devices.

MrCrassic 03-26-09 01:39 PM


Originally Posted by mlts22 (Post 8605078)
In theory you can, however, the machine must have an ability to run as a USB device, which I have not found any way to do so.

I don't think you will need to configure the OS to try and be a USB device natively. I think the (slightly) easier way is to make the OS recognize it as a USB device through the driver, which the kernel in the device will have to support.

tjwarren 03-26-09 02:05 PM


Originally Posted by mlts22 (Post 8605078)

Originally Posted by tjwarren (Post 8604906)
You can't go USB directly between two machines; you need to go through a USB hub.

In theory you can, however, the machine must have an ability to run as a USB device, which I have not found any way to do so.

I don't believe this is true. My understanding is that USB does not provide for host-to-host communication; communication between two host devices must pass through a bridge.

If you have some documentation that shows otherwise, I'd love to see it.

RubenX 03-26-09 10:28 PM


Originally Posted by tjwarren (Post 8604906)
You can't go USB directly between two machines; you need to go through a USB hub.

Why not just make it Network Attached Storage?

That was my question exactly. Maybe on a separate network with 2nd NICs if security is a mayor concern, with a red cable that reads "do not sniff mah!"...

enine 03-27-09 06:17 AM

USB device hardware is slightly different from USB host hardware. There are device hardware boards available for $$$ and the drivers are out there. it can be done but not really inexpensively.

mlts22 03-27-09 12:13 PM

The advantage of USB is that it is simple to use and requires no TCP/IP stack, network drivers, CIFS shares. Just plug in and go. Eventually I'd like to offer eSATA for a boot disk.

Here are the advantages of such a configuration that uses a LVM RAID 5 backend:

1: I can implement change logging technology where I can make a disk image, have any changes to a log partition and then on command, dump all changes, reverting back to the original partition. This is on a sector basis, below the filesystem. The advantage of this is that a machine can have a boot disk for testing to be reverted back, and no matter how bad the malware infection is, it is revertable no matter what.

2: I can mount the machine's filesystem read-only from the Linux side, make a snapshot using the LVM functionality while the machine is running, and do full or incremental backups of the filesystem, completely independant of the machine itself.

3: I can implement a dm-crypt loopback encrypted layer that uses a cryptographic tokens and a PINpad on the physical box. The PC that is plugged into it requires no drivers and doesn't care about the encryption as long as it can see the drive image.

4: I can implement a UFS filesystem layer so all writes are kept permanently and cryptographically signed with a timestamp by the machine. This allows me to create an external box that can be used for archiving of files for long term compliance to SOX and HIPAA.


All times are GMT -6. The time now is 07:16 PM.


Copyright 2018 MH Sub I, LLC dba Internet Brands. All rights reserved. Use of this site indicates your consent to the Terms of Use.