Re: Low Level read/Write code for USB storage device

Eduardo Gutierrez de O <[email protected]> Fri, 14 Dec 2018 20:19:29 +0100
Newsgroups gmane.comp.lang.realbasic.user
Message-ID <[email protected]>
--Apple-Mail=_ABA20C9D-AB0C-42DC-8F4D-D5CCABCA540D
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
	charset=utf-8

In mac or linux I would use dd or pv to copy the full device, which =
would create a perfect clone including partitions.

On Windows there might be something similar? (assuming you can't use =
either of the above compiled for Windows for licensing reasons)

> On 14 Dec 2018, at 19:21, Jim Wagner <[email protected]> wrote:
>=20
> I think that I would use command-line utilities to detect the =
partitions on the source stick, then reformat the destination stick with =
the same partition structure. Of course, there is a strong chance that =
how  you do this will depend on the OS of the host machine.
>=20
> Jim
>=20
> James Wagner
> Oregon Research Electronics
> http://www.orelectronics.net <http://www.orelectronics.net/>
>=20
>=20
>=20
>=20
>> On Dec 14, 2018, at 9:54 AM, Jean-Luc Arnaud =
<jean-luc-E/[email protected] <mailto:jean-luc-E/[email protected]>> wrote:
>>=20
>> Many thanks for replying, Jim.
>>=20
>> Your information is very interesting and relevant. However, I "need" =
to clone USB stick as it's the only way I can think to, to duplicate =
multi-partition sticks.
>>=20
>> Unless you have another idea? If so, I'm highly interested!
>>=20
>> Have a nice WE
>> Jean-Luc Arnaud
>>=20
>> Le 14/12/2018 =C3=A0 17:04, Jim Wagner a =C3=A9crit :
>>> Hello, Jean-Luc
>>>=20
>>> I do not think that you should try to =E2=80=9Cclone=E2=80=9D a USB =
stick at =E2=80=9Clow level=E2=80=9D, that is, at the sector or block =
level. That is because of a process used on solid-state memories (such =
as USB stick); this is called =E2=80=9Cwear leveling=E2=80=9D. For =
example, if you change a document on such memory, it will actually move =
it to a new place so that the different parts of the memory all have a =
chance to be written and no  part gets written too many times.
>>>=20
>>> Certainly, you can reconstruct partitions and such, but you need to =
do it at a file-system level. Perhaps, this is what you are calling =
=E2=80=9Clow level=E2=80=9D?
>>>=20
>>> Jim
>>>=20
>>> James Wagner
>>> Oregon Research Electronics
>>> http://www.orelectronics.net <http://www.orelectronics.net/>
>>>=20
>>>=20
>>>=20
>>>=20
>>>> On Dec 14, 2018, at 1:56 AM, Jean-Luc Arnaud =
<jean-luc-E/[email protected] <mailto:jean-luc-E/[email protected]>> wrote:
>>>>=20
>>>> Hi all,
>>>>=20
>>>> I plan to code for a kind of "USB Stick cloner" running on Windows, =
that is to make an
>>>> image of the entire content of a USB Storage device, in order to =
copy it
>>>> to another USB stick.
>>>>=20
>>>> I'd like to read low level information about partition table,
>>>> catalog, etc.. and of course, to copy this information to another =
stick.
>>>>=20
>>>> I didn't find nothing useful in the Xojo forum nor in MBS samples.
>>>>=20
>>>> After a lot of searches on Internet (information like APIs, Command =
Line tools, shared code, ...), I'm now interested in an open-source =
utility, Clonezilla, which does all I need.
>>>>=20
>>>> Does someone know and/or use this utility?
>>>> My goal is to adapt its source for my own needs, including it in a =
Xojo app.
>>>>=20
>>>> Thanks for any help.
>>>>=20
>>>> --=20
>>>> Jean-Luc Arnaud
>>>>=20
>>>=20
>=20


--Apple-Mail=_ABA20C9D-AB0C-42DC-8F4D-D5CCABCA540D
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html;
	charset=utf-8

<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html =
charset=3Dutf-8"></head><body style=3D"word-wrap: break-word; =
-webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" =
class=3D"">In mac or linux I would use dd or pv to copy the full device, =
which would create a perfect clone including partitions.<div =
class=3D""><br class=3D""></div><div class=3D"">On Windows there might =
be something similar? (assuming you can't use either of the above =
compiled for Windows for licensing reasons)<br class=3D""><div =
class=3D""><br class=3D""><div><blockquote type=3D"cite" class=3D""><div =
class=3D"">On 14 Dec 2018, at 19:21, Jim Wagner &lt;<a =
href=3D"mailto:[email protected]" =
class=3D"">[email protected]</a>&gt; wrote:</div><br =
class=3D"Apple-interchange-newline"><div class=3D""><meta =
http-equiv=3D"Content-Type" content=3D"text/html charset=3Dutf-8" =
class=3D""><div style=3D"word-wrap: break-word; -webkit-nbsp-mode: =
space; -webkit-line-break: after-white-space;" class=3D"">I think that I =
would use command-line utilities to detect the partitions on the source =
stick, then reformat the destination stick with the same partition =
structure. Of course, there is a strong chance that how &nbsp;you do =
this will depend on the OS of the host machine.<div class=3D""><br =
class=3D""></div><div class=3D"">Jim</div><div class=3D""><br =
class=3D""></div><div class=3D""><div class=3D"">
<span class=3D"Apple-style-span" style=3D"border-collapse: separate; =
font-family: Helvetica; font-style: normal; font-variant-ligatures: =
normal; font-variant-position: normal; font-variant-caps: normal; =
font-variant-numeric: normal; font-variant-alternates: normal; =
font-variant-east-asian: normal; font-weight: normal; letter-spacing: =
normal; line-height: normal; orphans: 2; text-align: -webkit-auto; =
text-indent: 0px; text-transform: none; white-space: normal; widows: 2; =
word-spacing: 0px; border-spacing: 0px; =
-webkit-text-decorations-in-effect: none; -webkit-text-stroke-width: =
0px;"><div style=3D"word-wrap: break-word; -webkit-nbsp-mode: space; =
-webkit-line-break: after-white-space;" class=3D""><div class=3D"">James =
Wagner</div><div class=3D"">Oregon Research Electronics</div><div =
class=3D""><a href=3D"http://www.orelectronics.net/" =
class=3D"">http://www.orelectronics.net</a></div><div class=3D""><br =
class=3D""></div></div></span><br class=3D"Apple-interchange-newline"><br =
class=3D"Apple-interchange-newline">
</div>
<br class=3D""><div class=3D""><blockquote type=3D"cite" class=3D""><div =
class=3D"">On Dec 14, 2018, at 9:54 AM, Jean-Luc Arnaud &lt;<a =
href=3D"mailto:jean-luc-E/[email protected]" =
class=3D"">jean-luc-E/[email protected]</a>&gt; wrote:</div><br =
class=3D"Apple-interchange-newline"><div class=3D"">
 =20
    <meta http-equiv=3D"Content-Type" content=3D"text/html; =
charset=3DUTF-8" class=3D"">
 =20
  <div text=3D"#000000" bgcolor=3D"#FFFFFF" class=3D""><p class=3D"">Many =
thanks for replying, Jim.</p><p class=3D"">Your information is very =
interesting and relevant. However, I
      "need" to clone USB stick as it's the only way I can think to, to
      duplicate multi-partition sticks.</p><p class=3D"">Unless you have =
another idea? If so, I'm highly interested!</p><p class=3D"">Have a nice =
WE<br class=3D"">
    </p>
    <pre class=3D"moz-signature" cols=3D"72">Jean-Luc Arnaud

</pre>
    <div class=3D"moz-cite-prefix">Le 14/12/2018 =C3=A0 17:04, Jim =
Wagner a
      =C3=A9crit&nbsp;:<br class=3D"">
    </div>
    <blockquote type=3D"cite" =
cite=3D"mid:932C2719-7B90-4DED-B38C-3447CAC45578-Wuw85uim5zDR7s880joybQ@public.gmane.org" class=3D"">
      <meta http-equiv=3D"Content-Type" content=3D"text/html; =
charset=3DUTF-8" class=3D"">
      Hello, Jean-Luc
      <div class=3D""><br class=3D"">
      </div>
      <div class=3D"">I do not think that you should try to =E2=80=9Cclone=
=E2=80=9D a USB
        stick at =E2=80=9Clow level=E2=80=9D, that is, at the sector or =
block level.
        That is because of a process used on solid-state memories (such
        as USB stick); this is called =E2=80=9Cwear leveling=E2=80=9D. =
For example, if
        you change a document on such memory, it will actually move it
        to a new place so that the different parts of the memory all
        have a chance to be written and no &nbsp;part gets written too =
many
        times.</div>
      <div class=3D""><br class=3D"">
      </div>
      <div class=3D"">Certainly, you can reconstruct partitions and =
such,
        but you need to do it at a file-system level. Perhaps, this is
        what you are calling =E2=80=9Clow level=E2=80=9D?</div>
      <div class=3D""><br class=3D"">
      </div>
      <div class=3D"">Jim</div>
      <div class=3D""><br class=3D"">
        <div class=3D"">
          <span class=3D"Apple-style-span" style=3D"border-collapse: =
separate; font-family: Helvetica; font-style: normal; =
font-variant-ligatures: normal; font-variant-position: normal; =
font-variant-caps: normal; font-variant-numeric: normal; =
font-variant-alternates: normal; font-variant-east-asian: normal; =
font-weight: normal; letter-spacing: normal; line-height: normal; =
orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: =
none; white-space: normal; widows: 2; word-spacing: 0px; border-spacing: =
0px; -webkit-text-decorations-in-effect: none; =
-webkit-text-stroke-width: 0px;">
            <div style=3D"word-wrap: break-word; -webkit-nbsp-mode: =
space;
              -webkit-line-break: after-white-space;" class=3D"">
              <div class=3D"">James Wagner</div>
              <div class=3D"">Oregon Research Electronics</div>
              <div class=3D""><a href=3D"http://www.orelectronics.net/" =
class=3D"" moz-do-not-send=3D"true">http://www.orelectronics.net</a></div>=

              <div class=3D""><br class=3D"">
              </div>
            </div>
          </span><br class=3D"Apple-interchange-newline">
          <br class=3D"Apple-interchange-newline">
        </div>
        <br class=3D"">
        <div class=3D"">
          <blockquote type=3D"cite" class=3D"">
            <div class=3D"">On Dec 14, 2018, at 1:56 AM, Jean-Luc Arnaud
              &lt;<a href=3D"mailto:jean-luc-E/[email protected]" class=3D"" =
moz-do-not-send=3D"true">jean-luc-E/[email protected]</a>&gt;
              wrote:</div>
            <br class=3D"Apple-interchange-newline">
            <div class=3D"">
              <div class=3D"">Hi all,<br class=3D"">
                <br class=3D"">
                I plan to code for a kind of "USB Stick cloner" running
                on Windows, that is to make an<br class=3D"">
                image of the entire content of a USB Storage device, in
                order to copy it<br class=3D"">
                to another USB stick.<br class=3D"">
                <br class=3D"">
                I'd like to read low level information about partition
                table,<br class=3D"">
                catalog, etc.. and of course, to copy this information
                to another stick.<br class=3D"">
                <br class=3D"">
                I didn't find nothing useful in the Xojo forum nor in
                MBS samples.<br class=3D"">
                <br class=3D"">
                After a lot of searches on Internet (information like
                APIs, Command Line tools, shared code, ...), I'm now
                interested in an open-source utility, Clonezilla, which
                does all I need.<br class=3D"">
                <br class=3D"">
                Does someone know and/or use this utility?<br class=3D"">
                My goal is to adapt its source for my own needs,
                including it in a Xojo app.<br class=3D"">
                <br class=3D"">
                Thanks for any help.<br class=3D"">
                <br class=3D"">
                -- <br class=3D"">
                Jean-Luc Arnaud<br class=3D"">
                <br class=3D"">
              </div>
            </div>
          </blockquote>
        </div>
        <br class=3D"">
      </div>
    </blockquote>
  </div>

</div></blockquote></div><br =
class=3D""></div></div></div></blockquote></div><br =
class=3D""></div></div></body></html>=

--Apple-Mail=_ABA20C9D-AB0C-42DC-8F4D-D5CCABCA540D--