def perform_installation_steps(): print() print('This is your chosen configuration:') archinstall.log("-- Guided template chosen (with below config) --", level=archinstall.LOG_LEVELS.Debug) archinstall.log(json.dumps(archinstall.arguments, indent=4, sort_keys=True, cls=archinstall.JSON), level=archinstall.LOG_LEVELS.Info) print() input('Press Enter to continue.') """ Issue a final warning before we continue with something un-revertable. We mention the drive one last time, and count from 5 to 0. """ if archinstall.arguments.get('harddrive', None): print(f" ! Formatting {archinstall.arguments['harddrive']} in ", end='') archinstall.do_countdown() """ Setup the blockdevice, filesystem (and optionally encryption). Once that's done, we'll hand over to perform_installation() """ with archinstall.Filesystem(archinstall.arguments['harddrive'], archinstall.GPT) as fs: # Wipe the entire drive if the disk flag `keep_partitions`is False. if archinstall.arguments['harddrive'].keep_partitions is False: fs.use_entire_disk( root_filesystem_type=archinstall.arguments.get( 'filesystem', 'btrfs')) # Check if encryption is desired and mark the root partition as encrypted. if archinstall.arguments.get('!encryption-password', None): root_partition = fs.find_partition('/') root_partition.encrypted = True # After the disk is ready, iterate the partitions and check # which ones are safe to format, and format those. for partition in archinstall.arguments['harddrive']: if partition.safe_to_format(): # Partition might be marked as encrypted due to the filesystem type crypt_LUKS # But we might have omitted the encryption password question to skip encryption. # In which case partition.encrypted will be true, but passwd will be false. if partition.encrypted and (passwd := archinstall.arguments.get( '!encryption-password', None)): partition.encrypt(password=passwd) else: partition.format() else: archinstall.log( f"Did not format {partition} because .safe_to_format() returned False or .allow_formatting was False.", level=archinstall.LOG_LEVELS.Debug) fs.find_partition('/boot').format('vfat') if archinstall.arguments.get('!encryption-password', None): # First encrypt and unlock, then format the desired partition inside the encrypted part. # archinstall.luks2() encrypts the partition when entering the with context manager, and # unlocks the drive so that it can be used as a normal block-device within archinstall. with archinstall.luks2( fs.find_partition('/'), 'luksloop', archinstall.arguments.get('!encryption-password', None)) as unlocked_device: unlocked_device.format(fs.find_partition('/').filesystem) unlocked_device.mount('/mnt') else: fs.find_partition('/').format( fs.find_partition('/').filesystem) fs.find_partition('/').mount('/mnt') fs.find_partition('/boot').mount('/mnt/boot')
def perform_installation_steps(): global SIG_TRIGGER print() print('This is your chosen configuration:') archinstall.log("-- Guided template chosen (with below config) --", level=archinstall.LOG_LEVELS.Debug) archinstall.log(json.dumps(archinstall.arguments, indent=4, sort_keys=True, cls=archinstall.JSON), level=archinstall.LOG_LEVELS.Info) print() input('Press Enter to continue.') """ Issue a final warning before we continue with something un-revertable. We mention the drive one last time, and count from 5 to 0. """ print(f" ! Formatting {archinstall.arguments['harddrive']} in ", end='') for i in range(5, 0, -1): print(f"{i}", end='') for x in range(4): sys.stdout.flush() time.sleep(0.25) print(".", end='') if SIG_TRIGGER: abort = input('\nDo you really want to abort (y/n)? ') if abort.strip() != 'n': exit(0) if SIG_TRIGGER is False: sys.stdin.read() SIG_TRIGGER = False signal.signal(signal.SIGINT, sig_handler) # Put back the default/original signal handler now that we're done catching # and interrupting SIGINT with "Do you really want to abort". print() signal.signal(signal.SIGINT, original_sigint_handler) """ Setup the blockdevice, filesystem (and optionally encryption). Once that's done, we'll hand over to perform_installation() """ with archinstall.Filesystem(archinstall.arguments['harddrive'], archinstall.GPT) as fs: # Wipe the entire drive if the disk flag `keep_partitions`is False. if archinstall.arguments['harddrive'].keep_partitions is False: fs.use_entire_disk(root_filesystem_type=archinstall.arguments.get( 'filesystem', 'btrfs')) # Check if encryption is desired and mark the root partition as encrypted. if archinstall.arguments.get('!encryption-password', None): root_partition = fs.find_partition('/') root_partition.encrypted = True # After the disk is ready, iterate the partitions and check # which ones are safe to format, and format those. for partition in archinstall.arguments['harddrive']: if partition.safe_to_format(): # Partition might be marked as encrypted due to the filesystem type crypt_LUKS # But we might have omitted the encryption password question to skip encryption. # In which case partition.encrypted will be true, but passwd will be false. if partition.encrypted and (passwd := archinstall.arguments.get( '!encryption-password', None)): partition.encrypt(password=passwd) else: partition.format() else: archinstall.log( f"Did not format {partition} because .safe_to_format() returned False or .allow_formatting was False.", level=archinstall.LOG_LEVELS.Debug) if archinstall.arguments.get('!encryption-password', None): # First encrypt and unlock, then format the desired partition inside the encrypted part. # archinstall.luks2() encrypts the partition when entering the with context manager, and # unlocks the drive so that it can be used as a normal block-device within archinstall. with archinstall.luks2( fs.find_partition('/'), 'luksloop', archinstall.arguments.get('!encryption-password', None)) as unlocked_device: unlocked_device.format(fs.find_partition('/').filesystem) perform_installation( device=unlocked_device, boot_partition=fs.find_partition('/boot'), language=archinstall.arguments['keyboard-language'], mirrors=archinstall.arguments['mirror-region']) else: perform_installation( device=fs.find_partition('/'), boot_partition=fs.find_partition('/boot'), language=archinstall.arguments['keyboard-language'], mirrors=archinstall.arguments['mirror-region'])
import archinstall import json import urllib.request import git # Unmount and close previous runs (Mainly only used for re-runs, but won't hurt.) archinstall.sys_command(f'umount -R /mnt', suppress_errors=True) archinstall.sys_command(f'cryptsetup close /dev/mapper/luksloop', suppress_errors=True) # Select a harddrive and a disk password harddrive = archinstall.all_disks()['/dev/sda'] disk_password = '******' with archinstall.Filesystem(harddrive) as fs: # Use the entire disk instead of setting up partitions on your own fs.use_entire_disk('luks2') if harddrive.partition[1].size == '512M': raise OSError('Trying to encrypt the boot partition for petes sake..') harddrive.partition[0].format('fat32') with archinstall.luks2(harddrive.partition[1], 'luksloop', disk_password) as unlocked_device: unlocked_device.format('btrfs') with archinstall.Installer(unlocked_device, boot_partition=harddrive.partition[0], hostname="testmachine") as installation: if installation.minimal_installation(): installation.add_bootloader()
# Once this is done, we output some useful information to the user # And the installation is complete. archinstall.log( "There are two new accounts in your installation after reboot:") archinstall.log(" * root (password: airoot)") archinstall.log(" * devel (password: devel)") if archinstall.arguments['harddrive']: archinstall.arguments['harddrive'].keep_partitions = False print(f" ! Formatting {archinstall.arguments['harddrive']} in ", end='') archinstall.do_countdown() # First, we configure the basic filesystem layout with archinstall.Filesystem(archinstall.arguments['harddrive'], archinstall.GPT) as fs: # We use the entire disk instead of setting up partitions on your own if archinstall.arguments['harddrive'].keep_partitions is False: fs.use_entire_disk(root_filesystem_type=archinstall.arguments.get( 'filesystem', 'btrfs')) boot = fs.find_partition('/boot') root = fs.find_partition('/') boot.format('vfat') # We encrypt the root partition if we got a password to do so with, # Otherwise we just skip straight to formatting and installation if archinstall.arguments.get('!encryption-password', None): root.encrypted = True root.encrypt(password=archinstall.arguments.get(
print(f' ! Formatting {harddrive} in 5...') time.sleep(1) print(f' ! Formatting {harddrive} in 4...') time.sleep(1) print(f' ! Formatting {harddrive} in 3...') time.sleep(1) print(f' ! Formatting {harddrive} in 2...') time.sleep(1) print(f' ! Formatting {harddrive} in 1...') time.sleep(1) """ Setup the blockdevice, filesystem (and optionally encryption). Once that's done, we'll hand over to perform_installation() """ with archinstall.Filesystem(harddrive, archinstall.GPT) as fs: # Use partitioning helper to set up the disk partitions. if disk_password: fs.use_entire_disk('luks2') else: fs.use_entire_disk('ext4') if harddrive.partition[1].size == '512M': raise OSError('Trying to encrypt the boot partition for petes sake..') harddrive.partition[0].format('fat32') if disk_password: # First encrypt and unlock, then format the desired partition inside the encrypted part. # archinstall.luks2() encrypts the partition when entering the with context manager, and # unlocks the drive so that it can be used as a normal block-device within archinstall. with archinstall.luks2(harddrive.partition[1], 'luksloop', disk_password) as unlocked_device:
import archinstall archdrives = archinstall.all_disks() print(f"Please select a drive: 0 - {len(archdrives) - 1}") i = 0 drives = [] for drive in archdrives: print(f"{i}: {drive}") drives.append(drive) i += 1 selected_drive = drives[int(input())] print(f"Installing on the drive \"{selected_drive}\"") mode = archinstall.GPT fs = archinstall.Filesystem(selected_drive, mode) # fs.find_partition() fs.use_entire_disk("btrfs") test = fs.add_partition("fat32", 2048, 3072) print(test)