Re: erasing a disk

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



At Mon, 14 Sep 2020 13:14:44 -0700 CentOS mailing list <centos@xxxxxxxxxx> wrote:

> 
> Folks
> 
> I've encountered situations where I want to reuse a hard-drive.  I do 
> not want to preserve anything on the drive, and I'm not concerned 
> about 'securely erasing' old content.  I just want to be able to 
> define it as an Physical Volume (in a logical volume set), or make it 
> a ZFS disk, or sometimes make it a simple EXT3, ExFAT or NTFS 
> disk.  However, old 'signatures' get in the way and Linux sometimes 
> refuses to let me proceed.  I know that a fool-proof solution is to 
> use the "dd if=/dev/zero bs=32768 oflag=direct" on the disk, but when 
> we're talking USB-connected hard drives of 8 TB, that's an operation 
> that can take days.
> 
> The disk in question might even have been corrupted.  This would make 
> using 'zpool destroy' to clear out a ZFS disk, or
> 
> I've tried erasing the first megabyte of the disk, but there are ZFS 
> or LVM structures that get in the way.  So, does anyone have an 
> efficient way to erase structures from a disk such that it can be reused?
> 
> Something like
>    -erase first N blocks (block defined as 4096)
>    - Erase <number> blocks starting at block <number>
>    - erase last <number> blocks

Use dd in a script:

#!/bin/bash
# erase N 4K blocks starting at M
# (M=0 means from the start of the disk)
# usage: $0 start4Kblock numberof4Kblocks drive
M = $1
N = $2
rawdisk = $3
dd if=/dev/zero bs=4096 oflag=direct count=$N seek=$M of=$rawdisk

> At least such an algorithm would be quicker than erasing 8 TB of data.
> 
> David
> 
> _______________________________________________
> CentOS mailing list
> CentOS@xxxxxxxxxx
> https://lists.centos.org/mailman/listinfo/centos
> 
>                                                                                                        
> 

-- 
Robert Heller             -- Cell: 413-658-7953 GV: 978-633-5364
Deepwoods Software        -- Custom Software Services
http://www.deepsoft.com/  -- Linux Administration Services
heller@xxxxxxxxxxxx       -- Webhosting Services
                                                                                                
_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
https://lists.centos.org/mailman/listinfo/centos



[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]


  Powered by Linux