Project

General

Profile

Using USB Mass Storage Peripheral driver » eject_usb.sh

Jonathan Cormier, 10/02/2014 02:38 PM

 
1
#!/bin/sh
2

    
3
# Remove mass storage module and mount loopback file.  
4

    
5
FILE=/dev/shm/20M
6

    
7
rmmod g_mass_storage
8

    
9
# Attach loopback file to /dev/loop0
10
[ ! -e /dev/loop0 ] && mknod /dev/loop0 b 7 0
11
losetup -o 4096 /dev/loop0 $FILE || die
12

    
13
# Mount fat32 partition
14
mkdir -p /mnt/loop
15
mount -t vfat /dev/loop0 /mnt/loop || die
16

    
17
# Copy files from loopback file
18
touch /mnt/loop/testfile || die
19

    
20
# Unmount and unAttach
21
umount /mnt/loop || die
22
losetup -d /dev/loop0 || die
23

    
24
# Delete file to free up memory
25
rm -f $FILE
(1-1/2) Go to top
Add picture from clipboard (Maximum size: 1 GB)