Beispiel #1
0
bool wizardDisk::checkDiskSpace()
{
  if ( getDiskSliceSize() < 4000 )
    return false;

  return true;
}
Beispiel #2
0
void wizardDisk::populateDiskTree()
{
  QStringList tmpList, zMnts;
  QString tmp, opts;

  // If installing to Free Space, show the option to change partition size
  labelNewPartition->setVisible(false);
  spinNewPartition->setVisible(false);
  spinNewPartition->setRange(0, 0);
  spinNewPartition->setValue(0);
  if ( comboPartition->currentIndex() != 0 && comboPartition->currentText().contains("Unused") ) {
    spinNewPartition->setRange(5000, this->getDiskSliceSize());
    spinNewPartition->setValue(getDiskSliceSize());
    labelNewPartition->setVisible(true);
    spinNewPartition->setVisible(true);
  }

  treeMounts->clear();
  treeMounts->setHeaderLabels(QStringList() << "ID" << tr("ZFS Mounts") << tr("ZFS Options") );
  treeMounts->setColumnCount(3);
  labelFreeSpace->setVisible(false);
  lineFreeMB->setVisible(false);

  treeMounts->header()->setSectionHidden(0, true);
  treeMounts->header()->setDefaultSectionSize(150);


  zMnts = sysFinalDiskLayout.at(0).at(2).split(",");

  // Now loop through ZFS mounts
  for (int i=0; i < zMnts.count(); ++i) {
    tmpList.clear();
    opts = zMnts.at(i).section("(", 1, 1).section(")", 0, 0); 
    tmpList << tmp.setNum(i+1) << zMnts.at(i).split("(").at(0) << opts ;
    QTreeWidgetItem *mItem = new QTreeWidgetItem(treeMounts, tmpList);
    mItem->setToolTip(2, opts);
  }

  treeMounts->setCurrentItem(treeMounts->findItems("0", Qt::MatchFixedString).at(0));
  slotTreeDiskChanged();  

  if ( restoreMode ) {
     treeMounts->setEnabled(false);
     pushRemoveMount->setEnabled(false);
     pushAddMount->setEnabled(false);
     labelMounts->setText(tr("The original system datasets / mount-points will be automatically restored."));
  }

}
Beispiel #3
0
void wizardDisk::generateDiskLayout()
{
  QString targetType, tmp;
  int targetLoc, totalSize = 0;
  QString targetDisk, targetSlice, tmpPass, fsType, target;

  // Clear out the original disk layout
  sysFinalDiskLayout.clear();
  QStringList fileSystem;
  qDebug() << "Generating disk layout";

  if ( comboPartition->currentIndex() == 0) {
    targetType = "DRIVE";
    targetSlice = "ALL";
    targetDisk = comboDisk->currentText();
    targetDisk.truncate(targetDisk.indexOf(" -"));
    target = targetDisk;
    targetLoc = 1;
  } else {
    targetType = "SLICE";
    targetDisk = comboDisk->currentText();
    targetDisk.truncate(targetDisk.indexOf(" -"));
    targetSlice = comboPartition->currentText();
    targetSlice.truncate(targetSlice.indexOf(":"));
    targetSlice = targetSlice.remove(0, targetSlice.size() -2);
    target = targetDisk + targetSlice;
    targetLoc = 2;
  }
  

  totalSize = getDiskSliceSize();
  if ( totalSize != -1 )
  {
     fsType= "ZFS";

     // This lets the user do nifty stuff like a mirror/raid post-install with a single zpool command
    fileSystem << targetDisk << targetSlice << "/,/tmp(compress=lzjb),/usr(canmount=off),/usr/home,/usr/jails,/usr/obj(compress=lzjb),/usr/pbi,/usr/ports(compress=gzip),/usr/ports/distfiles(compress=off),/usr/src(compress=gzip),/var(canmount=off),/var/audit(compress=lzjb),/var/log(compress=gzip),/var/tmp(compress=lzjb)" << fsType << tmp.setNum(totalSize) << "" << tmpPass;
     //qDebug() << "Auto-Gen FS:" <<  fileSystem;
     sysFinalDiskLayout << fileSystem;
     fileSystem.clear();
  }
  
  qDebug() << "AutoLayout:" <<  sysFinalDiskLayout;
}
Beispiel #4
0
void wizardDisk::generateDiskLayout()
{
  QString targetType, tmp;
  int targetLoc, totalSize = 0;
  QString targetDisk, targetSlice, tmpPass, fsType, target;

  // Clear out the original disk layout
  sysFinalDiskLayout.clear();
  QStringList fileSystem;
  qDebug() << "Generating disk layout";

  if ( comboPartition->currentIndex() == 0) {
    targetType = "DRIVE";
    targetSlice = "ALL";
    targetDisk = comboDisk->currentText();
    targetDisk.truncate(targetDisk.indexOf(" -"));
    target = targetDisk;
    targetLoc = 1;
  } else {
    targetType = "SLICE";
    targetDisk = comboDisk->currentText();
    targetDisk.truncate(targetDisk.indexOf(" -"));
    targetSlice = comboPartition->currentText();
    targetSlice.truncate(targetSlice.indexOf(":"));
    targetSlice = targetSlice.remove(0, targetSlice.size() -2);
    target = targetDisk + targetSlice;
    targetLoc = 2;
  }

  // Get the size of the slice we are working on
  totalSize = getDiskSliceSize();

  // Setup some swap space
  bool noswap = check_noswap->isChecked();
  if ( !noswap && totalSize > 50000 ) {
    // 4GB if over 50GB of disk space
    swapsize = 4096;
  } else if ( !noswap && totalSize > 30000 ) {
    // 2GB if over 30GB of disk space
    swapsize = 2048;
  } else if (!noswap){
    // Minimum 512MB
    swapsize = 512;
  }else{
    swapsize = 0;
  }
  totalSize = totalSize - swapsize;


  if ( totalSize != -1 )
  {
     fsType= "ZFS";
     if ( groupEncrypt->isChecked() ) {
        fsType="ZFS.eli";
        tmpPass=lineEncPass->text();
     }

    QString rootOpts="";
    rootOpts="(compress=lz4|atime=off)";

     // This lets the user do nifty stuff like a mirror/raid post-install with a single zpool command
    fileSystem << targetDisk << targetSlice << "/" + rootOpts + ",/tmp(compress=lz4|setuid=off),/usr(canmount=off|mountpoint=none),/usr/home(compress=lz4),/usr/jails(compress=lz4),/usr/local/share/doc(compress=gzip),/usr/obj(compress=lz4),/usr/ports(compress=lz4),/usr/src(compress=lz4),/var(canmount=off|atime=on|mountpoint=none),/var/audit(compress=lz4),/var/log(compress=lz4|exec=off|setuid=off),/var/mail(compress=lz4),/var/tmp(compress=lz4|exec=off|setuid=off)" << fsType << tmp.setNum(totalSize) << "" << tmpPass;
    sysFinalDiskLayout << fileSystem;
    fileSystem.clear();

  // If installing to a specific GPT slice, we can't create a 2nd swap partition
  if ( swapsize > 0 ) {
    // Now add swap space
    fileSystem << targetDisk << targetSlice << "SWAP.eli" << "SWAP.eli" << tmp.setNum(swapsize) << "" << "";
    sysFinalDiskLayout << fileSystem;
    fileSystem.clear();
  }

    //qDebug() << "Auto-Gen FS:" <<  fileSystem;
  }
  
  qDebug() << "AutoLayout:" <<  sysFinalDiskLayout;
}
Beispiel #5
0
void wizardDisk::generateCustomDiskLayout()
{
  QString targetType, tmp;
  int targetLoc;
  QString targetDisk, targetSlice, tmpPass, fsType, target;

  // Clear out the original disk layout
  sysFinalDiskLayout.clear();
  QStringList fileSystem;
  qDebug() << "Generating custom disk layout";
       
  if ( comboPartition->currentIndex() == 0) {
    targetType = "DRIVE";
    targetSlice = "ALL";
    targetDisk = comboDisk->currentText();
    targetDisk.truncate(targetDisk.indexOf(" -"));
    target = targetDisk;
    targetLoc = 1;
  } else {
    targetType = "SLICE";
    targetDisk = comboDisk->currentText();
    targetDisk.truncate(targetDisk.indexOf(" -"));
    targetSlice = comboPartition->currentText();
    targetSlice.truncate(targetSlice.indexOf(":"));
    targetSlice = targetSlice.remove(0, targetSlice.size() -2);
    target = targetDisk + targetSlice;
    targetLoc = 2;
  }

  // Check if this is an install to "Unused Space"
  for (int z=0; z < sysDisks.count(); ++z)
     if ( sysDisks.at(z).at(0) == "SLICE" \
       && sysDisks.at(z).at(2) == targetDisk + targetSlice \
       && sysDisks.at(z).at(4) == "Unused Space" ) {
       targetSlice = "free";
     }

  // Start building the ZFS file-systems
  QStringList zMnts;
  fsType = "ZFS";
  if ( groupEncrypt->isChecked() ) {
    fsType="ZFS.eli";
    tmpPass=lineEncPass->text();
  }
  int zpoolSize = getDiskSliceSize();

  // If we are using free space, get the user set size
  if ( targetSlice == "free" && spinNewPartition->value() != 0 )
    zpoolSize = spinNewPartition->value();

  // Deduct any swap space
  zpoolSize = zpoolSize - swapsize;

  // Get the zfs mounts
  QList<QTreeWidgetItem *> mItems = treeMounts->findItems("*", Qt::MatchWildcard);
  for ( int i = 0; i < mItems.size(); ++i) {
    if ( mItems.at(i)->text(2).isEmpty() )
      zMnts << mItems.at(i)->text(1);
    else
      zMnts << mItems.at(i)->text(1) + "(" + mItems.at(i)->text(2) + ")";
  }

  // If we have any additional ZFS mirror / raidz devices set it up now
  QString zOpts, zDisk;
  if ( groupZFSOpts->isChecked() && comboPartition->currentIndex() == 0 ) {
     zOpts = comboZFSMode->currentText() + ":";
     for ( int i = 0; i < listZFSDisks->count(); ++i )
        if ( listZFSDisks->item(i)->checkState() == Qt::Checked ) {
           zDisk = listZFSDisks->item(i)->text();
           zDisk.truncate(zDisk.indexOf(" -"));
           zOpts = zOpts + " " + zDisk;
        }
  }
  // Any additional ZFS cache devices?
  if ( groupZFSCache->isChecked() ) {
     zOpts+=" cache";
     for ( int i = 0; i < listZFSCache->count(); ++i )
        if ( listZFSCache->item(i)->checkState() == Qt::Checked ) {
           zDisk = listZFSCache->item(i)->text();
           zDisk.truncate(zDisk.indexOf(" -"));
           zOpts = zOpts + " " + zDisk;
        }
  }
  // Any additional ZFS log devices?
  if ( groupZFSLog->isChecked() ) {
     zOpts+=" log";
     for ( int i = 0; i < listZFSLog->count(); ++i )
        if ( listZFSLog->item(i)->checkState() == Qt::Checked ) {
           zDisk = listZFSLog->item(i)->text();
           zDisk.truncate(zDisk.indexOf(" -"));
           zOpts = zOpts + " " + zDisk;
        }
  }

  // Save the final disk layout
  fileSystem.clear();
  fileSystem << targetDisk << targetSlice << zMnts.join(",") << fsType << tmp.setNum(zpoolSize) << zOpts << tmpPass;
  sysFinalDiskLayout << fileSystem;

  // If installing to a specific GPT slice, we can't create a 2nd swap partition
  if ( swapsize > 0 ) {
    // Now add swap space 
    fileSystem.clear();
    fileSystem << targetDisk << targetSlice << "SWAP.eli" << "SWAP.eli" << tmp.setNum(swapsize) << "" << "";
    sysFinalDiskLayout << fileSystem;
  }

  qDebug() <<"AutoLayout:" << sysFinalDiskLayout;
}
Beispiel #6
0
void wizardDisk::generateCustomDiskLayout()
{
  QString targetType, tmp;
  int targetLoc;
  QString targetDisk, targetSlice, tmpPass, fsType, target;

  // Clear out the original disk layout
  sysFinalDiskLayout.clear();
  QStringList fileSystem;
  qDebug() << "Generating custom disk layout";
       
  if ( comboPartition->currentIndex() == 0) {
    targetType = "DRIVE";
    targetSlice = "ALL";
    targetDisk = comboDisk->currentText();
    targetDisk.truncate(targetDisk.indexOf(" -"));
    target = targetDisk;
    targetLoc = 1;
  } else {
    targetType = "SLICE";
    targetDisk = comboDisk->currentText();
    targetDisk.truncate(targetDisk.indexOf(" -"));
    targetSlice = comboPartition->currentText();
    targetSlice.truncate(targetSlice.indexOf(":"));
    targetSlice = targetSlice.remove(0, targetSlice.size() -2);
    target = targetDisk + targetSlice;
    targetLoc = 2;
  }

  // Start building the ZFS file-systems
  QStringList zMnts;
  fsType = "ZFS";
  int zpoolSize = getDiskSliceSize();

  // Get the zfs mounts
  QList<QTreeWidgetItem *> mItems = treeMounts->findItems("*", Qt::MatchWildcard);
  for ( int i = 0; i < mItems.size(); ++i) {
    if ( mItems.at(i)->text(2).isEmpty() )
      zMnts << mItems.at(i)->text(1);
    else
      zMnts << mItems.at(i)->text(1) + "(" + mItems.at(i)->text(2) + ")";
  }

  // If we have any additional ZFS mirror / raidz devices set it up now
  QString zOpts, zDisk;
  if ( groupZFSOpts->isChecked() && comboPartition->currentIndex() == 0 ) {
     zOpts = comboZFSMode->currentText() + ":";
     for ( int i = 0; i < listZFSDisks->count(); ++i )
        if ( listZFSDisks->item(i)->checkState() == Qt::Checked ) {
           zDisk = listZFSDisks->item(i)->text();
           zDisk.truncate(zDisk.indexOf(" -"));
           zOpts = zOpts + " " + zDisk;
        }
  }

  // Save the final disk layout
  fileSystem.clear();
  fileSystem << targetDisk << targetSlice << zMnts.join(",") << fsType << tmp.setNum(zpoolSize) << zOpts << tmpPass;
  sysFinalDiskLayout << fileSystem;

  qDebug() <<"AutoLayout:" << sysFinalDiskLayout;
}