Re: zeroing out part of an SDcard

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

 



On Aug 21, 2014, at 6:51 AM, Robert Moskowitz <rgm@xxxxxxxxxxxxxxx> 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

These 487MB aren't zero'd, so whatever is reported as free space by the file system will have stale data on its sectors. Mount sdb1 and use fstrim -v <mountpoint> and see if the command is accepted.

> 
> Then dd:
> 
> # dd if=/dev/zero of=/dev/sdb bs=1M seek=1007620

It's kinder to your sdcard to create a 2nd partition for the remaining space and trim it. This can be done with either mkfs.btrfs or mkfs.ext4, if the kernel detects it's solid state then both commands issue trim for all of those blocks, and then creates a file system. I'd use btrfs only because it writes out far less metadata.

However, quite a few sdcards don't respond to trim. And if they do, some have non-deterministic read of 'erased/trimmed' pages, in which case even though they're marked as erased, they can still return old data or garbage. And in that case unfortunately zeroing is the only way out.


Chris Murphy
-- 
users mailing list
users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Fedora Code of Conduct: http://fedoraproject.org/code-of-conduct
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
Have a question? Ask away: http://ask.fedoraproject.org




[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [EPEL Devel]     [Fedora Magazine]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Desktop]     [Fedora Fonts]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Fedora Sparc]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux