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

Re: Problem with flash drive - SUCCESS!!!!!!!!!!!!!!!!!



n 06/22/2013 11:56 PM Ethan Rosenberg, PhD wrote:
On 06/21/2013 04:00 AM, Klaus wrote:
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 -

WONDERFUL!!  IT WORKS!!!!!

rosenberg:/media/bkup# ls /media/usbdrive
command.com  kernel.sys

rosenberg:/media/usbdrive# mkdir bios
rosenberg:/media/usbdrive# ls -l
total 112
drwxr-xr-x 2 root root  1024 Jun 22 23:15 bios
-rwxr-xr-x 1 root root 66945 Jan 17  2012 command.com
-rwxr-xr-x 1 root root 45344 Jan 17  2012 kernel.sys

rosenberg:/media/bkup# fdisk -l /dev/sdc

Disk /dev/sdc: 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/sdc1   *          32       63487       31728    e  W95 FAT16 (LBA)

I now add a Linux partition... then..

rosenberg:/media/usbdrive# fdisk -l /dev/sdc

Disk /dev/sdc: 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/sdc1   *          32       63487       31728    e  W95 FAT16 (LBA)
/dev/sdc2           63488     7913471     3924992   83  Linux

Now create file system ....

/dev/sdc2           63488     7913471     3924992   83  Linux
rosenberg:/media/usbdrive# mkfs -t ext2 /dev/sdc2
mke2fs 1.42.5 (29-Jul-2012)
Could not stat /dev/sdc2 --- No such file or directory

???????

What did I do wrong??

Difficult to say just from the output provided above. And as with life in general, there are just a few ways to do something correctly, but dozen of ways to failure. :) It's also impossible for me to say what state your linux box and your usb stick are in currently. Oftentimes it's easier just to start over than to try to find the problem(s). If you decide to start afresh, be sure to reboot your linux box to purge any cruft in the filesystem. I would also comment out any automount directives from /etc/fstab prior to rebooting. You can uncomment them back in later if you wish. Something there might have mounted the stick read-only. Then, if you mounted (or automount mounted) the stick but then neither you nor it unmounted it, you could see the behavior you're seeing. Unlike Windows, and contrary to what someone else on the list wrote to you, in linux whenever a device is mounted, it should be unmounted prior to physically disconnecting it. See 'man umount'.

You should now have all the info you need to successfully accomplish what's required. Good luck to you. Hope to hear of your success.


Regards,
ken


TIA

Ethan

After setting up the DOS partition, I also need a Linux partition....so....

=====================
Ken and all that helped -

Rebooted.  Then....

mount
<snip>/dev/sdb1 on /media/bkup type vfat etc....

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)
/dev/sdb2           63488     7913471     3924992   83  Linux

rosenberg:/home/ethan# ls -la /dev/sdb1
brw-rw---T 1 root floppy 8, 17 Jun 23 09:37 /dev/sdb1
rosenberg:/home/ethan# ls -la /dev/sdb2
brw-rw---T 1 root floppy 8, 18 Jun 23 09:37 /dev/sdb2

OK, everything seems to be there....

rosenberg:/home/ethan# mkfs -t ext2 /dev/sdb2
mke2fs 1.42.5 (29-Jul-2012)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
245760 inodes, 981248 blocks
49062 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=1006632960
30 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
	32768, 98304, 163840, 229376, 294912, 819200, 884736

Allocating group tables: done
Writing inode tables: done
Writing superblocks and filesystem accounting information: done

YIPEEEEEE

I think what happened before is that the system identified the USB stick as /dev/sdc and it confused the system.

Ethan










Reply to: