archinstall icon indicating copy to clipboard operation
archinstall copied to clipboard

"Unable to determine new uuid" error when installing archinstall

Open coreknee opened this issue 2 years ago • 51 comments

im having a "Unable to determine new uuid" error when installing archinstall heres the logs

coreknee avatar Dec 17 '23 13:12 coreknee

The device wiping logic and/or udev synchronization could be the cause of the issue. Adding logging for the output of the mkfs command may provide additional information.

Log analysis

I see two runs in the log. On the first run it worked!

Formatting filesystem: /usr/bin/mkfs.btrfs -f /dev/nvme0n2p2
partition information found: {'name': 'nvme0n2p2', 'path': '/dev/nvme0n2p2', 'pkname': 'nvme0n2', 'size': '130558 MiB', 'log_sec': 512, 'pttype': 'gpt', 'ptuuid': 'f545e03c-428a-44df-87cc-e8525a70481a', 'rota': False, 'tran': 'nvme', 'partn': 2, 'partuuid': '2f533a5d-d865-4fe3-bcab-b190dcb6cfd4', 'parttype': '0fc63daf-8483-4772-8e79-3d69d8477de4', 'uuid': '0a07e1aa-ea2e-4769-b761-3fe33c6564be', 'fstype': 'btrfs', 'fsver': None, 'fsavail': None, 'fsuse_percentage': None, 'type': 'part', 'mountpoint': None, 'mountpoints': [], 'fsroots': [], 'children': []}

Then on the second it did not.

Formatting filesystem: /usr/bin/mkfs.btrfs -f /dev/nvme0n2p2
Unable to determine new uuid: /dev/nvme0n2p2
LsblkInfo(name='nvme0n2p2', path=PosixPath('/dev/nvme0n2p2'), pkname='nvme0n2', size=Size(value=136899985408, unit=<Unit.B: 1>, sector_size=SectorSize(value=512, unit=<Unit.B: 1>)), log_sec=512, pttype='gpt', ptuuid='6866456c-50d0-407d-9d9c-1ac8c97f60a2', rota=False, tran='nvme', partn=2, partuuid='082cb0b3-4695-49f6-880b-20c5d6b1e785', parttype='0fc63daf-8483-4772-8e79-3d69d8477de4', uuid=None, fstype=None, fsver=None, fsavail=None, fsuse_percentage=None, type='part', mountpoint=None, mountpoints=[], fsroots=[], children=[])

This is the same error seen in the log provided by @LeviSnoot in https://github.com/archlinux/archinstall/issues/2286#issuecomment-1845094905.

Formatting filesystem: /usr/bin/mkfs.btrfs -f /dev/nvme1n1p2
Unable to determine new uuid: /dev/nvme1n1p2
LsblkInfo(name='nvme1n1p2', path=PosixPath('/dev/nvme1n1p2'), pkname='nvme1n1', size=Size(value=999666221056, unit=<Unit.B: 1>, sector_size=SectorSize(value=512, unit=<Unit.B: 1>)), log_sec=512, pttype='gpt', ptuuid='480527ce-2a5b-442b-bf40-e8efaf6e17f8', rota=False, tran='nvme', partn=2, partuuid='b9e6eeb3-1fda-4dbd-8024-028323825766', parttype='0fc63daf-8483-4772-8e79-3d69d8477de4', uuid=None, fstype=None, fsver=None, fsavail=None, fsuse_percentage=None, type='part', mountpoint=None, mountpoints=[], fsroots=[], children=[])

It should be noted that the issue title of #2286 states partition UUID while this issue is for UUID. A partition UUID [1] is related to partitioning GPT disks specifically and UUID is related to formatting and filesystems [2].

Device wiping logic

The logic for wiping a device must come from the pyparted example make_one_primary_partition.py.

https://github.com/archlinux/archinstall/blob/f107104103b74ac065a56bd94a0878f0d263e177/archinstall/lib/disk/device_handler.py#L658-L661

https://github.com/archlinux/archinstall/blob/f107104103b74ac065a56bd94a0878f0d263e177/archinstall/lib/disk/device_handler.py#L642-L649

This will not work for Btrfs because the offset of the filesystem signature 0x10040 (or 65600 bytes) is not within the bytearray(1024). The wipefs command can be used to observe this. [3]

Demonstration
# lsblk name,fstype,uuid /dev/vdb
NAME   FSTYPE UUID
vdb
├─vdb1 vfat   E33B-EDB2
└─vdb2 btrfs  a7051e7b-d853-486b-b7bb-e051a0e07e9d
# wipefs /dev/vdb2
DEVICE OFFSET  TYPE  UUID				  LABEL
vdb2   0x10040 btrfs a7051e7b-d853-486b-b7bb-e051a0e07e9d
# printf "%d\n" 0x10040
65600
# python
Python 3.11.6 (main, Nov 14 2023, 09:36:21) [GCC 13.2.1 20230801] on linux
Type "help", "copyright", "credits" or "license" for more information.
with open('/dev/vdb2','wb') as p:
	p.write(bytearray(1024))
...
1024
>>>
# lsblk name,fstype,uuid /dev/vdb
NAME   FSTYPE UUID
vdb
├─vdb1 vfat   E33B-EDB2
└─vdb2 btrfs  a7051e7b-d853-486b-b7bb-e051a0e07e9d
# wipefs /dev/vdb2
DEVICE OFFSET  TYPE  UUID				  LABEL
vdb2   0x10040 btrfs a7051e7b-d853-486b-b7bb-e051a0e07e9d
# wipefs -a /dev/vdb2
/dev/vdb2: 8 bytes were erased at offset 0x00010040 (btrfs): 5f 42 48 52 66 53 5f 4d
# lsblk name,fstype,uuid /dev/vdb
NAME   FSTYPE UUID
vdb
├─vdb1 vfat   E33B-EDB2
└─vdb2
# wipefs /dev/vdb2
# exit

Notice in the demonstration that the UUID and offset remained after the write done in python. Following the same steps in the demonstration above but substituting in the EFI system partition (/dev/vdb1 in the example) will yield different results and the UUID and offset will not show after the write done in python. Why? The furthest out offset for that filesystem signature is 0x1fe (or 510 bytes) within the range of the bytearray(1024). Test and see! This shows that the code for wiping works when the offset is within the first 1024 bytes but not if it is outside of that range. Any filesystem with an offset outside this range will also have this problem.

A GUID Partition Table has a backup GPT header at the end of the disk, the offset for the backup GPT header can also be seen in the output of wipefs. This is not getting wiped with the current logic.

To overcome this wipefs can be used instead of writing a bytearray.

Synchronize with udev

The following is from the description of lsblk(8). [4]

Note that lsblk might be executed in time when udev does not have all information about recently added or modified devices yet. In this case it is recommended to use udevadm settle before lsblk to synchronize with udev.

When partitioning and formatting take place during an install there will be at least one recently modified device; udevadm settle is not being used as recommended.

Log format utility output

The output from the mkfs utility might be helpful. Notice in the sample output of the mkfs.btrfs command below that the UUID is included.

Sample command and output
# mkfs.btrfs /dev/vdb2
btrfs-progs v6.6.2
See https://btrfs.readthedocs.io for more information.

Performing full device TRIM /dev/vdb2 (19.50GiB) ...
NOTE: several default settings have changed in version 5.15, please make sure
      this does not affect your deployments:
      - DUP for metadata (-m dup)
      - enabled no-holes (-O no-holes)
      - enabled free-space-tree (-R free-space-tree)

Label:              (null)
UUID:               a7051e7b-d853-486b-b7bb-e051a0e07e9d
Node size:          16384
Sector size:        4096
Filesystem size:    19.50GiB
Block group profiles:
  Data:             single            8.00MiB
  Metadata:         DUP             256.00MiB
  System:           DUP               8.00MiB
SSD detected:       no
Zoned device:       no
Incompat features:  extref, skinny-metadata, no-holes, free-space-tree
Runtime features:   free-space-tree
Checksum:           crc32c
Number of devices:  1
Devices:
   ID        SIZE  PATH     
    1    19.50GiB  /dev/vdb2

What is the output when the error this issue reports is raised? If the output of this command was logged then it could be examined in this case, but it is not.

References

[1] https://wiki.archlinux.org/title/Persistent_block_device_naming#by-partuuid [2] https://wiki.archlinux.org/title/Persistent_block_device_naming#by-uuid [3] https://man.archlinux.org/man/wipefs.8 [4] https://man.archlinux.org/man/lsblk.8#DESCRIPTION

codefiles avatar Dec 17 '23 20:12 codefiles

Anyone that can reproduce this error that can try this simple patch?

diff --git a/archinstall/lib/disk/device_handler.py b/archinstall/lib/disk/device_handler.py
index fcf52013..ade8163b 100644
--- a/archinstall/lib/disk/device_handler.py
+++ b/archinstall/lib/disk/device_handler.py
@@ -316,6 +316,7 @@ class DeviceHandler(object):
                        else:
                                self._perform_formatting(part_mod.safe_fs_type, part_mod.safe_dev_path)

+                       SysCommand('udevadm settle')
                        lsblk_info = self._fetch_part_info(part_mod.safe_dev_path)

                        part_mod.partn = lsblk_info.partn

codefiles avatar Dec 18 '23 00:12 codefiles

Any updates on this? That patch doesn't fix it for me.

ghost avatar Dec 25 '23 10:12 ghost

I have a few patches I will submit once merge activity for the repo picks back up. Other than that there is no update and if nothing new is posted here then that means nothing has changed.

codefiles avatar Dec 29 '23 15:12 codefiles

I just wanted to add that I also encountered this issue and I hope it gets resolved. I tried to work around it by not formatting any btrfs partitions but I encountered a different issue #2317 .

benduckwdesign avatar Dec 31 '23 20:12 benduckwdesign

With the logs submitted so far, the UUID is not able to be determined for a partition formatted as Btrfs when a Btrfs file system was previously present at the same device path, which can be seen in the Disk states before installing portion of the logs. This appears to support the information I provided regarding the device wiping logic.

It would be helpful if anyone that can reproduce this issue could test the following simple patch.

diff --git a/archinstall/lib/disk/device_handler.py b/archinstall/lib/disk/device_handler.py
index fcf52013..eb5163b0 100644
--- a/archinstall/lib/disk/device_handler.py
+++ b/archinstall/lib/disk/device_handler.py
@@ -655,10 +655,9 @@ class DeviceHandler(object):
                auto-discovery tools don't recognize anything here.
                """
                info(f'Wiping partitions and metadata: {block_device.device_info.path}')
-               for partition in block_device.partition_infos:
-                       self._wipe(partition.path)
-
-               self._wipe(block_device.device_info.path)
+               paths = [str(part.path) for part in block_device.partition_infos]
+               paths.append(str(block_device.device_info.path))
+               SysCommand(['wipefs', '--all'] + paths)


 device_handler = DeviceHandler()

codefiles avatar Jan 03 '24 00:01 codefiles

Is there a way i can use archinstall right now?

Pacific6938 avatar Jan 05 '24 00:01 Pacific6938

Is there a way i can use archinstall right now?

You can try the patch from @codefiles https://github.com/archlinux/archinstall/issues/2305#issuecomment-1874724212

svartkanin avatar Jan 05 '24 00:01 svartkanin

I don't know how I can apply the patch to the archinstall script

Pacific6938 avatar Jan 05 '24 11:01 Pacific6938

I don't know how I can apply the patch to the archinstall script

The easiest way to test the logic of the patch would be to run a wipefs -a device command before the archinstall command, where device is the device from the error message. In #2322 your error message was Unable to determine new uuid: /dev/nvme0n1p2 so try wipefs -a /dev/nvme0n1p2. That should be sufficient to test what the patch does with the least amount of trouble, please report back.

codefiles avatar Jan 06 '24 14:01 codefiles

I don't think it worked as I understood you you said running wipefs -a /dev... should have the same affect as your fix but it didn't work for me. Just checking https://0x0.st/H60v.log (Other distros work so my hardware shouldn't be broken)

Pacific6938 avatar Jan 06 '24 15:01 Pacific6938

It looks like you understood just fine. This is from the log under the Disk states before installing portion of the first run.

            {
                ...
                "fstype": "vfat",
                ...
                "partuuid": "42ab6fc9-2917-4840-83b7-54437ef72b80",
                "path": "/dev/nvme0n1p1",
                ...
                "uuid": "C49A-C194"
            },
            {
                ...
                "fstype": null,
                ...
                "partuuid": "93b2c2c3-e841-4aab-a9e4-11a3dd535b59",
                "path": "/dev/nvme0n1p2",
                ...
                size": "1024 MiB",
                ...
                "uuid": null
            },
            {
                ...
                "fstype": "btrfs",
                ...
                "partuuid": "8222a227-f888-429f-943f-2beefb6ee1e4",
                "path": "/dev/nvme0n1p3",
                ...
                "size": "1906104 MiB",
                ...
                "uuid": "f7802a0f-a52c-4e6f-ac3e-0b2c15ac432e"
            }

The fstype of /dev/nvme01p2 is null and so is the uuid, that shows that you did the wipefs command correctly.

Could you also try wipefs -a /dev/nvme0n1* before the archinstall command?

codefiles avatar Jan 06 '24 16:01 codefiles

Still doesn't seem to work https://0x0.st/H6GW.log

Pacific6938 avatar Jan 06 '24 16:01 Pacific6938

Could you run lsblk -n -o uuid /dev/nvme0n1p2 after that combination of commands and then the error message? Do you get any output?

codefiles avatar Jan 06 '24 16:01 codefiles

PXL_20240106_163342284

Pacific6938 avatar Jan 06 '24 16:01 Pacific6938

Could you run the lsblk command right after getting the error message?

codefiles avatar Jan 06 '24 16:01 codefiles

PXL_20240106_164010214

Pacific6938 avatar Jan 06 '24 16:01 Pacific6938

Now do precisely this:

wipefs -a /dev/nvme0n1p2
mkfs.btrfs /dev/nvme0n1p2
lsblk -n -o uuid /dev/nvme0n1p2

What is the output of lsblk now?

codefiles avatar Jan 06 '24 16:01 codefiles

PXL_20240106_164429679

Pacific6938 avatar Jan 06 '24 16:01 Pacific6938

Thank you so much @Schweeeeeeeeeeeeeeee! You have verified that #2211 is correct for this issue. We can see you clearly can trigger the error but when the commands above are supplied there is no problem with getting the uuid.

~This leads me back to https://github.com/archlinux/archinstall/issues/2305#issuecomment-1859350259. To manually apply the patch from that comment, on the live ISO edit the file /usr/lib/python3.11/site-packages/archinstall/lib/disk/device_handler.py and add SysCommand('udevadm settle') on the line above line number 319 which is lsblk_info = self._fetch_part_info(part_mod.safe_dev_path), use the same indentation as this line. Then save the file and run wipefs -a nvme0n1* followed by archinstall.~ That cannot be it, you showed that the uuid is not available in https://github.com/archlinux/archinstall/issues/2305#issuecomment-1879750786.

codefiles avatar Jan 06 '24 17:01 codefiles