[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Problem with flash drive



Ethan,

when you create a new partition table on the device, then the kernel needs to know about it. With a flash memory card, just unplug and re-plug it. You don't need to run fdisk first, since you copy an entire disk image, this comes with partition table and all.
Is your mounting read-only intended?

$ bunzip2  FreeDOS-1.1-USB-Boot.img.bz2

$ ls -l FreeDOS-1.1-USB-Boot.img
-rw-r----- 1 klaus klaus 32505856 Jun 21 08:38 FreeDOS-1.1-USB-Boot.img

$ dd if=FreeDOS-1.1-USB-Boot.img of=/dev/sdb
63488+0 records in
63488+0 records out
32505856 bytes (33 MB) copied, 5.38615 s, 6.0 MB/s
$ sudo fdisk -l /dev/sdb

Disk /dev/sdb: 2017 MB, 2017459712 bytes
64 heads, 32 sectors/track, 1923 cylinders, total 3940351 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00077d8f

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *          32       63487       31728    e  W95 FAT16 (LBA)

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

---------      DISCONNECTED DEVICE, THEN PLUGGED BACK IN
---------      GETS AUTOMATICALLY MOUNTED IN /MEDIA/$username/$disk-id


$ ls -l /media/klaus/FREEDOS1~1A/
total 111
-rwxr-xr-x 1 klaus klaus 66945 Jan 17  2012 command.com
-rw-r--r-- 1 klaus klaus 45344 Jan 17  2012 kernel.sys

$ cp test.txt /media/klaus/FREEDOS1~1A/

$ ls -l /media/klaus/FREEDOS1~1A/
total 112
-rwxr-xr-x 1 klaus klaus 66945 Jan 17  2012 command.com
-rw-r--r-- 1 klaus klaus 45344 Jan 17  2012 kernel.sys
-rw-r--r-- 1 klaus klaus    36 Jun 21 08:48 test.txt


On 21/06/13 05:29, Ethan Rosenberg, PhD wrote:
Ken -

Tried what you said, but I cannot make it work.

Here is what I did:

fdisk /dev/sdb

Command (m for help): d
Selected partition 1

Command (m for help):
Command (m for help): p

Disk /dev/sdb: 4051 MB, 4051697664 bytes
64 heads, 32 sectors/track, 3864 cylinders, total 7913472 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00077d8f

    Device Boot      Start         End      Blocks   Id  System

Command (m for help): n
Partition type:
    p   primary (0 primary, 0 extended, 4 free)
    e   extended
Select (default p):
Using default response p
Partition number (1-4, default 1):
Using default value 1
First sector (2048-7913471, default 2048): 0
Value out of range.
First sector (2048-7913471, default 2048): 1
Value out of range.
First sector (2048-7913471, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-7913471, default 7913471):
989184

Command (m for help): t
Selected partition 1
Hex code (type L to list codes): e
Changed system type of partition 1 to e (W95 FAT16 (LBA))

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or
resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)

dd if=/home/ethan/DOSutil/FreeDOS-1.1-USB-Boot.img of=/dev/sdb
63488+0 records in
63488+0 records out
32505856 bytes (33 MB) copied, 0.447414 s, 72.7 MB/s

rosenberg:/media# fdisk -l
Disk /dev/sdb: 4051 MB, 4051697664 bytes
64 heads, 32 sectors/track, 3864 cylinders, total 7913472 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00077d8f

    Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *          32       63487       31728    e  W95 FAT16 (LBA)

rosenberg:/media# mount
/dev/sdb1 on /media/bkup type vfat
(ro,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=utf8,shortname=mixed,errors=remount-ro)


rosenberg:/media# cd /media/bkup
rosenberg:/media/bkup# ls
64k of m.emo  conditio.n i     = (eq.ual  in a bat.ch    %lukb?.ree
ng used.in    pt to th.e d  sage.??P.AUS    tell you. if  tring].?.?/U
able to.the   ctive.?.Sea   es curre.nt   ings res.our    mand as.if
n if the. sp  racter)?.  $  s and di.rec    t enter.to    t]??  te.xt
ame?          D   Curr.ent  exists..the   in the e.nvi    me?
no para.met  rd outpu.t o  seems to. be    ters to.dis   tting.?I.f a
and for.tha   debug [o.N |  fied com.man  into fre.eDO    mes a fi.le/
not to e.xec  rectory.off    sets, o.r r    than sig.n)?  umber of. th
ariable..??/  DEBUG wi.tho  %f IN (-.--s  ions as.you    meters i.n a
nsize2]....]  rectory.sta      shows. ke    than the.?     while t.he
ariable.nam   director.y s         f.ree  irectory.nam     minimum.?
o?change. cu  reeCOM o.r o  sign to.the    ?  The '.*'   window t.owa
ar sign).?    ?DIRS?.emo         Fre.eDO   is remo.ved     minsize.2 s
?.ode        riables..??s  sion:?%s.?    the comm.and   within.the
ason: %u. (%  DOWN]??D.own  g1==stri.ng2  istory b.uff    mmand pr.omp
ommand [.arg  rnal com.man     Speci.fie     the con.ten  y out if. th
  assigns. th  drive an.d p  ge:?"pre.ss   istribut.ion    m, speci.fy
ontents.of    rogram.. Re    specify. as    the path. sp  ype veri.FY
ation an.d n  eater-th.an   he for c.omm  ?  label    n?
ORLEVEL.num   rrent ti.me   splay th.e v    thout a.par
ays the.Fre   ectory.?.Typ  hrinks a. UM  lays or.set    name2]??.Not
os comma.nd   r [/r] [./w]  ST filen.ame    tical Er.ror
   backsp.ace  edirect.the   h you wi.sh   le; by d.efa    n and li.nef
our file.s a  rsion an.d o  ST filen.ame    TIME fro.m b
ber spec.ifi  e [drive.:]p  ibutors..?      lename [.par    nded
to.the   out para.met  rwise?th.e c  [string]. to    time [/t.] [
cify a n.ew   eep the.sam   I code 2.7)?  line by.its    ne histo.ry?
plays or. se  ry [size.]??   system.whe    ting.?.f d
  colon.?      e execut.abl  ies a se.rie  ll debug. ou    n exit c.ode
play the. cu  ?.s a      t" and ".std    to that.fil
conditio.n i  e follow.ing  ilename1.] [  Loads a.pro    ?.ng
prompt t.he   sage "pa.cke  tch prog.ram    tring is. sp

Thanks for everything, but I am still stuck.

Ethan
=========
On 06/20/2013 07:22 PM Ethan Rosenberg, PhD wrote:
Dear list -

I am trying to copy FreeDOS to a flash drive.  I can't make it work.

This is what I have done -

Command (m for help): p

Disk /dev/sdb: 4051 MB, 4051697664 bytes
125 heads, 62 sectors/track, 1021 cylinders, total 7913472 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00077d8f

    Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048      989184      493568+   c  W95 FAT32 (LBA)
/dev/sdb2          989185     7913471     3462143+  83  Linux

Notice that sdb1 doesn't start at the beginning of the media, but rather
2048 sectors in.  If your FreeDOS image is really a boot image (as the
name of the file suggests), then you need to start the copy at the very
beginning of the media, i.e., sector 0.  So I would try:

dd if=/home/ethan/Downloads/FreeDOS-1.1-USB-Boot.img of=/dev/sdb




I then delete the DOS partition since it seems to be corrupted and add
regenerate the  FAT Partition, and write it out.

Make file system:

mkfs.vfat /dev/sdb1
mkfs.vfat 3.0.16 (01 Mar 2013)

No sense making a file system because 'dd' is going to overwrite it.



Check file system:

fsck.vfat /dev/sdb1
dosfsck 3.0.16, 01 Mar 2013, FAT32, LFN
/dev/sdb1: 0 files, 0/61661 clusters

Copy FreeDOS:

dd if=/home/ethan/Downloads/FreeDOS-1.1-USB-Boot.img of=/dev/sdb1
63488+0 records in
63488+0 records out
32505856 bytes (33 MB) copied, 1.30864 s, 24.8 MB/

Check Mount:

/dev/sdb1 on /media/bkup type vfat
(ro,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=utf8,shortname=mixed,errors=remount-ro)


After you do the 'dd' command I suggested above, then do

fdisk -l /dev/sdb

to see what partitions are listed.  There will likely be just one.  You
can add more later.  Best anyway to see what the 'dd' command leaves you.





Check Contents:

rosenberg:/media# ls -la bkup
ls: cannot access bkup/%f IN (-.--s: Input/output error
ls: cannot access bkup/in a bat.ch: Input/output error
ls: cannot access bkup/
   label: Input/output error
ls: cannot access bkup/ng used.in: Input/output error
ls: cannot access bkup/ colon.
: Input/output error
ls: cannot access bkup/ry [size.]

....

hth,
ken




--
Klaus


Reply to: