module Getch::FileSystem::Clean

Public Class Methods

clean_hdd(disk) click to toggle source
# File lib/getch/filesystem/clean.rb, line 4
def self.clean_hdd(disk)
  return if ! disk
  raise ArgumentError, "Disk #{disk} is no found." if ! File.exist? "/dev/#{disk}"
  puts
  print "Cleaning data on #{disk}, can be long, avoid this on Flash Memory (SSD,USB,...) ? [y,N] "
  case gets.chomp
  when /^y|^Y/
    bloc=`blockdev --getbsz /dev/#{disk}`.chomp
    Helpers::sys("dd if=/dev/urandom of=/dev/#{disk} bs=#{bloc} status=progress")
  else
    return
  end
end
clean_struct(disk) click to toggle source
# File lib/getch/filesystem/clean.rb, line 18
def self.clean_struct(disk)
  return if ! disk
  raise ArgumentError, "Disk #{disk} is no found." if ! File.exist? "/dev/#{disk}"
  Helpers::sys("sgdisk -Z /dev/#{disk}")
  Helpers::sys("wipefs -a /dev/#{disk}")
end
external_disk(root_disk, *disks) click to toggle source
# File lib/getch/filesystem/clean.rb, line 36
def self.external_disk(root_disk, *disks)
  disks.each { |d|
    unless d && d != "" && d != nil && d == root_disk
      hdd(d)
    end
  }
end
hdd(*disks) click to toggle source
# File lib/getch/filesystem/clean.rb, line 25
def self.hdd(*disks)
  disks.each { |d|
    clean_struct(d)
    clean_hdd(d)
  }
end
old_vg(disk, vg) click to toggle source
# File lib/getch/filesystem/clean.rb, line 44
def self.old_vg(disk, vg)
  oldvg = `vgdisplay | grep #{vg}`.chomp
  Helpers::sys("vgremove -f #{vg}") if oldvg != ''
  Helpers::sys("pvremove -f #{disk}") if oldvg != '' and File.exist? disk
end
old_zpool() click to toggle source
# File lib/getch/filesystem/clean.rb, line 50
def self.old_zpool
  oldzpool = `zpool status | grep pool:`.gsub(/pool: /, '').delete(' ').split("\n")
  if oldzpool[0] != "" and $?.success?
    oldzpool.each { |p| Helpers::sys("zpool destroy #{p}") if p }
  end
end
sdd() click to toggle source

See wiki.archlinux.org/index.php/Solid_state_drive/Memory_cell_clearing for SSD

# File lib/getch/filesystem/clean.rb, line 33
def self.sdd
end