Sha256: c4ad6466ddb053ff86a2abbfe5cfe17692f3ffc2f63f3fb887f7a560ba965783

Contents?: true

Size: 1.06 KB

Versions: 1

Compression:

Stored size: 1.06 KB

Contents

module Getch
  module FileSystem
    module Zfs
      class Mount < Device
        def initialize
          super
          @mount = Getch::FileSystem::Mount.new
          @state = Getch::States.new
          @log = Getch::Log.new
        end

        def run
          return if STATES[:mount]
          exec("zpool export -a")
          exec("rm -rf #{MOUNTPOINT}/*")
          exec("zpool import -N -R #{MOUNTPOINT} #{@pool_name}")
          exec("zpool import -f -N -R #{MOUNTPOINT} #{@boot_pool_name}") if @dev_boot
          @mount.swap(@dev_swap)
          mount_root
          mount_boot
          @mount.esp(@dev_esp)
          exec("zfs mount -a")
          @state.mount
        end

        private

        def mount_root
          Helpers::mkdir(MOUNTPOINT)
          exec("zfs mount #{@pool_name}/ROOT/#{@n}")
        end

        def mount_boot
          return if ! @dev_boot
          exec("zfs mount #{@boot_pool_name}/BOOT/#{@n}")
        end

        def exec(cmd)
          @log.info("==> #{cmd}")
          Helpers::sys(cmd)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
getch-0.1.6 lib/getch/filesystem/zfs/mount.rb