mirror of
https://github.com/NixOS/mobile-nixos.git
synced 2024-12-18 05:21:47 +03:00
21 lines
483 B
Ruby
21 lines
483 B
Ruby
|
# Automatically resizes the given filesystem.
|
||
|
class Tasks::AutoResize < Task
|
||
|
attr_reader :device
|
||
|
|
||
|
def initialize(device, type: )
|
||
|
@device = device
|
||
|
@type = type
|
||
|
add_dependency(:Files, @device)
|
||
|
end
|
||
|
|
||
|
def run()
|
||
|
log("Resizing #{@device}...")
|
||
|
if @type.match(/^ext[234]$/)
|
||
|
System.run("e2fsck", "-fp", @device)
|
||
|
System.run("resize2fs", "-f", @device)
|
||
|
else
|
||
|
$logger.warn("Cannot resize #{@type}... filesystem left untouched.")
|
||
|
end
|
||
|
end
|
||
|
end
|