lib/getch/filesystem/ext4/partition.rb in getch-0.1.0 vs lib/getch/filesystem/ext4/partition.rb in getch-0.1.1

- old
+ new

@@ -3,72 +3,49 @@ module Ext4 class Partition < Getch::FileSystem::Ext4::Device def initialize super @state = Getch::States.new() + @clean = Getch::FileSystem::Clean + @partition = Getch::FileSystem::Partition.new run_partition end def run_partition return if STATES[:partition ] - clear_struct - cleaning + @clean.struct(@disk, @cache_disk, @home_disk) + @clean.hdd(@disk, @cache_disk, @home_disk) if Helpers::efi? partition_efi else partition_bios end @state.partition end private - def clear_struct - exec("sgdisk -Z /dev/#{@disk}") - exec("wipefs -a /dev/#{@disk}") - end - - def cleaning - puts - print "Cleaning data on #{@disk}, can be long, avoid this on Flash Memory (SSD,USB,...) ? (n,y) " - case gets.chomp - when /^y|^Y/ - bloc=`blockdev --getbsz /dev/#{@disk}`.chomp - exec("dd if=/dev/urandom of=/dev/#{@disk} bs=#{bloc} status=progress") - else - return - end - end - # Follow https://wiki.archlinux.org/index.php/Partitioning def partition_efi - # /boot/efi - EFI system partition - 260MB - # / - Root - # swap - Linux Swap - size of the ram - # /home - Home - mem=`awk '/MemTotal/ {print $2}' /proc/meminfo`.chomp + 'K' - - exec("sgdisk -n1:1M:+260M -t1:EF00 /dev/#{@disk}") - exec("sgdisk -n2:0:+15G -t2:8304 /dev/#{@disk}") - exec("sgdisk -n3:0:+#{mem} -t3:8200 /dev/#{@disk}") - exec("sgdisk -n4:0:0 -t4:8302 /dev/#{@disk}") if @dev_home + # /efi - EFI system partition - 260MB + # swap - Linux Swap - size of the ram + # / - Root + # /home - Home + @partition.efi(@dev_esp) + @partition.swap(@dev_swap) + @partition.root(@dev_root, "8304") + @partition.home(@dev_home, "8302") if @dev_home end def partition_bios # None - Bios Boot Partition - 1MiB # / - Root # swap - Linux Swap - size of the ram # /home - Home - mem=`awk '/MemTotal/ {print $2}' /proc/meminfo`.chomp + 'K' - - exec("sgdisk -n1:1MiB:+1MiB -t1:EF02 /dev/#{@disk}") - exec("sgdisk -n2:0:+15G -t2:8304 /dev/#{@disk}") - exec("sgdisk -n3:0:+#{mem} -t3:8200 /dev/#{@disk}") - exec("sgdisk -n4:0:0 -t4:8302 /dev/#{@disk}") if @dev_home - end - - def exec(cmd) - Getch::Command.new(cmd).run! + @partition.gpt(@dev_gpt) + @partition.swap(@dev_swap) + @partition.root(@dev_root, "8304") + @partition.home(@dev_home, "8302") if @dev_home end end end end end