public function takeSnapshot() { lxshell_return("modprobe", "dm-snapshot"); $tmp = "{$this->main->configrootdir}/snapshot_mount"; lxfile_mkdir($tmp); $tmp = expand_real_root($tmp); $size = lvm_disksize($this->main->maindisk); $size = $size / 3; $size = round($size); $vgname = $this->main->corerootdir; $vgname = fix_vgname($vgname); $sfpath = "/dev/{$vgname}/{$this->main->nname}_snapshot"; $out = exec_with_all_closed_output("lvdisplay -c {$sfpath}"); if (csa($out, ":")) { lxshell_return("umount", $sfpath); lvm_remove($sfpath); } $out = exec_with_all_closed_output("lvdisplay -c {$sfpath}"); if (csa($out, ":")) { throw new lxException("old_snapshot_exists_and_cant_remove"); } $ret = lxshell_return("lvcreate", "-L{$size}M", "-s", "-n", "{$this->main->nname}_snapshot", $this->main->maindisk); if ($ret) { throw new lxException("could_not_create_snapshot_lack_of_space"); } if (!$this->main->isWindows()) { lxshell_return("e2fsck", "-f", "-y", $sfpath); lxshell_return("mount", "-o", "ro", $sfpath, $tmp); } else { $tmp = $sfpath; } return $tmp; }
function lvm_extend($lvpath, $size) { global $gbl, $sgbl, $login, $ghtml; global $global_shell_error; $cursize = lvm_disksize($lvpath); $extra = $size - $cursize; if ($extra > 0) { $ret = lxshell_return("lvextend", "-L+{$extra}M", $lvpath); if ($ret) { $gbl->setWarning('extending_failed', '', $global_shell_error); } } }