summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Pashev <pashev.igor@gmail.com>2013-04-09 13:34:35 +0000
committerIgor Pashev <pashev.igor@gmail.com>2013-04-09 13:34:35 +0000
commit285a0dca4874332d9605a978567622ae31ce15a7 (patch)
treed1ef9541b26ac522625631fd70d8b171255abea6
parentfc00d4939e5e8588a330420ff762daf5fb39557e (diff)
downloadlive-285a0dca4874332d9605a978567622ae31ce15a7.tar.gz
Create BE
-rwxr-xr-xinstall103
1 files changed, 99 insertions, 4 deletions
diff --git a/install b/install
index 6587a58..e594bbb 100755
--- a/install
+++ b/install
@@ -31,6 +31,10 @@ rpool = None
# Name of the root slice, where ZFS root pool will be created (e. g. c0t0d0s0)
rslice = None
+# Created boot environment
+bootenv = None
+
+
class Abort(Exception):
''' User clicked "Cancel" '''
pass
@@ -136,11 +140,13 @@ def create_rpool(hdd):
pool_name = 'rpool{}'.format(pool_no)
if not pool_name in zpools:
break
+ else:
+ pool_name = None;
progress = ProgressMessage(screen, title='Please, wait',
text='Creating ZFS pool "{rpool}" on slice "{slice}" ...'.format(rpool=pool_name, slice=rslice))
- zpool_cmd = Popen(['zpool', 'create', '-f', pool_name, rslice],
+ zpool_cmd = Popen(['zpool', 'create', '-R', '/mnt/'+pool_name, '-f', pool_name, rslice],
stderr=PIPE, stdout=PIPE)
out, err = zpool_cmd.communicate()
if 0 != zpool_cmd.returncode:
@@ -168,7 +174,7 @@ def configure_rpool():
if not pool_is_imported(rpool):
progress = ProgressMessage(screen, title='Please, wait',
text='Importing ZFS pool "{}" ...'.format(rpool))
- zpool_cmd = Popen(['zpool', 'import', '-f', rpool], stderr=PIPE, stdout=PIPE)
+ zpool_cmd = Popen(['zpool', 'import', '-R', '/mnt/'+rpool, '-f', rpool], stderr=PIPE, stdout=PIPE)
out, err = zpool_cmd.communicate()
if 0 != zpool_cmd.returncode:
ButtonChoiceWindow(screen,
@@ -176,10 +182,99 @@ def configure_rpool():
text=err, buttons=['Ok'], width=70)
rpool = None
+def zfs_exists(fs):
+ fs_exists = call(['zfs', 'list', '-H', fs], stdout=PIPE, stderr=PIPE)
+ return fs_exists == 0
-def configure_zfs():
- pass
+def zfs_create(fs, zvol=None, options={}):
+ args = ['zfs', 'create']
+ if zvol:
+ args += ['-V', zvol]
+
+ for o in options:
+ args += ['-o', o + '=' + options[o]]
+
+ args.append(fs)
+ zfs_cmd = Popen(args, stderr=PIPE, stdout=PIPE)
+ out, err = zfs_cmd.communicate()
+ if 0 != zfs_cmd.returncode:
+ ButtonChoiceWindow(screen,
+ title='Creating of ZFS dataset failed',
+ text=err, buttons = ['Ok'], width=70)
+ return False
+ return True
+
+
+def configure_zfs():
+ global bootenv
+ progress = ProgressBar(screen, title='Creating ZFS filesystems')
+ root = rpool + '/ROOT'
+ if not zfs_exists(root):
+ progress.text = 'Creating ' + root
+ zfs_create(root, options={'canmount':'off'})
+ progress.progress = 10
+
+ # Make sure we are creating new boot environment
+ bootenv = None
+ for be_no in range(20):
+ bootenv = root + '/osdy-' + str(be_no)
+ if not zfs_exists(bootenv):
+ break
+ else:
+ bootenv = None
+ progress.progress = 20
+
+ progress.text = 'Creating ' + bootenv
+ zfs_create(bootenv, options={'canmount':'noauto'})
+ progress.progress = 30
+
+ fs = bootenv + '/usr'
+ progress.text = 'Creating ' + fs
+ zfs_create(fs)
+ progress.progress = 50
+
+ fs = bootenv + '/usr/local'
+ progress.text = 'Creating ' + fs
+ zfs_create(fs, options={'compression':'on'})
+ progress.progress = 55
+
+ fs = bootenv + '/usr/src'
+ progress.text = 'Creating ' + fs
+ zfs_create(fs, options={'compression':'on'})
+ progress.progress = 60
+
+ fs = bootenv + '/var'
+ progress.text = 'Creating ' + fs
+ zfs_create(fs)
+ progress.progress = 65
+
+ fs = bootenv + '/var/log'
+ progress.text = 'Creating ' + fs
+ zfs_create(fs)
+ progress.progress = 70
+
+ fs = bootenv + '/var/lib'
+ progress.text = 'Creating ' + fs
+ zfs_create(fs)
+ progress.progress = 75
+
+ fs = bootenv + '/var/cache'
+ progress.text = 'Creating ' + fs
+ zfs_create(fs)
+ progress.progress = 80
+
+ fs = bootenv + '/var/tmp'
+ progress.text = 'Creating ' + fs
+ zfs_create(fs)
+ progress.progress = 90
+
+ home = root + '/home'
+ if not zfs_exists(home):
+ progress.text = 'Creating ' + home
+ zfs_create(home, options={'mountpoint':'/home', 'compression':'on',
+ 'devices':'off', 'setuid':'off'})
+ progress.progress = 100
def choose_hdd(number_of_zpools = 0):
hdd_items = map(lambda x: '{}: {} {}'.format(x.name, x.capacity, x.description), hdds)