Class: Getch::Disk
- Inherits:
-
Object
- Object
- Getch::Disk
- Defined in:
- lib/getch/disk.rb
Instance Method Summary collapse
- #cleaning ⇒ Object
- #format ⇒ Object
-
#initialize(disk, fs) ⇒ Disk
constructor
A new instance of Disk.
- #partition ⇒ Object
Constructor Details
Instance Method Details
#cleaning ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/getch/disk.rb', line 10 def cleaning return if STATES[:partition ] puts print "Cleaning data on #{@hdd}, can be long, avoid this on Flash Memory (SSD,USB,...) ? (n,y) " case gets.chomp when /^y|^Y/ system("dd if=/dev/urandom of=/dev/#{@hdd} bs=4M status=progress") else return end end |
#format ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/getch/disk.rb', line 36 def format return if STATES[:format] puts "Format #{@hdd} with #{@fs}" if Helpers::efi? then system("mkfs.fat -F32 /dev/#{@hdd}1") system("mkswap /dev/#{@hdd}2") system("mkfs.ext4 /dev/#{@hdd}3") system("mkfs.ext4 /dev/#{@hdd}4") else system("mkswap /dev/#{@hdd}2") system("mkfs.ext4 /dev/#{@hdd}3") system("mkfs.ext4 /dev/#{@hdd}4") end @state.format end |
#partition ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/getch/disk.rb', line 22 def partition return if STATES[:partition] system("sgdisk --zap-all /dev/#{@hdd}") system("wipefs -a /dev/#{@hdd}") if Helpers::efi? then puts "Partition disk #{@hdd} for an EFI system" partition_efi else puts "Partition disk #{@hdd} for a Bios system" partition_bios end @state.partition end |