Class: LinuxAdmin::Partition
- Inherits:
-
LinuxAdmin
- Object
- LinuxAdmin
- LinuxAdmin::Partition
- Defined in:
- lib/linux_admin/partition.rb
Constant Summary
Constants inherited from LinuxAdmin
Instance Attribute Summary collapse
-
#disk ⇒ Object
Returns the value of attribute disk.
-
#end_sector ⇒ Object
Returns the value of attribute end_sector.
-
#fs_type ⇒ Object
Returns the value of attribute fs_type.
-
#id ⇒ Object
Returns the value of attribute id.
-
#mount_point ⇒ Object
Returns the value of attribute mount_point.
-
#partition_type ⇒ Object
Returns the value of attribute partition_type.
-
#size ⇒ Object
Returns the value of attribute size.
-
#start_sector ⇒ Object
Returns the value of attribute start_sector.
Instance Method Summary collapse
- #format_to(filesystem) ⇒ Object
-
#initialize(args = {}) ⇒ Partition
constructor
A new instance of Partition.
- #mount(mount_point = nil) ⇒ Object
- #path ⇒ Object
- #umount ⇒ Object
Methods included from Common
Constructor Details
#initialize(args = {}) ⇒ Partition
Returns a new instance of Partition.
19 20 21 22 23 24 25 26 27 |
# File 'lib/linux_admin/partition.rb', line 19 def initialize(args={}) @id = args[:id] @size = args[:size] @disk = args[:disk] @fs_type = args[:fs_type] @start_sector = args[:start_sector] @end_sector = args[:end_sector] @partition_type = args[:partition_type] end |
Instance Attribute Details
#disk ⇒ Object
Returns the value of attribute disk.
16 17 18 |
# File 'lib/linux_admin/partition.rb', line 16 def disk @disk end |
#end_sector ⇒ Object
Returns the value of attribute end_sector.
14 15 16 |
# File 'lib/linux_admin/partition.rb', line 14 def end_sector @end_sector end |
#fs_type ⇒ Object
Returns the value of attribute fs_type.
12 13 14 |
# File 'lib/linux_admin/partition.rb', line 12 def fs_type @fs_type end |
#id ⇒ Object
Returns the value of attribute id.
10 11 12 |
# File 'lib/linux_admin/partition.rb', line 10 def id @id end |
#mount_point ⇒ Object
Returns the value of attribute mount_point.
17 18 19 |
# File 'lib/linux_admin/partition.rb', line 17 def mount_point @mount_point end |
#partition_type ⇒ Object
Returns the value of attribute partition_type.
11 12 13 |
# File 'lib/linux_admin/partition.rb', line 11 def partition_type @partition_type end |
#size ⇒ Object
Returns the value of attribute size.
15 16 17 |
# File 'lib/linux_admin/partition.rb', line 15 def size @size end |
#start_sector ⇒ Object
Returns the value of attribute start_sector.
13 14 15 |
# File 'lib/linux_admin/partition.rb', line 13 def start_sector @start_sector end |
Instance Method Details
#format_to(filesystem) ⇒ Object
33 34 35 36 37 |
# File 'lib/linux_admin/partition.rb', line 33 def format_to(filesystem) run!(cmd(:mke2fs), :params => { '-t' => filesystem, nil => self.path}) @fs_type = filesystem end |
#mount(mount_point = nil) ⇒ Object
39 40 41 42 43 44 45 46 47 |
# File 'lib/linux_admin/partition.rb', line 39 def mount(mount_point=nil) @mount_point = mount_point @mount_point = "/mnt/#{disk.path.split(File::SEPARATOR).last}#{id}" if mount_point.nil? FileUtils.mkdir(@mount_point) unless File.directory?(@mount_point) run!(cmd(:mount), :params => { nil => [self.path, @mount_point] }) end |
#path ⇒ Object
29 30 31 |
# File 'lib/linux_admin/partition.rb', line 29 def path "#{disk.path}#{id}" end |
#umount ⇒ Object
49 50 51 52 |
# File 'lib/linux_admin/partition.rb', line 49 def umount run!(cmd(:umount), :params => { nil => [@mount_point] }) end |