zeroing out part of an SDcard

Robert P. J. Day rpjday at crashcourse.ca
Thu Aug 21 13:46:51 UTC 2014


On Thu, 21 Aug 2014, Robert Moskowitz wrote:

>
> On 08/21/2014 09:07 AM, Robert P. J. Day wrote:
> > On Thu, 21 Aug 2014, Robert Moskowitz wrote:
> >
> > > More on my compressing images from SDcards.
> > >
> > > I only need the boot info and 1st partition, so I remove the other
> > > partitions,
> > > but of course there is still 1s out there so it will not compress
> > > efficiently.
> > > I want to zero out the end of the card so first I use fdisk:
> > >
> > > # fdisk -l /dev/sdb
> > >
> > > Disk /dev/sdb: 7.4 GiB, 7969177600 bytes, 15564800 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
> > > Disklabel type: dos
> > > Disk identifier: 0x0009e2ad
> > >
> > > Device Boot Start End Blocks Id System
> > > /dev/sdb1 8192 1007615 499712 83 Linux
> > >
> > > Then dd:
> > >
> > > # dd if=/dev/zero of=/dev/sdb bs=1M seek=1007620
> > > dd: ‘/dev/sdb’: cannot seek: Invalid argument
> > > 0+0 records in
> > > 0+0 records out
> > > 0 bytes (0 B) copied, 0.000652852 s, 0.0 kB/s
> > >
> > > ======================
> > >
> > > seems you cannot seek on an SDcard. How do I do this? Since the change in
> > > partition 1 is trivial, if I have to start again from an SDcard with all 3
> > > paritions, I can do that...
> >    it seems like you're trying to seek more than a terabyte into that
> > card.
>
> Well, man says about seek:
>
>        seek=N skip N obs-sized blocks at start of output
>
> and obs defaults to 512 bytes, and I *THOUGHT* fdisk was reporting # 512
> blocks, not bytes.

  if memory serves, using "bs=" overrides both ibs= and obs= ...
here's from the man page:

       bs=BYTES
              read and write up to BYTES bytes at a time

notice that says "read *and* write", so i'm simply assuming it is the
value used for both ibs and obs.

rday

-- 

========================================================================
Robert P. J. Day                                 Ottawa, Ontario, CANADA
                        http://crashcourse.ca

Twitter:                                       http://twitter.com/rpjday
LinkedIn:                               http://ca.linkedin.com/in/rpjday
========================================================================


More information about the users mailing list