Class: Getch::FileSystem::Lvm::Encrypt::Void

Inherits:
Device
  • Object
show all
Includes:
Helpers::Void
Defined in:
lib/getch/filesystem/ext4/hybrid/void.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helpers::Void

#chroot, #command_output, #line_fstab, #s_uuid

Methods inherited from Device

#boot, #efi, #gpt, #home, #initialize, #root, #swap, #zcache, #zlog

Constructor Details

This class inherits a constructor from Getch::Device

Instance Attribute Details

#boot_diskObject (readonly)

Returns the value of attribute boot_disk.



10
11
12
# File 'lib/getch/filesystem/ext4/hybrid/void.rb', line 10

def boot_disk
  @boot_disk
end

Instance Method Details

#add_key(name, dev) ⇒ Object

Key need to be added in dracut.conf.d and crypttab



19
20
21
22
23
24
25
# File 'lib/getch/filesystem/ext4/hybrid/void.rb', line 19

def add_key(name, dev)
  command "dd bs=1 count=64 if=/dev/urandom of=/boot/#{name}"
  puts " => Creating a key for #{dev}, password required:"
  chroot "cryptsetup luksAddKey #{dev} /boot/#{name}"
  command "chmod 000 /boot/#{name}"
  #command "chmod -R g-rwx,o-rwx /boot"
end

#create_keyObject

Create key to avoid enter password twice



13
14
15
16
# File 'lib/getch/filesystem/ext4/hybrid/void.rb', line 13

def create_key
  add_key('volume.key', @dev_root)
  add_key('home.key', @dev_home) if @home_disk
end

#crypttabObject



27
28
29
30
31
32
33
# File 'lib/getch/filesystem/ext4/hybrid/void.rb', line 27

def crypttab
  conf = "#{MOUNTPOINT}/etc/crypttab"
  File.write(conf, "\n", mode: 'w', chmod: 0644)
  add_line(conf, "cryptswap #{@lv_swap} /dev/urandom swap,discard,cipher=aes-xts-plain64:sha256,size=512")
  line_crypttab(@vg, @dev_root, '/boot/volume.key', 'luks')
  line_crypttab("crypthome", @dev_home, "/boot/home.key", "luks") if @home_disk
end

#finishObject



35
36
37
38
# File 'lib/getch/filesystem/ext4/hybrid/void.rb', line 35

def finish
  puts '+ Enter in your system: chroot /mnt /bin/bash'
  puts '+ Reboot with: shutdown -r now'
end