Unix Technical Forum

usb memory stick boot sector problem

This is a discussion on usb memory stick boot sector problem within the Slackware Linux Support forums, part of the Unix Operating Systems category; --> I have a usb memory stick to transfer files between my home and office computer. When plugging in the ...


Go Back   Unix Technical Forum > Unix Operating Systems > Slackware Linux Support

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-20-2008, 10:24 AM
Henk Jan Priester
 
Posts: n/a
Default usb memory stick boot sector problem

I have a usb memory stick to transfer files between my home
and office computer.

When plugging in the stick dmesg contains:

hub.c: new USB device 00:02.2-8, assigned address 7
scsi3 : SCSI emulation for USB Mass Storage devices
Vendor: Generic Model: Flash Disk Rev: 8.01
Type: Direct-Access ANSI SCSI revision: 02
Attached scsi removable disk sdb at scsi3, channel 0, id 0, lun 0
SCSI device sdb: 511998 512-byte hdwr sectors (262 MB)
sdb: Write Protect is off
sdb: sdb1 sdb2 sdb4
WARNING: USB Mass Storage data integrity not assured
USB Mass Storage device found at 7

When I mount the stick:

mount -t vfat /dev/sdb /mnt/stick
mount: wrong fs type, bad option, bad superblock on /dev/sdb,
missing codepage or other error
In some cases useful info is found in syslog - try
dmesg | tail or so

dmesg contains:

I/O error: dev 08:10, sector 0
FAT: unable to read boot sector

It seems that the boot sector is corrupt, it worked the last time
I used it (a couple of weeks ago, the stick is about 3 months)

Is there a way to restore the boot sector or should I get a
new stick?

Henk Jan






Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-20-2008, 10:24 AM
Frank Boehm
 
Posts: n/a
Default Re: usb memory stick boot sector problem

Henk Jan Priester <henkjan@prienix.nospam.xs4all.nl> wrote:
> I have a usb memory stick to transfer files between my home
> and office computer.
>
> When plugging in the stick dmesg contains:
>
> SCSI device sdb: 511998 512-byte hdwr sectors (262 MB)
> sdb: Write Protect is off
> sdb: sdb1 sdb2 sdb4

^^^

> mount -t vfat /dev/sdb /mnt/stick
>
> It seems that the boot sector is corrupt, it worked the last time
> I used it (a couple of weeks ago, the stick is about 3 months)
>
> Is there a way to restore the boot sector or should I get a
> new stick?


nothing is broken, you mount the whole disk /dev/sdb instead of a
parition on a disk, e.g. /dev/sdb1

cu Frank

--
UNIX is many things to many people,
but it's never been everything to anybody.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-20-2008, 10:25 AM
-pbh-
 
Posts: n/a
Default Re: usb memory stick boot sector problem

Frank Boehm wrote:
> Henk Jan Priester <henkjan@prienix.nospam.xs4all.nl> wrote:
>
>>I have a usb memory stick to transfer files between my home
>>and office computer.
>>
>>When plugging in the stick dmesg contains:
>>
>>SCSI device sdb: 511998 512-byte hdwr sectors (262 MB)
>>sdb: Write Protect is off
>> sdb: sdb1 sdb2 sdb4

>
> ^^^
>
>
>> mount -t vfat /dev/sdb /mnt/stick
>>
>>It seems that the boot sector is corrupt, it worked the last time
>>I used it (a couple of weeks ago, the stick is about 3 months)
>>
>>Is there a way to restore the boot sector or should I get a
>>new stick?

>
>
> nothing is broken, you mount the whole disk /dev/sdb instead of a
> parition on a disk, e.g. /dev/sdb1
>
> cu FrankIn other words - you have 4 partitions on that stick!!

To check the partitions, you can do a 'fdisk -l /dev/sdb', though
chances are they are all vfat. You get their respective sizes by using
fdisk (and also what 'type' of partition). If this is sufficient to tell
you which partition to use, then mount that particular partition - or -
you can mount all 4 to see which one contains what you want:
# mount -t auto /dev/sdb1 /mnt/stick; ls /mnt/stick; umount /mnt/stick
Then do the same for /dev/sdb2, /dev/sdb3 and /dev/sdb4

You _can_ use the entire device without any partitions, ie just like a
floppy disk (man mkdosfs), but the safest is to use one partition and
let this span the entire device (all memory cards and 99% of all
usb-sticks come preformatted this way). That being said, personally I
use two sticks, one with vfat and one with ext2 or reiserfs, I have also
been down to have both a vfat and a linux partition on the same stick,
in which case vfat _must_ be the first partition or windoze wont see it!!

Good luck!
-pbh-

>

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-20-2008, 10:26 AM
Henk Jan Priester
 
Posts: n/a
Default Re: usb memory stick boot sector problem

On Sat, 20 Aug 2005 17:55:02 +0000, -pbh- wrote:

> Frank Boehm wrote:
>> Henk Jan Priester <henkjan@prienix.nospam.xs4all.nl> wrote:
>>
>>>I have a usb memory stick to transfer files between my home
>>>and office computer.
>>>
>>>When plugging in the stick dmesg contains:
>>>
>>>SCSI device sdb: 511998 512-byte hdwr sectors (262 MB)
>>>sdb: Write Protect is off
>>> sdb: sdb1 sdb2 sdb4

>>
>> ^^^
>>
>>
>>> mount -t vfat /dev/sdb /mnt/stick
>>>
>>>It seems that the boot sector is corrupt, it worked the last time
>>>I used it (a couple of weeks ago, the stick is about 3 months)
>>>
>>>Is there a way to restore the boot sector or should I get a
>>>new stick?

>>
>>
>> nothing is broken, you mount the whole disk /dev/sdb instead of a
>> parition on a disk, e.g. /dev/sdb1
>>
>> cu FrankIn other words - you have 4 partitions on that stick!!

> To check the partitions, you can do a 'fdisk -l /dev/sdb', though
> chances are they are all vfat. You get their respective sizes by using
> fdisk (and also what 'type' of partition). If this is sufficient to tell
> you which partition to use, then mount that particular partition - or -
> you can mount all 4 to see which one contains what you want:
> # mount -t auto /dev/sdb1 /mnt/stick; ls /mnt/stick; umount /mnt/stick
> Then do the same for /dev/sdb2, /dev/sdb3 and /dev/sdb4
>
> You _can_ use the entire device without any partitions, ie just like a
> floppy disk (man mkdosfs), but the safest is to use one partition and
> let this span the entire device (all memory cards and 99% of all
> usb-sticks come preformatted this way). That being said, personally I
> use two sticks, one with vfat and one with ext2 or reiserfs, I have also
> been down to have both a vfat and a linux partition on the same stick,
> in which case vfat _must_ be the first partition or windoze wont see it!!
>
> Good luck!
> -pbh-


I have tried all for partions but all still fail.

Initializing USB Mass Storage driver...
usb.c: registered new driver usb-storage
USB Mass Storage support registered.
hub.c: new USB device 00:02.2-8, assigned address 14
scsi3 : SCSI emulation for USB Mass Storage devices
Vendor: Generic Model: Flash Disk Rev: 8.01
Type: Direct-Access ANSI SCSI revision: 02
Attached scsi removable disk sdb at scsi3, channel 0, id 0, lun 0
SCSI device sdb: 511998 512-byte hdwr sectors (262 MB)
sdb: Write Protect is off
sdb: sdb1 sdb2 sdb4
WARNING: USB Mass Storage data integrity not assured
USB Mass Storage device found at 14

mount -t vfat /dev/sdb1 /mnt/stick/
mount: wrong fs type, bad option, bad superblock on /dev/sdb1,
missing codepage or other error
In some cases useful info is found in syslog - try
dmesg | tail or so

In dmesg:

I/O error: dev 08:11, sector 0
FAT: unable to read boot sector

For sdb2 and sdb4 the same error, for sdb3 the message is
not a valid block device.

When running fdisk it fails:

fdisk /dev/sdb

Unable to read /dev/sdb

I don't have a windows system here to check the stick. I can
trt that in the office.

Other suggestions?

Henk Jan


>
>>


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 02-20-2008, 10:26 AM
Grant
 
Posts: n/a
Default Re: usb memory stick boot sector problem

On Sun, 21 Aug 2005 12:24:08 +0200, Henk Jan Priester <henkjan@prienix.nospam.xs4all.nl> wrote:
>
>Other suggestions?


Try reading the thing raw with dd:

# dd if=/dev/sdb bs=512 count=1 | xxd

Should display the MBR, if no error then I'd suggest reading the three
partitions detected at boot

# dd if=/dev/sdb1 of=~/stuck-stick-1

repeat for 2 and 4, you must have some idea how the thing is organised?

See what you get, all this is guess-work as I've yet to play with a
USB stick. Working until recently? Forget to unmount prior to removal
in windows? Surprise removal will break them sooner.

Grant.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 02-20-2008, 10:26 AM
Henk Jan Priester
 
Posts: n/a
Default Re: usb memory stick boot sector problem

On Sun, 21 Aug 2005 20:40:03 +1000, Grant wrote:

> On Sun, 21 Aug 2005 12:24:08 +0200, Henk Jan Priester <henkjan@prienix.nospam.xs4all.nl> wrote:
>>
>>Other suggestions?

>
> Try reading the thing raw with dd:
>
> # dd if=/dev/sdb bs=512 count=1 | xxd
>
> Should display the MBR, if no error then I'd suggest reading the three
> partitions detected at boot
>
> # dd if=/dev/sdb1 of=~/stuck-stick-1
>
> repeat for 2 and 4, you must have some idea how the thing is organised?
>
> See what you get, all this is guess-work as I've yet to play with a
> USB stick. Working until recently? Forget to unmount prior to removal
> in windows? Surprise removal will break them sooner.


dd if=/dev/sdb bs=512 count=1 | xxd
dd: reading `/dev/sdb': Input/output error
0+0 records in
0+0 records out

Yes it worked last time I used it a couple of weeks ago.
I currently used it only between two Linux systems, I don't
know if I have forgotten to unmount it.

Henk Jan




>
> Grant.


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 02-20-2008, 10:26 AM
Eivind Rygg
 
Posts: n/a
Default Re: usb memory stick boot sector problem

On Sun, 21 Aug 2005 12:56:57 +0200, Henk Jan Priester wrote:

> On Sun, 21 Aug 2005 20:40:03 +1000, Grant wrote:
>
>> On Sun, 21 Aug 2005 12:24:08 +0200, Henk Jan Priester <henkjan@prienix.nospam.xs4all.nl> wrote:
>>>
>>>Other suggestions?

>>
>> Try reading the thing raw with dd:
>>
>> # dd if=/dev/sdb bs=512 count=1 | xxd
>>
>> Should display the MBR, if no error then I'd suggest reading the three
>> partitions detected at boot
>>
>> # dd if=/dev/sdb1 of=~/stuck-stick-1
>>
>> repeat for 2 and 4, you must have some idea how the thing is organised?
>>
>> See what you get, all this is guess-work as I've yet to play with a
>> USB stick. Working until recently? Forget to unmount prior to removal
>> in windows? Surprise removal will break them sooner.

>
> dd if=/dev/sdb bs=512 count=1 | xxd
> dd: reading `/dev/sdb': Input/output error
> 0+0 records in
> 0+0 records out
>
> Yes it worked last time I used it a couple of weeks ago.
> I currently used it only between two Linux systems, I don't
> know if I have forgotten to unmount it.
>
> Henk Jan
>
>
>
>
>>
>> Grant.


I had a similar problem once. Device nodes in /dev did not exist.

Try 'mknod /dev/sda b 8 0'

and/or

mknod /dev/sda1 b 8 1



E. R.


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 02-20-2008, 10:26 AM
Henk Jan Priester
 
Posts: n/a
Default Re: usb memory stick boot sector problem

On Sun, 21 Aug 2005 13:57:33 +0200, Eivind Rygg wrote:

> On Sun, 21 Aug 2005 12:56:57 +0200, Henk Jan Priester wrote:
>
>> On Sun, 21 Aug 2005 20:40:03 +1000, Grant wrote:
>>
>>> On Sun, 21 Aug 2005 12:24:08 +0200, Henk Jan Priester <henkjan@prienix.nospam.xs4all.nl> wrote:
>>>>
>>>>Other suggestions?
>>>
>>> Try reading the thing raw with dd:
>>>
>>> # dd if=/dev/sdb bs=512 count=1 | xxd
>>>
>>> Should display the MBR, if no error then I'd suggest reading the three
>>> partitions detected at boot
>>>
>>> # dd if=/dev/sdb1 of=~/stuck-stick-1
>>>
>>> repeat for 2 and 4, you must have some idea how the thing is organised?
>>>
>>> See what you get, all this is guess-work as I've yet to play with a
>>> USB stick. Working until recently? Forget to unmount prior to removal
>>> in windows? Surprise removal will break them sooner.

>>
>> dd if=/dev/sdb bs=512 count=1 | xxd
>> dd: reading `/dev/sdb': Input/output error
>> 0+0 records in
>> 0+0 records out
>>
>> Yes it worked last time I used it a couple of weeks ago.
>> I currently used it only between two Linux systems, I don't
>> know if I have forgotten to unmount it.
>>
>> Henk Jan
>>
>>
>>
>>
>>>
>>> Grant.

>
> I had a similar problem once. Device nodes in /dev did not exist.
>
> Try 'mknod /dev/sda b 8 0'
>
> and/or
>
> mknod /dev/sda1 b 8 1


/dev/sda is my sata drive and does exist. /dev/sdb is for the memory
stick and does exist as well.
ls -l /dev/sdb*
brw-r----- 1 root disk 8, 16 Apr 29 1995 /dev/sdb
brw-r----- 1 root disk 8, 17 Apr 29 1995 /dev/sdb1
brw-r----- 1 root disk 8, 26 Apr 29 1995 /dev/sdb10
brw-r----- 1 root disk 8, 27 Apr 29 1995 /dev/sdb11
brw-r----- 1 root disk 8, 28 Apr 29 1995 /dev/sdb12
brw-r----- 1 root disk 8, 29 Apr 29 1995 /dev/sdb13
brw-r----- 1 root disk 8, 30 Apr 29 1995 /dev/sdb14
brw-r----- 1 root disk 8, 31 Apr 29 1995 /dev/sdb15
brw-r----- 1 root disk 8, 18 Apr 29 1995 /dev/sdb2
brw-r----- 1 root disk 8, 19 Apr 29 1995 /dev/sdb3
brw-r----- 1 root disk 8, 20 Apr 29 1995 /dev/sdb4
brw-r----- 1 root disk 8, 21 Apr 29 1995 /dev/sdb5
brw-r----- 1 root disk 8, 22 Apr 29 1995 /dev/sdb6
brw-r----- 1 root disk 8, 23 Apr 29 1995 /dev/sdb7
brw-r----- 1 root disk 8, 24 Apr 29 1995 /dev/sdb8
brw-r----- 1 root disk 8, 25 Apr 29 1995 /dev/sdb9

Henk Jan

>
>
>
> E. R.


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 02-20-2008, 10:34 AM
TTK Ciar
 
Posts: n/a
Default Re: usb memory stick boot sector problem

Sorry for coming into this so late .. here's a formula I used
for making a custom knoppix distrib bootable from a usb-dongle for
The Archive's petabox project, and a similar process should also
work for slackware. The use of syslinux and the "special" SPB
custom boot block from 8ung.at were the key I needed. I never
did get lilo to work for it.

Ignore the cautionary note at the end, it's particular to the
hardware we were using for that project.

-- TTK

#!/bin/true
#
# First check out the petabox installation files:
cd /
cvs -d ws20:/var/cvs /petabox/install

# Load the usb mass storage module to map the usb device to /dev/sda:
modprobe usb-storage

# Create a mountpoint for the usb device's filesystem:
mkdir /au

# Wipe any existing partition and bootblock:
dd if=/dev/zero of=/dev/sda bs=1024k count=1

# Now we need to label the partition table as DOS-style formatted.
# For some reason "apt-get install mtools" didn't install "mlabel",
# which is the normal tool of choice for this sort of thing. So we
# will use parted.
parted -s -- /dev/sda mklabel msdos

# Next, partition the device with a single partition of type "b" (Win95 Fat32)
echo '/dev/sda1 : start= 1, size= 1014, Id= b' | sfdisk -uC /dev/sda

# and mark the partition as "bootable"
echo ',,,*' | sfdisk -N1 /dev/sda

# Then create a dos filesystem on the newly created partiton:
mkdosfs /dev/sda1

# Mount the partition:
mount -t vfat /dev/sda1 /au

# Put the Feather Linux files onto the filesystem:
cd /au
unzip /petabox/install/usb-100.zip

# Now unmount the filesystem:
# This might take a *very* long time to complete. Be patient.
# What's happening is that most of the data you just wrote to this filesystem
# is "really" just in linux's filesystem cache. It needs to flush the cache
# to the USB device before it can unmount it.
cd ..
umount /au

# Make the partition bootable with syslinux:
syslinux /dev/sda1

# Install the SPB custom boot block on the USB device to make it bootable:
# You can't use the standard linux bootblock, must use the SPB-linux file.
dd if=/petabox/install/spb2_mbr.sec of=/dev/sda

# (further discussion of this can be found at
# http://rz-obrian.rz.uni-karlsruhe.de/knoppix-usb/ and
# http://www.8ung.at/spblinux/)
#
# At this point the USB device should be bootable on any PC that's capable of
# booting off USB. You will likely need to set the BIOS to prefer booting off
# a device of type "USB HDD" though some bioses may allow or even require
# "USB Zip Drive."
#
# NOTE: AFTER BOOTING FROM USB DEVICE, MACHINE MUST BE "HARD" POWER-CYCLED.
# The plug must be removed from the power supply, and re-entered after a slow
# count of four. Otherwise the USB device is left in a disabled state.
# (This behavior might change if we switch to a different motherboard.)

echo 'done.'

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 02-20-2008, 10:35 AM
Frank Boehm
 
Posts: n/a
Default Re: usb memory stick boot sector problem

TTK Ciar <ttk@remove_this_and_all_after_org.ciar.org.hyperc ount.com> wrote:

<snipped description, IMHO unneccessary complex>

You are right, important key is to write a valid mbr, I do prefer
http://ms-sys.sourceforge.net/

Use as partition type (6) FAT16 and not (b) W95 FAT32, the
documentation for syslinux says *only* Fat16 can be used.

Which partition type did you actually write/format, might be different
from the entry in the partition table?

Should be possible to use loadlin with FAT32, but untested by me, I'm
using syslinux on a FAT16 partition.


next is a part of my own documentation for another project
http://www.baldar.de/pub/restore/how...tore-HOWTO.txt
-----------------------------------------------------------------------
6.15. USB-Stick and USB-hdd

My kernel can be used to boot an usb-stick or usb-hdd. Find out, if
your bios will need an usb-stick formatted as a super floppy without
partitions. Newer bios will expect a normal hdd partition layout.
Boot from CD, your stick is detected by the kernel? Use cfdisk to
create a beautiful new partition table. First partition FAT16
beginning at the start with 512MB size. Toggle the partition as boot
able. Create the dos fs with mkdosfs. ms-sys -s /dev/your_device to
create a mbr and syslinux /dev/your_device_partition1. Now you have to
mount the partition and copy the following files to the root directory
of your new partition. Note the ldlinux.sys already there, don't
overwrite it.



Files to copy:
from /isolinux/
message.txt
f2.txt
f3.txt
f4.txt
syslinux
syslinux.cfg
syslinux.com
initrd.img
from /kernels/baldar.de/ only bzImage.



The root directory of the partition should contain now 10 files
including ldlinux.sys. Now you have to edit syslinux.cfg. You can use
the working isolinux.cfg from the cd, copy it to syslinux.cfg and
change in the line starting with default /kernels/baldar.de/bzImage to
default bzImage, keep the rest as is. You are now ready to boot from
the stick, some Computer can only boot from a stick, if your power
off, plug in the stick, power on computer. There are many broken
implementations, but this approach should work with newer Computers.
Best working for me are external usb-drives with their own power and
newer chip sets. Not every USB-Stick is detected.
-----------------------------------------------------------------------
#isolinux.cfg
#
#change the ramdisk_size now 120MB
default bzImage rw initrd=initrd.img load_ramdisk=1 prompt_ramdisk=0 ramdisk_size=122880 root=/dev/ram0 SLACK_KERNEL=baldar.de
#APPEND rw hda=ide-scsi hdb=ide-scsi hdc=ide-scsi hdd=ide-scsi
#ONTIMEOUT linux auto
#ONERROR kernel options
#SERIAL port [[baudrate] flowcontrol]
SERIAL /dev/ttyS0 9600 0
#KBDMAP keymap
#DISPLAY filename
SAY Restore via CD/DVD and linux
#PROMPT flag_val
#F1 filename
prompt 1
timeout 1200
display message.txt
F1 message.txt
F2 f2.txt
F3 f3.txt
F4 f4.txt
-----------------------------------------------------------------------

Copy isolinux files from you slackware installation, not /isolinux/ as
in my example, copy your own kernel as bzImage to the root directory
and use you own initrd. Your kernel has to provide usb-mass storage
and scsi device support.

Btw. note to self, I should update my own bootmessages in message.txt
and f*.txt.

A working example is in my small cd image, I can provide more details.

have fun,cu Frank


--
"I never thought there could be anything worse than being all alone
in the night."
"But there is, being all alone in a crowd."
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 06:44 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com