Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archinstall/lib/disk
AgeCommit message (Collapse)Author
2022-04-03Partition.boot works now for GPT and MBR disks (issue #1061) (#1063)Werner Llácer
2022-03-10Additions to Listmgr et alia (#1028)Werner Llácer
* Permit multiple default actions as a list * Define headers for list at ListManager and Menu * small corrections for default values * Make subvolume info work. The real marker that signifies that a mounted subvolume exist is the bracket notation nor the at sign
2022-02-28Fix (some) mypy things (#996)Daniel
* Fix mypy things * Fix flake8 Co-authored-by: Daniel Girtler <girtler.daniel@gmail.com>
2022-02-08Change usage `lsblk` to `blkid` where possible. And general improvements to ↵Anton Hvornum
disk handling. (#949) * Renamed all_disks() to all_blockdevices() as it's technically a bit more correct. As it would return partitions as well. And it now distinguishes between BlockDevice() and Partition() when returning values. Also lsblk has been replaced with blkid and glob.glob() on /sys/class/block/ * Added handling of loop devices * Added device information enrichment * Removed old code * Updated the usage of blockdevice.info['type'] to 'DEVTYPE' as per returned by blkid instead of lsblk * Created a MapperDev() and DMCryptDev() 'disk' classes. This should help differentiate between BlockDevice(), Partition() and crypt-specific devices. Due to some new helper functions (mentioned later) BlockDevice().device_or_backfile has been simplified thanks to the information being pre-existing instead of having to call losetup. BlockDevice().mountpoint has been added as a dummy function. archinstall.enrich_blockdevice_information() has been added to enrich information extracted from blkid. archinstall.uevent() has been created to parse blkdid data when in -o export format, also eats up /sys/class/x/y/uevent data which is of the same format. all_blockdevices() now returns mapper devices found under /dev/mapper/ and properly returns the different types, not just BlockDevice() for everything. archinstall.get_parent_of_partition() has been added, which can translate /dev/sda1 to /dev/sda via strings by using /sys/class/block/ - note here tho that it has to be a blockdevice. Other parents won't return properly. archinstall.find_mountpoint() was created to be able to find mountpoints for a device, rather than the other way around which get_mount_info() handles. find_mountpoint() will convert /dev/sda1 -> /boot for instance, whereas get_mount_info('/boot') will convert /boot -> /dev/sda1. archinstall.get_partitions_in_use() will now properly traverse the entire structure, not just one level deep. This called for the creation of get_all_targets() which will take a dictionary structure and look for 'target': '/path' and return all '/path' values, recursively without being trapped in get_partitions_in_use() which has recursive targets. get_partitions_in_use() now returns a dictionary instead of a list, as it also returns the mountpoint and associated device. It will also prioritize MapperDev over DMCryptDev (as MapperDev is a child of DMCryptDev and can be resolved, other way around is 'trickier'). * Reverted Installer().partitions to return only the partitions. It's a slight speed defecit by not returning the mountpoints directly as {mntpoint: partition}, because the partition.mountpoint is a bit slow. But it avoids breaking legacy code :) * Fixed a few imports, and added MapperDev.filesystem * Fixed so that Installer().detect_encryption() uses the new separated logic of MapperDev/DMCryptDev/Partition * Fixing a translation issue on hostname * Added DMCryptDev.filesystem * Added back archinstall.all_disks() for legacy reasons. * Added a deprecation warning to archinstall.all_disks() * Added a enrichment check for dm-crypt specific devices, which in turn sets DMCRYPT_NAME on the device information, making it easier to detect and target DMCryptDev when needed. This should avoid issues with loopdevices being detected as DMCryptDev. Also some minor tweaks to variable names on unencrypted setups * Made debug output hidden without --verbose. Also added get_subvolume_info() which takes a path and returns any 'btrfs subvol show' information on the path * Partition().subvolumes has been added. Which generates an iterator over potential subvolumes based on mountpoint. Partition().mount_information is now a list of mount-destinations, as one partition should be allowed to be mounted to several places (more commonly used in btrfs subvolumes). BtrfsSubvolume() has been added as a 'device type', which should make it more easy to recognize a BtrfsSubvolume object right out of the gate. Only found from Partition().subvolumes currently. * Parameter fix for --verbose in log() * Made sure loopdev devices have a PATH key as well, to make dealing with them as blockdevice as seamless as possible. * Added backup information grabbing on uninitated devices * Tweaked backup option if losetup cannot find the blockdev * looks like losetup doesn't exit with a bad code even when it should. Raising ourselves when information is empty. * Fixed structure returned from get_blockdevice_uevent() * Made sure that fallback to blkid and loopdev info returns a PTTYPE (Partition Table Type) that is None, since we can't locate it yet (empty drive). But it's not False either, which is what logic after is looking for * Deprecated split_bind_name() and added more debugging * get_partitions_in_use() now only iterates over Partition() objects. And properly checks all mountpoints, not only the first. * Flipped SysCallError to show the last 500 bytes if data rather than the first, to catch the actual errors. * Removed anonymous parameters to all_blockdevices() * Added .mount_information to MapperDev * Added typing annotations * Partition().mountpoint is now a @property that will live-report the current mountpoint. * Removed the need for setting Partition().mountpoint = X when calling .mount() and .unmount(), as it's live-reported instead. * Added .subvolumes to MapperDev() * Added debug information * Muting F841 in helpers.py * Tweaked debug information in get_mount_info() * Minimized log output by moving Partition().mountpoint to DEBUG, as partitions are allowed to not be mounted * Simplified Installer().add_bootloader() to act as a router to the new split function, one for each bootloader type. This since flake8 complained about complexity and I agree that it became to wild.
2022-02-06Update nationalization (#944)Daniel
* Update nationalization * Update translations * Finish german translation * Fix errors #943 * Add remaining translations * Fix alignment in menu * Update README * Update translations: * Fix flake8 * Update tz function Co-authored-by: Daniel Girtler <girtler.daniel@gmail.com>
2022-02-04disk layout: allow to omit partition "start" option to start from previous ↵Victor Gavro
partition end (#895) * disk layout: allow to omit partition "start" option to start from previous partition end * mixed tabs/spaces fixes * Update filesystem.py Co-authored-by: Anton Hvornum <anton.feeds+github@gmail.com>
2022-02-03Command locales (second batch) (#886)Werner Llácer
* flexibilize the definition of execution locale for OS commands executed via the SysCommand* interface. Defined a storage argument which holds the default Added functions to unset the program own locales reset to the program default locales set a specific locale A decorator to execute functions in the host locale environment * rename decorator local_environ to host_locale_environ created a simmetric decorator c_locale_environ, to make a routine work with the C locale whatever is set * Correct definition of btrfs standard layout * Added error handling * Fixed issue where archinstall.Boot() would raise an exception in vain * Added debugging for SysCommandWorker() * Added some debugging * Tweaking debug a bit * Tweaking debug * Adding more debug * Adding more debug * Removed some debugging * Adding more debug * Adding more debug * Adding more debug * Adding more debug * Adding more debug * Adding more debug * Adding more debug * Adding more debug * Adding more debug * Adding more debug * Adding more debug * Removed soem debugging * Removed soem debugging * Testing a revert * Adding back the reverted change, adding lofile * Redirecting stdout to /dev/null for testing (to avoid interrupting the fork) * Reverted debug changes * Testing os.system() Co-authored-by: Anton Hvornum <anton@hvornum.se>
2022-02-02Migrate old input to new menu (#874)Daniel
* Migrate old input to new menu * Fix imports * Remove imports * Update * Fixed import by changing 'import archinstall', to 'from ..menu import Menu' and use Menu() directly * Converted archinstall.<thing> to from ..where import <thing>. This enables us to use archinstall as a module, a git repository in testing and other things without having to install archinstall as an actual module. Co-authored-by: Daniel Girtler <girtler.daniel@gmail.com> Co-authored-by: Anton Hvornum <anton@hvornum.se>
2022-02-02Torxed fix sys command calls (#932)Anton Hvornum
* Fixed exceptions in is_vm() and virtualization() * Added exception handling for parted in BlockDevice.free_space
2022-02-01Issue923 (#927)Werner Llácer
* Correct definition of btrfs standard layout * Solving issue 923. Standarize keyword "wipe" to signal the need of formatting a FS * flake8 complains
2022-01-25Correct definition of btrfs standard layout (#906)Werner Llácer
2022-01-25Fixing the 'device_instance' being None in some partition places (#902)Anton Hvornum
* Added a new return value from add_partition. Also added an exception to make sure `add_partition` can't continue silently * Added a log of debugging to add_partition * Removed a blank line (flake8) * Misconfigured variable * Added some more debugging information to partprobe * FIX: disk layout: partprobe should be called and checked only for target device (#896) * disk layout: partprobe should be called and checked only for target device * disk layout: partprobe: removed unnecessary bash subprocess * Properly defined BlockDevice() on Partition() creation. Also made sure mount-checks got some rrro handling and non-block devices should no longer attempt to return a size Co-authored-by: Anton Hvornum <anton.feeds@gmail.com> Co-authored-by: Victor Gavro <vgavro@gmail.com>
2022-01-25Make text for getting filesystems more grammatically correct (#903)Dylan M. Taylor
* Make text for getting filesystems more grammatically correct Use 'Retry attempt {count} of 10.' instead of Waiting for the {count} time". It's more grammatically correct since we're not doing '1st', '2nd', etc. * Maybe mention waiting still
2022-01-25FIX: disk layout: partprobe should be called and checked only for target ↵Victor Gavro
device (#896) * disk layout: partprobe should be called and checked only for target device * disk layout: partprobe: removed unnecessary bash subprocess
2022-01-25Removed last lsblk to grab PARTUUID (#901)Anton Hvornum
Co-authored-by: Anton Hvornum <anton.feeds@gmail.com>
2022-01-14Unified filesystem names by using get_mount_fs_type() function before ↵Anton Hvornum
.format() is called
2022-01-14Changed the default btrfs layout to have @ as /Anton Hvornum
2022-01-08partition.py: Use exit code for mkfs.fat exception (#853)Romain Goncalves
When using archinstall on an existing Arch Linux installation, (e.g. for migrating the current system on a new drive), no exception is raised if mkfs.vfat is missing in the base install (no dosfstools package currently installed).
2022-01-07Btrfs II (#838)Werner Llácer
* Btrfs with encrypted partitions. We have changed installer.mount_ordered_layout into a series of loops * open the encrypted devices * manage btrfs subvolumes * mount whatever * create kyefiles for encrypted volumes We have simplified the btrfs subvolume manager We merged the locale branch as it is needed here * We allow only the creation of keyfiles if the partition does not contain the root mount point. Also, adapt examples/only_hd to the new __init__.py Also, assorted flake8 warnings * Cleanup code * Naming schema for encrypted volumes revert global locale association (provisional) * We introduce the option of defining mount options in the partition dictionary. It has forced us to define two new entries in this dictionary: * format_options (formerly options) for mkfs options and * mount_options for mount -o ones. The different meaning of compress between partition and subvolumes is treated * Function lib/disk/btrfs.py mount_subvolume marked as deprecated Code cleanup. * format_options now filesystem.options * format_options now filesystem.format_options mount_options nof filesystem.mount_options * flake8 uncovered a slip in the code
2022-01-07Fix partition layout (#794)HTV04
* Fix partition layout * Tweaked the numbers to match the alignment of previous partitions. Co-authored-by: Anton Hvornum <anton.feeds@gmail.com>
2022-01-06Added type annotations to all functions (#845)Anton Hvornum
* Added type annotations for 1/5 of the files. There's bound to be some issues with type miss-match, will sort that out later. * Added type hints for 4/5 of the code * Added type hints for 4.7/5 of the code * Added type hints for 5/5 of the code base * Split the linters into individual files This should help with more clearly show which runner is breaking since they don't share a single common name any longer. Also moved mypy settings into pyproject.toml * Fixed some of the last flake8 issues * Missing parameter * Fixed invalid lookahead types * __future__ had to be at the top * Fixed last flake8 issues
2022-01-04Add prompt for /home partition (#801)HTV04
2021-12-31Btrfs2 (#787)Werner Llácer
* All the changes needed to make btrfs subvolumes work. It boils down to two points; the handling of the addressing of subvolumes re. physical partitions, and the small changes at the bootloader level * We added a new script only_hd for testing purposes. It only handles hadrd drive management * restoring an escape hatch during subvolume processing * hipercommented manage_btrfs_subvolumes * Ready to be able to select and process options in subvolume mounting * Separte nodatacow processing * Solving a flake8 complain * Use of bind names @ get_filesystem_type * compress mount option bypass * Preparations for encryption handling * Compatibility to master version re. encrypted btrfs volumes * Now we can create subvolumes and mountpoints inside an encrypted btrfs partition * changes for entries file generation with systemd-bootctl * flake8 corrections plus some comments Co-authored-by: Anton Hvornum <anton@hvornum.se>
2021-12-16Changed lsblk to blkid where possible (#802)Anton Hvornum
* Swapped lsblk for blkid * Added a hefty sleep on partprobe() And added a TODO for the future
2021-12-12Fixing possible race condition with partprobe (#796)Wilhelm Åkermark
* Update partition.py * Added sleep after partprobe Added sleep after partprobe. Without this tools such as lsblk may be unable to retrieve certain properties of devices (such as partuuid).
2021-12-02Add simple menu for better UX (#660)Daniel
* Add simple menu for better UX * Add remove external dependency * Fix harddisk return value on skip * Table output for partitioning process * Switch partitioning to simple menu * fixup! Switch partitioning to simple menu * Ignoring complexity and binary operator issues Only in simple_menu.py * Added license text to the MIT licensed file * Added in versioning information * Fixed some imports and removed the last generic_select() from user_interaction. Also fixed a revert/merged fork of ask_for_main_filesystem_format() * Update color scheme to match Arch style better * Use cyan as default cursor color * Leave simple menu the same Co-authored-by: Daniel Girtler <girtler.daniel@gmail.com> Co-authored-by: Anton Hvornum <anton.feeds+github@gmail.com> Co-authored-by: Dylan M. Taylor <dylan@dylanmtaylor.com>
2021-11-24Re-phrased btrfs subvolume question to only allow for a default layoutAnton Hvornum
2021-11-24Support encrypting multiple partitions (#759)Anton Hvornum
* Added support for storing disk encryption keyfiles and add them to a keyslot. * Added a luks2().add_key() function in order to inject a keyfile into a keyslot on a encrypted volume. * Simplified 'missing encryption password' logic in Filesystem(). Added a call to luks2().add_key() after the root-password is set on the volume, to add the keyfile in slot 2 * Adding in password handling in luks2().add_key(). It's required to enter a previous passphrase to unlock the volume and add a new keyslot. Also simplified the handling of partition in Installer().mount_ordered_layout() * Adding in encryption on all partitions except /boot when encryption is opted in * Removed setting size on Partition() as it's a read only value. No idea how Partition().size = size hasn't caused an issue before. Removed size=X argument to Partition() * Added a uniqueness to the loopdevice name. This should ensure that multiple encrypted volumes can be opened at the same time, except for Partition().detect_inner_filesystem() operations which can only happen one at a time since they share namespace. This should never be an issue since archinstall is single threaded and no concurrent operations can/should happen. * Added partprobe() as part of disk/helpers.py, added a /dev/ -> UUID mapper function called convert_device_to_uuid(path). Added a luks2().crypttab() function that sets up a /etc/crypttab entry. * Moved the responsability for telling archinstall to generate a keyfile from Filesystem() to user_interaction.py. This should in the future be a user-input based value, and not something the Filesystem() automatically dictates. * Added a retry mechanism to luks2().encrypt() to avoid having to re-start the installation when a device simply wasn't up yet. * Swapping UUID= lookup from loopdev to physdev.
2021-11-23Add accessibility packages to installed system if using the on the live ISO ↵Dylan M. Taylor
(#760) * Add group of accesibility tools * Conditionally extend base packages * Enable it if accessibility in use in guided * Fix circular import
2021-11-23Adding a warning when /boot is reasonably too small (#738)Anton Hvornum
* Moved convert_size_to_gb() into disk/helpers.py, Added a Partition().size property meta function. Using the .size value to check if /boot is too small which will raise an exception. The only drawback is that it's done post-formatting. This in order to catch scenarios where formatting isn't used. * Changed /boot warning from 0.15GB to 0.25GB * Changed the wording in the warning when /boot is too small.
2021-11-22Update filesystem.pyFirminator
just a few typos * label instead of labling * make UUID consistent
2021-11-22Make NTFS an advanced option (#753)Dylan M. Taylor
* Make NTFS an advanced option
2021-11-22NTFS Root Filesystem Support (#748)Dylan M. Taylor
* For fun, allow NTFS as a root filesystem type Add ability to format a filesystem as NTFS Try to force filesystem type Fix FAT mounting * Split out mount fs type method * Handle rootfstype on non-GRUB bootloaders * Add -Q to mkfs.ntfs command line for quick formatting * I believe this will fix GRUB with NTFS root * Remove the fsck hook if NTFS is used as the root partition * Looks like the string is ntfs3 not ntfs so this logic wasn't running
2021-11-22Simplified size definition in dict. (#752)Anton Hvornum
* Simplified size definition in dict. Also changed from MiB to MB and GiB to GB on places where they were used, as BlockDevice().size now returns GB by default, so no math operations needed * Appended the /boot offset to /root when specifying /home start.
2021-11-22Fix #746 - Can't create a filesystem on a new partition during the manual ↵Anton Hvornum
partitioning (#751) * Changed default value of info in largest_free_space() * Fixing bad assumption that a disk always contain a minimum of two partitions.
2021-11-19source code improvementSteven Lee
2021-11-18Adding a cmd_history.txt log under /var/log/archinstall/ (#737)Anton Hvornum
* Adding a cmd_history.txt log under /var/log/archinstall/ to get a clear picture of which commands was executed.
2021-11-18Added docstringAnton Hvornum
2021-11-18Reworked _safe_uuid() to be it's own function without timeouts.Anton Hvornum
2021-11-18Reworked the last uuid fix, and introduced _safe_uuid which does the same ↵Anton Hvornum
thing but handles the DisKerror. This way we can use it in more places.
2021-11-18Error handling when PARTUUID is missing during __repr__Anton Hvornum
2021-11-18Swapped .get() statement for a verification. This ensures Partition().uuid ↵Anton Hvornum
doesn't immediately return None
2021-11-18Increased disk delays by 100% (for unsuccessful operations), successful ↵Anton Hvornum
should still be quick. (#730) Co-authored-by: Anton Hvornum <anton.feeds@gmail.com>
2021-11-17Fixing broken encryption support in GRUB (#724)Anton Hvornum
* Added multiple `partprobe` calls and added a `.partprobe()` function on partitions, filesystem and blockdevice. * Adding retry attempts to all UUID related operations tied to the boot process * Tweaked logging for mounting and disk related operations * Removed potential SysCall exception disruptor causing exceptions to go by unnoticed * Increased the start position from 1MiB to 5MiB of /boot partition * Optimized the GRUB installation & config code * Improved Partition().uuid to never return None. Instead it will raise an exception if it can't get a PARTUUID within X retries with Y delay per attempt. * Increased sleep timer for partition uuid retrieval, because even with a 3 second sleep it wasn't long enough even on fast devices. * Make GRUB install to /dev/sda instead of /dev/sda1. * Added 10 retries for retreiving PARTUUID with a one second sleep. Instead of increasing the sleep simply add more retries until we find a good balance on slower disks.
2021-11-12Removed the GPT vs MBR lookup on __enter__ as it's no longer necessary to ↵Anton Hvornum
validate this on instance creation. load_layout() Uses this only to detect what partition table format it should use when wiping the drive. Other than that we only check if MBR and part numbers are > 3, that's the only use of this variable at this moment.
2021-11-11Converted partprobe call into a function.Anton Hvornum
2021-11-11Dealt with exception in partitionAnton Hvornum
2021-11-11Added a hard exception for when mount information can't be detectedAnton Hvornum
2021-11-11Added more debug output for get_mount_info()Anton Hvornum
2021-11-11Improved partition.uuid handling of lsblk informationAnton Hvornum