Class: Getch::Disk
- Inherits:
-
Object
- Object
- Getch::Disk
- Defined in:
- lib/getch/disk.rb
Instance Method Summary collapse
- #cleaning ⇒ Object
- #efi? ⇒ Boolean
- #format ⇒ Object
-
#initialize(disk, fs) ⇒ Disk
constructor
A new instance of Disk.
- #partition ⇒ Object
Constructor Details
Instance Method Details
#cleaning ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/getch/disk.rb', line 14 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 |
#efi? ⇒ Boolean
9 10 11 |
# File 'lib/getch/disk.rb', line 9 def efi? Dir.exist? '/sys/firmware/efi/efivars' end |
#format ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/getch/disk.rb', line 40 def format return if STATES[:format] puts "Format #{@hdd} with #{@fs}" if efi? then system("mkfs.vfat -F32 /dev/#{@hdd}1") system("mkswap /dev/#{@hdd}2") system("swapon /dev/#{@hdd}2") system("mkfs.ext4 /dev/#{@hdd}3") system("mkfs.ext4 /dev/#{@hdd}4") else system("mkswap /dev/#{@hdd}2") system("swapon /dev/#{@hdd}2") system("mkfs.ext4 /dev/#{@hdd}3") system("mkfs.ext4 /dev/#{@hdd}4") end @state.format end |
#partition ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/getch/disk.rb', line 26 def partition return if STATES[:partition] system("wipefs -a /dev/#{@hdd}") system("sgdisk --zap-all /dev/#{@hdd}") if 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 |