tjmnmk / gadget_cdrom

gadget_cdrom converts your Raspberry Pi to virtual usb cdrom
Other
94 stars 25 forks source link

Possible to use partition for HDD storage? #7

Closed lordbink closed 1 month ago

lordbink commented 3 years ago

One of the (minor) drawbacks is the speed at adding files to the device. Is it possible to have a partition be used in place of the iso.img file? That way you could put the sd card in a computer directly to transfer the files.

Is there a limit to the gadget module that prevents you from using a partition?

lordbink commented 3 years ago

It appears it is possible. The documentation here says using a device is supported. https://linux-sunxi.org/USB_Gadget/Mass_storage

I will do some testing at some point and try to document the process/results here.

lordbink commented 3 years ago

Here are my notes from testing:

  1. Backup all the img and isos you placed on the storage/HDD device
  2. Delete /iso.img (caution: this deletes all your files that were on HDD/Storage)
  3. Resize your root partition - I booted into a second system with gparted - mine has 15G, and I left the rest for storage/HDD)
  4. Create and format the leftover partition, I used NTFS
  5. Put the sd card back into the pi and boot
  6. Inside the gadget_cdrom directory: Replace all instances of /iso.img (or "$(losetup -PLf /iso.img --show)p1") with the new partition (mine is /dev/mmcblk0p3)
    • Mode.sh
    • Clean.sh
  7. Test by rebooting the Pi or restarting the gadget_cdrom service
  8. Test by shutting down the Pi, removing the sd card and putting in a PC, transfer your files, eject/unmount and put back in the Pi

I was able to get an improvement in speed from 10-20M/s (through the Pi) to 90M/s (direct to PC). I am not sure this is worth the extra effort yet. For reference the card I was using is this a SanDisk 256GB Extreme MicroSDXC Micro SD - SDSQXA1-256G-GN6MA.

lordbink commented 1 month ago

I answered my own question.