Repository: archlinux/archinstall

Issue:
BTRFS with 2 different drives fails with Unable to add partition, most likely due to overlapping sectors: Can't have a partition outside the disk!
I have the latest version of the Arch ISO as of writing, and the archinstall script is manually updated to archinstall-2.6.2-1 via pacman in the live USB,

I'm trying to install Arch via the archinstall script on my machine (not through a VM), I have two SSDs (both DRAM-less) plugged in and I wish to use BTRFS for both of them with this configuration:
- The 120GB SSD will be used for the operating system alone
- The 480GB SSD will be used for the home folders

The script crashes when its formatting a partition on the 480GB SSD with the error: Unable to add partition, most likely due to overlapping sectors: Can't have a partition outside the disk!

Here is my user_configuration.json:
[user_configuration.json.txt](https://github.com/archlinux/archinstall/files/12762472/user_configuration.json.txt)

Here is my cmd_history.txt:
[cmd_history.txt](https://github.com/archlinux/archinstall/files/12762476/cmd_history.txt)

And here is my install.log:
[install.log](https://github.com/archlinux/archinstall/files/12762477/install.log)

Error: "archinstall.lib.exceptions.DiskError : Unable to determine new partition number: /dev/nvme1n1p1"
```
Hardware model detected: ASUS System Product Name; UEFI mode: True
Processor model detected: 12th Gen Intel(R) Core(TM) i5-12400F
Memory statistics: 31067744 available out of 32679152 total installed
Could not detect virtual system: ['/usr/bin/systemd-detect-virt'] exited with abnormal exit code [1]: none

System is not running in a VM: ['/usr/bin/systemd-detect-virt'] exited with abnormal exit code [1]: none

Virtualization detected: None; is VM: False
Graphics devices detected: dict_keys(['Advanced Micro Devices, Inc. [AMD/ATI] Navi 23 [Radeon RX 6600/6600 XT/6600M] (rev c1)'])
Disk states before installing: [
    {
        "children": [],
        "fsavail": 0,
        "fsroots": [
            "."
        ],
        "fstype": "squashfs",
        "fsuse_percentage": "100%",
        "fsver": "4.0",
        "log_sec": 512,
        "mountpoint": "/run/archiso/airootfs",
        "mountpoints": [
            "/run/archiso/airootfs"
        ],
        "name": "loop0",
        "partn": null,
        "parttype": null,
        "partuuid": null,
        "path": "/dev/loop0",
        "pkname": null,
        "pttype": null,
        "ptuuid": null,
        "rota": false,
        "size": "685 MiB",
        "tran": null,
        "type": "loop",
        "uuid": null
    },
    {
        "children": [
            {
                "children": [],
                "fsavail": null,
                "fsroots": [],
                "fstype": "vfat",
                "fsuse_percentage": null,
                "fsver": "FAT32",
                "log_sec": 512,
                "mountpoint": null,
                "mountpoints": [],
                "name": "sda1",
                "partn": 1,
                "parttype": "0xc",
                "partuuid": "0004a257-01",
                "path": "/dev/sda1",
                "pkname": "sda",
                "pttype": "dos",
                "ptuuid": "0004a257",
                "rota": true,
                "size": "14771 MiB",
                "tran": null,
                "type": "part",
                "uuid": "E239-F0DB"
            }
        ],
        "fsavail": null,
        "fsroots": [],
        "fstype": null,
        "fsuse_percentage": null,
        "fsver": null,
        "log_sec": 512,
        "mountpoint": null,
        "mountpoints": [],
        "name": "sda",
        "partn": null,
        "parttype": null,
        "partuuid": null,
        "path": "/dev/sda",
        "pkname": null,
        "pttype": "dos",
        "ptuuid": "0004a257",
        "rota": true,
        "size": "14772 MiB",
        "tran": "usb",
        "type": "disk",
        "uuid": null
    },
    {
        "children": [],
        "fsavail": null,
        "fsroots": [],
        "fstype": null,
        "fsuse_percentage": null,
        "fsver": null,
        "log_sec": 512,
        "mountpoint": null,
        "mountpoints": [],
        "name": "nvme1n1",
        "partn": null,
        "parttype": null,
        "partuuid": null,
        "path": "/dev/nvme1n1",
        "pkname": null,
        "pttype": null,
        "ptuuid": null,
        "rota": false,
        "size": "1907729 MiB",
        "tran": "nvme",
        "type": "disk",
        "uuid": null
    },
    {
        "children": [],
        "fsavail": null,
        "fsroots": [],
        "fstype": null,
        "fsuse_percentage": null,
        "fsver": null,
        "log_sec": 512,
        "mountpoint": null,
        "mountpoints": [],
        "name": "nvme0n1",
        "partn": null,
        "parttype": null,
        "partuuid": null,
        "path": "/dev/nvme0n1",
        "pkname": null,
        "pttype": null,
        "ptuuid": null,
        "rota": false,
        "size": "953869 MiB",
        "tran": "nvme",
        "type": "disk",
        "uuid": null
    }
]
Testing connectivity to the Arch Linux mirrors...
Suggesting multi-disk-layout for devices: /dev/nvme0n1, /dev/nvme1n1
/root: /dev/nvme0n1
/home: /dev/nvme1n1
Password strength: weak
 -- Chosen configuration --
{
    "__separator__": null,
    "additional-repositories": [],
    "archinstall-language": "English",
    "audio_config": null,
    "bootloader": "Systemd-boot",
    "config_version": "2.6.3",
    "debug": false,
    "disk_config": {
        "config_type": "default_layout",
        "device_modifications": [
            {
                "device": "/dev/nvme0n1",
                "partitions": [
                    {
                        "btrfs": [],
                        "dev_path": null,
                        "flags": [
                            "Boot",
                            "ESP"
                        ],
                        "fs_type": "fat32",
                        "mount_options": [],
                        "mountpoint": "/boot",
                        "obj_id": "c4630b8d-a5b8-4d32-8ba3-cd64005372c1",
                        "size": {
                            "sector_size": {
                                "unit": "B",
                                "value": 512
                            },
                            "unit": "MiB",
                            "value": 512
                        },
                        "start": {
                            "sector_size": {
                                "unit": "B",
                                "value": 512
                            },
                            "unit": "MiB",
                            "value": 1
                        },
                        "status": "create",
                        "type": "primary"
                    },
                    {
                        "btrfs": [],
                        "dev_path": null,
                        "flags": [],
                        "fs_type": "btrfs",
                        "mount_options": [
                            "compress=zstd"
                        ],
                        "mountpoint": "/",
                        "obj_id": "80fec0e9-4104-417e-8883-3065b61f3ddb",
                        "size": {
                            "sector_size": {
                                "unit": "B",
                                "value": 512
                            },
                            "unit": "B",
                            "value": 999666966528
                        },
                        "start": {
                            "sector_size": {
                                "unit": "B",
                                "value": 512
                            },
                            "unit": "MiB",
                            "value": 513
                        },
                        "status": "create",
                        "type": "primary"
                    }
                ],
                "wipe": true
            },
            {
                "device": "/dev/nvme1n1",
                "partitions": [
                    {
                        "btrfs": [],
                        "dev_path": null,
                        "flags": [],
                        "fs_type": "btrfs",
                        "mount_options": [
                            "compress=zstd"
                        ],
                        "mountpoint": "/home",
                        "obj_id": "50633bd0-0451-4583-941f-843f49d75ef5",
                        "size": {
                            "sector_size": {
                                "unit": "B",
                                "value": 512
                            },
                            "unit": "B",
                            "value": 2000397885440
                        },
                        "start": {
                            "sector_size": {
                                "unit": "B",
                                "value": 512
                            },
                            "unit": "MiB",
                            "value": 1
                        },
                        "status": "create",
                        "type": "primary"
                    }
                ],
                "wipe": true
            }
        ]
    },
    "disk_encryption": null,
    "hostname": "archlinux",
    "kernels": [
        "linux"
    ],
    "locale_config": {
        "kb_layout": "us",
        "sys_enc": "UTF-8",
        "sys_lang": "en_US"
    },
    "mirror_config": null,
    "network_config": {},
    "no_pkg_lookups": false,
    "ntp": true,
    "offline": false,
    "packages": [],
    "parallel downloads": 0,
    "profile_config": null,
    "save_config": null,
    "script": "guided",
    "silent": false,
    "swap": true,
    "timezone": "UTC",
    "version": "2.6.3"
}
Unmounting all existing partitions: /dev/nvme0n1
Wiping partitions and metadata: /dev/nvme0n1
Creating partitions: /dev/nvme0n1
	Type: primary
	Filesystem: fat32
	Geometry: 2048 start sector, 1048576 length
	Type: primary
	Filesystem: btrfs
	Geometry: 1050624 start sector, 1952474544 length
Calling partprobe: partprobe /dev/nvme0n1
Unmounting all existing partitions: /dev/nvme0n1
Formatting filesystem: /usr/bin/mkfs.fat -F32 /dev/nvme0n1p1
Calling partprobe: partprobe /dev/nvme0n1p1
partition information found: {'name': 'nvme0n1p1', 'path': '/dev/nvme0n1p1', 'pkname': 'nvme0n1', 'size': '512 MiB', 'log_sec': 512, 'pttype': 'gpt', 'ptuuid': 'c5e438eb-ebf0-409d-9537-b052e2b4cb4d', 'rota': False, 'tran': 'nvme', 'partn': 1, 'partuuid': 'd4edc0fe-0d02-4ace-bb56-d566ded56e19', 'parttype': 'c12a7328-f81f-11d2-ba4b-00a0c93ec93b', 'uuid': 'DD60-E3BE', 'fstype': 'vfat', 'fsver': 'FAT32', 'fsavail': None, 'fsuse_percentage': None, 'type': 'part', 'mountpoint': None, 'mountpoints': [], 'fsroots': [], 'children': []}
Formatting filesystem: /usr/bin/mkfs.btrfs -f /dev/nvme0n1p2
Calling partprobe: partprobe /dev/nvme0n1p2
partition information found: {'name': 'nvme0n1p2', 'path': '/dev/nvme0n1p2', 'pkname': 'nvme0n1', 'size': '953356 MiB', 'log_sec': 512, 'pttype': 'gpt', 'ptuuid': 'c5e438eb-ebf0-409d-9537-b052e2b4cb4d', 'rota': False, 'tran': 'nvme', 'partn': 2, 'partuuid': '613678fb-3aaa-4fad-91eb-00dda9de4051', 'parttype': '0fc63daf-8483-4772-8e79-3d69d8477de4', 'uuid': 'b42bd5a8-a0f7-498a-8d63-5a64bb6058f0', 'fstype': 'btrfs', 'fsver': None, 'fsavail': None, 'fsuse_percentage': None, 'type': 'part', 'mountpoint': None, 'mountpoints': [], 'fsroots': [], 'children': []}
Creating subvolumes: /dev/nvme0n1p2
Mounting /dev/nvme0n1p2: mount /dev/nvme0n1p2 /mnt/arch_btrfs
Partition /dev/nvme0n1p2 is currently mounted at: ['/mnt/arch_btrfs']
Unmounting mountpoint: /mnt/arch_btrfs
Unmounting all existing partitions: /dev/nvme1n1
Wiping partitions and metadata: /dev/nvme1n1
Creating partitions: /dev/nvme1n1
	Type: primary
	Filesystem: btrfs
	Geometry: 2048 start sector, 3907027120 length
Calling partprobe: partprobe /dev/nvme1n1
Unmounting all existing partitions: /dev/nvme1n1
Formatting filesystem: /usr/bin/mkfs.btrfs -f /dev/nvme1n1p1
Calling partprobe: partprobe /dev/nvme1n1p1
Calling partprobe: partprobe /dev/nvme1n1p1
Calling partprobe: partprobe /dev/nvme1n1p1
Calling partprobe: partprobe /dev/nvme1n1p1
Unable to determine new partition number: /dev/nvme1n1p1
LsblkInfo(name='nvme1n1p1', path=PosixPath('/dev/nvme1n1p1'), pkname='nvme1n1', size=Size(value=2000397885440, unit=<Unit.B: 1>, sector_size=SectorSize(value=512, unit=<Unit.B: 1>)), log_sec=512, pttype='gpt', ptuuid='09a95aaa-600c-4f5d-b6e2-ef1d30e292cf', rota=False, tran='nvme', partn=None, partuuid=None, parttype=None, uuid='58bd78c5-c84a-4d47-bdb8-f0256188ac2d', fstype='btrfs', fsver=None, fsavail=None, fsuse_percentage=None, type='part', mountpoint=None, mountpoints=[], fsroots=[], children=[])
```


Discussion:
I'm having the same issue.
I have the same issue as well
did someone find the solution to that issue?
Any news about this? I'm always ready to test any commit / patch.
There will be an update to this ticket - when there's any news about it :)

Resolving patch:
diff --git a/archinstall/lib/interactions/disk_conf.py b/archinstall/lib/interactions/disk_conf.py
--- a/archinstall/lib/interactions/disk_conf.py
+++ b/archinstall/lib/interactions/disk_conf.py
@@ -175,9 +175,9 @@ def select_disk_config(
 	return None
 
 
-def _boot_partition(sector_size: disk.SectorSize) -> disk.PartitionModification:
+def _boot_partition(sector_size: disk.SectorSize, using_gpt: bool) -> disk.PartitionModification:
 	flags = [disk.PartitionFlag.Boot]
-	if SysInfo.has_uefi():
+	if using_gpt:
 		start = disk.Size(1, disk.Unit.MiB, sector_size)
 		size = disk.Size(512, disk.Unit.MiB, sector_size)
 		flags.append(disk.PartitionFlag.ESP)
@@ -241,6 +241,8 @@ def suggest_single_disk_layout(
 
 	device_modification = disk.DeviceModification(device, wipe=True)
 
+	using_gpt = SysInfo.has_uefi()
+
 	# Used for reference: https://wiki.archlinux.org/title/partitioning
 	# 2 MiB is unallocated for GRUB on BIOS. Potentially unneeded for other bootloaders?
 
@@ -252,7 +254,7 @@ def suggest_single_disk_layout(
 	# Also re-align the start to 1MiB since we don't need the first sectors
 	# like we do in MBR layouts where the boot loader is installed traditionally.
 
-	boot_partition = _boot_partition(sector_size)
+	boot_partition = _boot_partition(sector_size, using_gpt)
 	device_modification.add_partition(boot_partition)
 
 	if not using_subvolumes:
@@ -266,20 +268,25 @@ def suggest_single_disk_layout(
 			else:
 				using_home_partition = False
 
+	align_buffer = disk.Size(1, disk.Unit.MiB, sector_size)
+
 	# root partition
-	start = disk.Size(513, disk.Unit.MiB, sector_size) if SysInfo.has_uefi() else disk.Size(206, disk.Unit.MiB, sector_size)
+	root_start = boot_partition.start + boot_partition.length
 
 	# Set a size for / (/root)
 	if using_subvolumes or device_size_gib < min_size_to_allow_home_part or not using_home_partition:
-		length = device.device_info.total_size - start
+		root_length = device.device_info.total_size - root_start
 	else:
-		length = min(device.device_info.total_size, root_partition_size)
+		root_length = min(device.device_info.total_size, root_partition_size)
+
+	if using_gpt and not using_home_partition:
+		root_length -= align_buffer
 
 	root_partition = disk.PartitionModification(
 		status=disk.ModificationStatus.Create,
 		type=disk.PartitionType.Primary,
-		start=start,
-		length=length,
+		start=root_start,
+		length=root_length,
 		mountpoint=Path('/') if not using_subvolumes else None,
 		fs_type=filesystem_type,
 		mount_options=['compress=zstd'] if compression else [],
@@ -302,14 +309,17 @@ def suggest_single_disk_layout(
 		# If we don't want to use subvolumes,
 		# But we want to be able to re-use data between re-installs..
 		# A second partition for /home would be nice if we have the space for it
-		start = root_partition.length
-		length = device.device_info.total_size - root_partition.length
+		home_start = root_partition.length
+		home_length = device.device_info.total_size - root_partition.length
+
+		if using_gpt:
+			home_length -= align_buffer
 
 		home_partition = disk.PartitionModification(
 			status=disk.ModificationStatus.Create,
 			type=disk.PartitionType.Primary,
-			start=start,
-			length=length,
+			start=home_start,
+			length=home_length,
 			mountpoint=Path('/home'),
 			fs_type=filesystem_type,
 			mount_options=['compress=zstd'] if compression else []
@@ -376,17 +386,21 @@ def suggest_multi_disk_layout(
 	root_device_sector_size = root_device_modification.device.device_info.sector_size
 	home_device_sector_size = home_device_modification.device.device_info.sector_size
 
+	root_align_buffer = disk.Size(1, disk.Unit.MiB, root_device_sector_size)
+	home_align_buffer = disk.Size(1, disk.Unit.MiB, home_device_sector_size)
+
+	using_gpt = SysInfo.has_uefi()
+
 	# add boot partition to the root device
-	boot_partition = _boot_partition(root_device_sector_size)
+	boot_partition = _boot_partition(root_device_sector_size, using_gpt)
 	root_device_modification.add_partition(boot_partition)
 
-	if SysInfo.has_uefi():
-		root_start = disk.Size(513, disk.Unit.MiB, root_device_sector_size)
-	else:
-		root_start = disk.Size(206, disk.Unit.MiB, root_device_sector_size)
-
+	root_start = boot_partition.start + boot_partition.length
 	root_length = root_device.device_info.total_size - root_start
 
+	if using_gpt:
+		root_length -= root_align_buffer
+
 	# add root partition to the root device
 	root_partition = disk.PartitionModification(
 		status=disk.ModificationStatus.Create,
@@ -399,15 +413,18 @@ def suggest_multi_disk_layout(
 	)
 	root_device_modification.add_partition(root_partition)
 
-	start = disk.Size(1, disk.Unit.MiB, home_device_sector_size)
-	length = home_device.device_info.total_size - start
+	home_start = home_align_buffer
+	home_length = home_device.device_info.total_size - home_start
+
+	if using_gpt:
+		home_length -= home_align_buffer
 
 	# add home partition to home device
 	home_partition = disk.PartitionModification(
 		status=disk.ModificationStatus.Create,
 		type=disk.PartitionType.Primary,
-		start=start,
-		length=length,
+		start=home_start,
+		length=home_length,
 		mountpoint=Path('/home'),
 		mount_options=['compress=zstd'] if compression else [],
 		fs_type=filesystem_type,


Test patch: