当前位置: 首页>>技术教程>>正文


清空SSD的推荐方法是什么?

, ,

问题描述

我刚刚收到我的新SSD,因为旧的SSD死了。这款Intel 320 SSD支持TRIM。出于测试目的,我的经销商把Windows放在上面,但我想摆脱它并在上面安装Kubuntu。

它不一定是”secure wipe”,我只需要以最健康的方式清空磁盘。我相信dd if=/dev/zero of=/dev/sda只用零填充块,从而进行另一次写入(如果我错了,请纠正我)。

我已经看到了答案How to enable TRIM,但看起来它适合清除空块而不是擦除磁盘。

hdparm似乎是执行它的程序,但我不确定它是否清除磁盘或清除空块。从其手册页:

  --trim-sector-ranges           For  Solid State Drives (SSDs).  EXCEPTIONALLY DANGEROUS. DO NOT           USE THIS OPTION!!  Tells the drive firmware to discard  unneeded           data  sectors,  destroying  any  data that may have been present           within them.  This makes those sectors available  for  immediate           use  by  the firmware's garbage collection mechanism, to improve           scheduling for wear-leveling of the flash  media.   This  option           expects  one  or  more  sector range pairs immediately after the           option: an LBA starting address, a colon, and  a  sector  count,           with no intervening spaces.  EXCEPTIONALLY DANGEROUS. DO NOT USE           THIS OPTION!! 
          E.g.  hdparm --trim-sector-ranges 1000:4 7894:16 /dev/sdz

如何使用TRIM将所有块显示为空?

最佳解决办法

ATA安全擦除

您应该使用驱动器的security erase功能。

  1. 确保未冻结驱动器安全性。如果是,则暂停和恢复计算机可能会有所帮助。

    $ sudo hdparm -I /dev/sdX | grep frozen
           not     frozen 
    

    (已过滤)命令输出表示此驱动器“未冻结”,您可以继续。

  2. 设置用户密码(此密码也被清除,确切的选择无关紧要)。

    sudo hdparm --user-master u --security-set-pass Eins /dev/sdX
    
  3. 发出ATA安全擦除命令

    sudo hdparm --user-master u --security-erase Eins /dev/sdX
    

注意:

  • /dev/sdX是SSD作为要擦除的块设备。

  • Eins是此示例中选择的密码。

有关完整说明(包括故障排除),请参阅Linux内核wiki中的ATA安全擦除文章。

次佳解决办法

util-linux 2.23提供blkdiscard,无需secure-wiping即可丢弃数据。我测试过:适用于SATA和mmcblk,但不适用于USB。

摘自blkdiscard(8)手册页:

NAME

blkdiscard – discard sectors on a device

SYNOPSIS

blkdiscard [-o offset] [-l length] [-s] [-v] device 

DESCRIPTION

blkdiscard is used to discard device sectors. This is useful for solid-state drivers (SSDs) and thinly-provisioned storage. Unlike fstrim(8) this command is used directly on the block device.

By default, blkdiscard will discard all blocks on the device. Options may be used to modify this behavior based on range or size, as explained below.

The device argument is the pathname of the block device.

WARNING: All data in the discarded region on the device will be lost!

从Ubuntu 15.04和OpenSUSE 13.1开始就是命令(是的,OpenSUSE比Ubuntu提前2年)。

第三种解决办法

如果您不需要安全擦除,为什么不使用“使用整个磁盘”和相当于’quick format’的选项安装kubuntu(现在不记得确切的术语)

这样你就放弃了文件分配表,并且有效地清空了驱动器以进行覆盖。你实际上并不需要清空它。

参考资料

本文由Ubuntu问答整理, 博文地址: https://ubuntuqa.com/article/1604.html,未经允许,请勿转载。