Skip to content

Instantly share code, notes, and snippets.

@tobiasmcnulty
Last active March 17, 2022 02:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tobiasmcnulty/7d649cc5ac0fd39196d11c8aa4595e20 to your computer and use it in GitHub Desktop.
Save tobiasmcnulty/7d649cc5ac0fd39196d11c8aa4595e20 to your computer and use it in GitHub Desktop.
Unit file to load the `g_mass_storage` module after `iscsi.service`
# Adapted from: https://unix.stackexchange.com/a/260022/18065
[Unit]
Description=Loads kernel module for USB OTG
After=iscsi.service
DefaultDependencies=false
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/sbin/modprobe g_mass_storage file=/dev/xyx
ExecStop=/sbin/rmmod g_mass_storage
[Install]
WantedBy=sysinit.target
[ 16.570113] Loading iSCSI transport class v2.0-870.
[ 16.644803] iscsi: registered transport (tcp)
[ 16.648670] scsi host0: iSCSI Initiator over TCP/IP
[ 16.666917] scsi 0:0:0:0: Direct-Access iSCSI Disk 0123 PQ: 0 ANSI: 7
[ 16.668074] sd 0:0:0:0: Attached scsi generic sg0 type 0
[ 16.668457] sd 0:0:0:0: Power-on or device reset occurred
[ 16.680206] sd 0:0:0:0: [sda] 536870920 4096-byte logical blocks: (2.20 TB/2.00 TiB)
[ 16.680242] sd 0:0:0:0: [sda] 32768-byte physical blocks
[ 16.680594] sd 0:0:0:0: [sda] Write Protect is off
[ 16.680618] sd 0:0:0:0: [sda] Mode Sense: 7f 00 10 08
[ 16.681096] sd 0:0:0:0: [sda] Write cache: enabled, read cache: enabled, supports DPO and FUA
[ 16.681974] sd 0:0:0:0: [sda] Optimal transfer size 1048576 bytes
[ 16.721611] sda: sda1
[ 16.743345] sd 0:0:0:0: [sda] Attached SCSI disk
[ 16.848690] Mass Storage Function, version: 2009/09/11
[ 16.848727] LUN: removable file: (no medium)
[ 16.849139] LUN: file: /dev/sda
[ 16.849162] Number of LUNs=1
[ 16.850087] g_mass_storage gadget: Mass Storage Gadget, version: 2009/09/11
[ 16.850117] g_mass_storage gadget: userspace failed to provide iSerialNumber
[ 16.850124] g_mass_storage gadget: g_mass_storage ready
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment