rooster1
Posts: 17
Joined: Tue Feb 12, 2013 8:55 pm

usb stick problem

Fri Apr 12, 2013 10:21 pm

I've got a usb stick which I've used before but I reformatted it on ubuntu using the 'compatible with all systems (FAT)' option.

I then put it into the usb hub connected to the PI and do the following...

mkdir /media/usbstick
mount -t vfat -o rw /dev/sda1 /media/usbstick
cp somefiles /media/usbstick
sync
umount /media/usbstick
rm -r /media/usbstick

when I remount the usb stick, it has copied some files, missed some files and created a load of new gibberish files such as...

-rw-r--r-- 1 russ russ 1344437036 Oct 13 1902 "az":69,."ss
d????????? ? ? ? ? ? b0","mod.e":
d????????? ? ? ? ? ? ce":"/de.v/t
-rw-r--r-- 1 russ russ 576875881 Jan 12 1997 ck":0.00.00,

the filenames look like data out of some of the files (gps data).

any idea what I am doing wrong?

Thanks

R

sdjf
Posts: 1395
Joined: Fri Mar 16, 2012 5:20 am
Location: California
Contact: Website

Re: usb stick problem

Sat Apr 13, 2013 12:27 am

You need to say what tool(s) you used to reformat the stick. Sometimes reformatting does not work unless you wipe out everything in the partition or on the device with something like "wipe".

Also, after creating a new file system, it is always wise to run fsck to make sure the file system is clean before writing to it.

And when did you issue the following command? It does not make sense after umounting the stick, which is the way your post reads.

rm -r /media/usbstick

the above command would recursively remove all files in the stick, if any were in the main directory, and maybe below, I am not sure as I generally do not use rm -r.
FORUM TIP: To view someone's posting history, sign in, click on their user name, then on "Search User's Posts." || Running ArchLinuxArm on Model 2B and 512MB Model B

rooster1
Posts: 17
Joined: Tue Feb 12, 2013 8:55 pm

Re: usb stick problem

Sat Apr 13, 2013 6:30 am

sdjf wrote:You need to say what tool(s) you used to reformat the stick. Sometimes reformatting does not work unless you wipe out everything in the partition or on the device with something like "wipe".

Also, after creating a new file system, it is always wise to run fsck to make sure the file system is clean before writing to it.

And when did you issue the following command? It does not make sense after umounting the stick, which is the way your post reads.

rm -r /media/usbstick

the above command would recursively remove all files in the stick, if any were in the main directory, and maybe below, I am not sure as I generally do not use rm -r.
I used the format option when right clicking on the usb stick icon on the left panel on ubuntu. I really want to format the usb stick using command line on raspberry pi, but I don't know the commands to do this and check it is ok (fsck?).

My understanding was that I do

mkdir /media/usbstick at the beginning and
rm -r /media/usbstick at the end to create and delete the directory that the usb will be mounted on?

R

cleverca22
Posts: 1932
Joined: Sat Aug 18, 2012 2:33 pm

Re: usb stick problem

Sat Apr 13, 2013 6:34 am

just rmdir /media/usbstick

if you did anything wrong, it will refuse to do bad stuff, and just give an error
as for formatting, get a root shell (sudo -i) then type in mkfs. and hit tab twice
you should get a list of options similar to this: mkfs mkfs.bfs mkfs.cramfs mkfs.ext2 mkfs.ext3 mkfs.ext4 mkfs.ext4dev mkfs.minix mkfs.msdos mkfs.vfat mkfs.xfs
just pick one and give it the block device!

Code: Select all

mkfs.vfat /dev/sda1

rooster1
Posts: 17
Joined: Tue Feb 12, 2013 8:55 pm

Re: usb stick problem

Sat Apr 13, 2013 6:58 am

cleverca22 wrote:just rmdir /media/usbstick

if you did anything wrong, it will refuse to do bad stuff, and just give an error
as for formatting, get a root shell (sudo -i) then type in mkfs. and hit tab twice
you should get a list of options similar to this: mkfs mkfs.bfs mkfs.cramfs mkfs.ext2 mkfs.ext3 mkfs.ext4 mkfs.ext4dev mkfs.minix mkfs.msdos mkfs.vfat mkfs.xfs
just pick one and give it the block device!

Code: Select all

mkfs.vfat /dev/sda1
after mkfs[tabtab] I get the options...
mkfs mkfs.bfs mkfs.cramfs mkfs.ext2 mkfs.ext3 mkfs.ext4 mkfs.ext4dev mkfs.minix

so I do
mkfs.ext2 /dev/sda1

which seems to work (but the last line gives ext2fs_mkdir: Attempt to read block from filesystem resulted in short read while creating root dir)

I then mount...
mount -t ext2 -o rw /dev/sda1 /media/usbstick/

and get the error...
mount: wrong fs type, bad option, bad superblock on /dev/sda1,
missing codepage or helper program, or other error
In some cases useful info is found in syslog - try
dmesg | tail or so

??

rooster1
Posts: 17
Joined: Tue Feb 12, 2013 8:55 pm

Re: usb stick problem

Sat Apr 13, 2013 7:09 am

in fact, I've had lots of problems with the usb stick

all want to do is

a) rpi to boot up
b) format usb stick (maybe)
c) mount usb stick
d) copy data to usb stick
e) unmount usb stick
f) read data from usb stick in windows or linux via windowing system - to upload to a website

i have corrupted a few sticks, i think having the stick mounted when the power goes off, formatting the stick on windows or ubuntu gives different behaviour etc. also umount /dev/sda1 rather than umount /media/usbstick doesn't help!

rooster1
Posts: 17
Joined: Tue Feb 12, 2013 8:55 pm

Re: usb stick problem

Sat Apr 13, 2013 2:04 pm

rooster1 wrote:I've got a usb stick which I've used before but I reformatted it on ubuntu using the 'compatible with all systems (FAT)' option.

I then put it into the usb hub connected to the PI and do the following...

mkdir /media/usbstick
mount -t vfat -o rw /dev/sda1 /media/usbstick
cp somefiles /media/usbstick
sync
umount /media/usbstick
rm -r /media/usbstick

when I remount the usb stick, it has copied some files, missed some files and created a load of new gibberish files such as...

-rw-r--r-- 1 russ russ 1344437036 Oct 13 1902 "az":69,."ss
d????????? ? ? ? ? ? b0","mod.e":
d????????? ? ? ? ? ? ce":"/de.v/t
-rw-r--r-- 1 russ russ 576875881 Jan 12 1997 ck":0.00.00,

the filenames look like data out of some of the files (gps data).

any idea what I am doing wrong?

Thanks

R
looks like it might be the powered usb (shame because its the only one which works with the bluetooth)

when plugged straight into the pi, all the above seems to work ok :) , :(

rooster1
Posts: 17
Joined: Tue Feb 12, 2013 8:55 pm

Re: usb stick problem

Sun Apr 14, 2013 9:55 am

rooster1 wrote:
rooster1 wrote:I've got a usb stick which I've used before but I reformatted it on ubuntu using the 'compatible with all systems (FAT)' option.

I then put it into the usb hub connected to the PI and do the following...

mkdir /media/usbstick
mount -t vfat -o rw /dev/sda1 /media/usbstick
cp somefiles /media/usbstick
sync
umount /media/usbstick
rm -r /media/usbstick

when I remount the usb stick, it has copied some files, missed some files and created a load of new gibberish files such as...

-rw-r--r-- 1 russ russ 1344437036 Oct 13 1902 "az":69,."ss
d????????? ? ? ? ? ? b0","mod.e":
d????????? ? ? ? ? ? ce":"/de.v/t
-rw-r--r-- 1 russ russ 576875881 Jan 12 1997 ck":0.00.00,

the filenames look like data out of some of the files (gps data).

any idea what I am doing wrong?

Thanks

R
looks like it might be the powered usb (shame because its the only one which works with the bluetooth)

when plugged straight into the pi, all the above seems to work ok :) , :(
ok, update for anybody that cares!!

i have had lots of problems with usb powered hubs. the 4 port belkin works fine though.

i needed extra ports so got the 7 port belkin - same style

only 3 ports of this work perfectly with the Pi, the other 4 have problems (maybe the 4 are daisy chained off the other 4, leaving only 3 good ones).

:)

cleverca22
Posts: 1932
Joined: Sat Aug 18, 2012 2:33 pm

Re: usb stick problem

Sun Apr 14, 2013 10:16 am

you know what dave says!
don't turn it on, TAKE IT APPART!!!
it should be easy to see if its 1 hub or 2 hubs

(from the eevblog, http://www.youtube.com/eevblog/)

sdjf
Posts: 1395
Joined: Fri Mar 16, 2012 5:20 am
Location: California
Contact: Website

Re: usb stick problem

Sun Apr 14, 2013 2:27 pm

Where on earth did you get the idea that to unmount the usbstick you remove the directory? That is not the way to do it. My instructions are all for what to do on the Raspberry Pi itself.

You create a permanent mount point, available for use when needed, with

mkdir /media/usbstick

Then the following entries you mentioned, look fine:

mount -t vfat -o rw /dev/sda1 /media/usbstick

cp somefiles /media/usbstick
sync
umount /media/usbstick

But no need to rmdir, leave it there for use when needed. And, yeah, looks like the file corruption part was power issue.
FORUM TIP: To view someone's posting history, sign in, click on their user name, then on "Search User's Posts." || Running ArchLinuxArm on Model 2B and 512MB Model B

Return to “Troubleshooting”