![]() This is why you have to remove the file /mnt/hdb/zero after that in order to regain the unused space. Try: # We don't wish to abort the whole script on an errorįor n in xrange(info. The command just copies zeros from the virtual File /dev/zero (infinite number of zeros) into /mnt/hdb/zero until the disk is full, or some other error occurs. Zeros = "\x00" * bsize # Create a block of zeros that size ![]() Zerodir = os.path.join(drive_path, 'ZerosDir') # Create a directory nameįilename_pattern = os.path.join(zerodir, 'Z%07d.000') # File name patternīsize = max(info.f_bsize, info.f_frsize) # Decide the block size You can adjust the blocksize and count as needed. You can copy a fixed number of bytes with dd: dd if/dev/zero ofzero-file bs1 count10000000000 This copies one byte 10000000000 times from /dev/zeroto zero-file. Info = os.statvfs(drive_path) # Get a the file system info. Try using /dev/zeroas a virtual input file that contains only zeros. ![]() For instance, Excel will strip leading zeros from numbers and. """ Fill a drive with zeros then delete them """ Excel may, however, make incorrect assumptions about the way data it imports should be formatted. I would suggest booting from a Linux USB key that gives read/write access to the drive that you wish to zero and using a python script, (most Linux installations include python), to do something like: import os lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS loop0 7:0 0 256M 0 loop /tmp/fs5f4RX1/mntpoint Because the size of the created image is 256M, the image will be created as fat16 by default when mkfs.vfat, and the maximum directory entry of fat16 is 512 ( will become fewer according to the length of the directory name ). Filling the disk with all zeros (This may take a while, as it is making every bit of data 0) : dd if/dev/zero of/dev/sdX bs1M replace X with the target.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |