archlinux / archinstall

Arch Linux installer - guided, templates etc.
GNU General Public License v3.0
6.04k stars 522 forks source link

Error: 'Partition' object has no attribute 'create_subvolume' #1483

Closed jaysonwcs closed 12 months ago

jaysonwcs commented 1 year ago

Tried using the guided install today, but got this error. I was using an old Arch ISO, then I downloaded the current archinstall release and got this error. Then, I switched to the v2.5.1rc1 tag, but got the same error. Here's the log: install.log

Torxed commented 1 year ago

I'm wondering if it's because the partition is set to "wipe": false but you want it to setup a bunch of new subvolumes. And that it some how causes archinstall to have conflicting opinions on what the partition is (when using subvolumes it expects the object to be a BTRFSPartition, but is getting Partition because it's detected the current layout accordingly).

Aka, reusing btrfs partitions with subvolumes is not working as expected? Could that be it?

jaysonwcs commented 1 year ago

I will test setting the option wipe to true and report back soon.

jaysonwcs commented 1 year ago

Tried enabling wipe setting, now I got a different error:

This is your chosen configuration:
{
    "HSM": null,
    "__separator__": null,
    "additional-repositories": [
        "multilib"
    ],
    "archinstall-language": "English",
    "audio": "pipewire",
    "bootloader": "systemd-bootctl",
    "config_version": "2.5.1",
    "debug": false,
    "desktop-environment": "gnome",
    "gfx_driver": "VMware / VirtualBox (open-source)",
    "harddrives": [
        "/dev/vda"
    ],
    "hostname": "archlinux",
    "kernels": [
        "linux",
        "linux-lts"
    ],
    "keyboard-layout": "br-abnt2",
    "mirror-region": {
        "Brazil": {
            "http://archlinux-br.com.br/archlinux/$repo/os/$arch": true,
            "http://archlinux.c3sl.ufpr.br/$repo/os/$arch": true,
            "http://archlinux.pop-es.rnp.br/$repo/os/$arch": true,
            "http://br.mirror.archlinux-br.org/$repo/os/$arch": true,
            "http://linorg.usp.br/archlinux/$repo/os/$arch": true,
            "http://mirror.ufscar.br/archlinux/$repo/os/$arch": true,
            "https://archlinux-br.com.br/archlinux/$repo/os/$arch": true
        }
    },
    "nic": {
        "dhcp": true,
        "dns": null,
        "gateway": null,
        "iface": null,
        "ip": null,
        "type": "nm"
    },
    "no_pkg_lookups": false,
    "ntp": true,
    "offline": false,
    "packages": [
        "nano"
    ],
    "parallel downloads": 0,
    "profile": {
        "path": "/usr/lib/python3.10/site-packages/archinstall/profiles/desktop.py"
    },
    "save_config": null,
    "script": "guided",
    "silent": false,
    "swap": true,
    "sys-encoding": "UTF-8",
    "sys-language": "pt_BR.UTF-8",
    "timezone": "America/Sao_Paulo",
    "version": "2.5.1"
}
{
    "/dev/vda": {
        "partitions": [
            {
                "ESP": true,
                "PARTUUID": null,
                "boot": true,
                "encrypted": false,
                "filesystem": {
                    "format": "fat32"
                },
                "mountpoint": "/boot",
                "size": 1046528,
                "start": 2048,
                "type": "primary",
                "wipe": true
            },
            {
                "ESP": false,
                "PARTUUID": null,
                "boot": false,
                "encrypted": false,
                "filesystem": {
                    "format": "linux-swap"
                },
                "mountpoint": null,
                "size": 10485760,
                "start": 1048576,
                "type": "primary",
                "wipe": true
            },
            {
                "ESP": false,
                "PARTUUID": "1d698520-5058-49bb-98f7-2744e659267e",
                "boot": false,
                "btrfs": {
                    "subvolumes": [
                        {
                            "compress": true,
                            "mountpoint": "/",
                            "name": "@",
                            "nodatacow": false
                        },
                        {
                            "compress": true,
                            "mountpoint": "/home",
                            "name": "@home",
                            "nodatacow": false
                        },
                        {
                            "compress": true,
                            "mountpoint": "/root",
                            "name": "@user_root",
                            "nodatacow": false
                        }
                    ]
                },
                "encrypted": false,
                "filesystem": {
                    "format": "btrfs"
                },
                "mountpoint": null,
                "size": 93321216,
                "start": 11534336,
                "type": "primary",
                "wipe": true
            }
        ]
    }
}

Press Enter to continue.
 ! Formatting [BlockDevice(/dev/vda, size=50.0GB, free_space=1031kB+1032kB, bus_type=None)] in 5....4....3....2....1....
Adding partition to BlockDevice(/dev/vda, size=50.0GB, free_space=1031kB+1032kB, bus_type=None), 2048->1046528
Traceback (most recent call last):
  File "/usr/bin/archinstall", line 8, in <module>
    sys.exit(run_as_a_module())
  File "/usr/lib/python3.10/site-packages/archinstall/__init__.py", line 311, in run_as_a_module
    script.execute()
  File "/usr/lib/python3.10/site-packages/archinstall/lib/profiles.py", line 195, in execute
    self.spec.loader.exec_module(sys.modules[self.namespace])
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/usr/lib/python3.10/site-packages/archinstall/examples/guided.py", line 315, in <module>
    perform_filesystem_operations()
  File "/usr/lib/python3.10/site-packages/archinstall/examples/guided.py", line 130, in perform_filesystem_operations
    with archinstall.Filesystem(drive, mode) as fs:
  File "/usr/lib/python3.10/site-packages/archinstall/lib/disk/filesystem.py", line 44, in __exit__
    raise args[1]
  File "/usr/lib/python3.10/site-packages/archinstall/examples/guided.py", line 131, in perform_filesystem_operations
    fs.load_layout(archinstall.arguments['disk_layouts'][drive.path])
  File "/usr/lib/python3.10/site-packages/archinstall/lib/disk/filesystem.py", line 89, in load_layout
    partition['device_instance'] = self.add_partition(partition.get('type', 'primary'),
  File "/usr/lib/python3.10/site-packages/archinstall/lib/disk/filesystem.py", line 254, in add_partition
    if self.parted(parted_string):
  File "/usr/lib/python3.10/site-packages/archinstall/lib/disk/filesystem.py", line 204, in parted
    if (parted_handle := self.raw_parted(string)).exit_code == 0:
  File "/usr/lib/python3.10/site-packages/archinstall/lib/disk/filesystem.py", line 192, in raw_parted
    if (cmd_handle := SysCommand(f'/usr/bin/parted -s {string}')).exit_code != 0:
  File "/usr/lib/python3.10/site-packages/archinstall/lib/general.py", line 435, in __init__
    self.create_session()
  File "/usr/lib/python3.10/site-packages/archinstall/lib/general.py", line 486, in create_session
    with SysCommandWorker(
  File "/usr/lib/python3.10/site-packages/archinstall/lib/general.py", line 275, in __exit__
    raise SysCallError(f"{self.cmd} exited with abnormal exit code [{self.exit_code}]: {self._trace_log[-500:]}", self.exit_code, worker=self)
archinstall.lib.exceptions.SysCallError: ['/usr/bin/parted', '-s', '/dev/vda', 'mkpart', 'primary', 'fat32', '2048', '1046528'] exited with abnormal exit code [256]: b'Error: The location 1046528 is outside of the device /dev/vda.\r\n'
archinstall  5.02s user 4.64s system 2% cpu 6:19.31 total

Here is the log: install.log

Torxed commented 1 year ago

So as the error states: The location 1046528 is outside of the device /dev/vda The size of the device is smaller than of the size of the first partition:

    "size": 1046528,
    "start": 2048,
jaysonwcs commented 1 year ago

This is weird, I set the first partition to 0% 512MiB.

Torxed commented 1 year ago

humm, so boot starts early, at 2048. And it ends before the swap which is the second partition.

Boot End     Swap Start          Swap End        Root Start
1046528  <   1048576     <     10485760   <   10485760

So I'm not sure why it's complaining, how big is the /dev/vda? If you do a lsblk -b?

jaysonwcs commented 1 year ago

This is the result:

# lsblk -b
NAME   MAJ:MIN RM        SIZE RO TYPE MOUNTPOINTS
sr0     11:0    1   832909312  0 rom  /run/media/jayson/ARCH_202209
vda    254:0    0 53687091200  0 disk

It's a virtual disk I created using the command truncate -s 50G VMs/arch/Test2.img (the VMs folder is located on my home directory).

Torxed commented 1 year ago

That's how I create my VM images too. But the way you mount it is interesting. You don't happen to have the full QEMU string? Usually you can get it via debugging being turned on or in the log window of the VM provider.

That way I can emulate the exact setup and try here :)

btw: Thank you for the patience and willingness to supply debug info

jaysonwcs commented 1 year ago

I use Libvirt, but could found the string used inside the log. Here it is:

2022-09-26 17:36:30.182+0000: starting up libvirt version: 8.7.0, qemu version: 7.1.0, kernel: 5.19.11-arch1-1, hostname: Desktop.localdomain
LC_ALL=C \
PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/var/lib/snapd/snap/bin \
HOME=/var/lib/libvirt/qemu/domain-5-archlinux \
XDG_DATA_HOME=/var/lib/libvirt/qemu/domain-5-archlinux/.local/share \
XDG_CACHE_HOME=/var/lib/libvirt/qemu/domain-5-archlinux/.cache \
XDG_CONFIG_HOME=/var/lib/libvirt/qemu/domain-5-archlinux/.config \
/usr/bin/qemu-system-x86_64 \
-name guest=archlinux,debug-threads=on \
-S \
-object '{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/var/lib/libvirt/qemu/domain-5-archlinux/master-key.aes"}' \
-blockdev '{"driver":"file","filename":"/usr/share/edk2-ovmf/x64/OVMF_CODE.fd","node-name":"libvirt-pflash0-storage","auto-read-only":true,"discard":"unmap"}' \
-blockdev '{"node-name":"libvirt-pflash0-format","read-only":true,"driver":"raw","file":"libvirt-pflash0-storage"}' \
-blockdev '{"driver":"file","filename":"/var/lib/libvirt/qemu/nvram/archlinux_VARS.fd","node-name":"libvirt-pflash1-storage","auto-read-only":true,"discard":"unmap"}' \
-blockdev '{"node-name":"libvirt-pflash1-format","read-only":false,"driver":"raw","file":"libvirt-pflash1-storage"}' \
-machine pc-i440fx-7.1,usb=off,vmport=off,dump-guest-core=off,memory-backend=pc.ram,pflash0=libvirt-pflash0-format,pflash1=libvirt-pflash1-format \
-accel kvm \
-cpu host,migratable=on \
-m 4096 \
-object '{"qom-type":"memory-backend-memfd","id":"pc.ram","share":true,"x-use-canonical-path-for-ramblock-id":false,"size":4294967296}' \
-overcommit mem-lock=off \
-smp 8,sockets=8,cores=1,threads=1 \
-uuid 16ace08a-c4e0-45f9-b71b-1f9fe8f577ca \
-no-user-config \
-nodefaults \
-chardev socket,id=charmonitor,fd=35,server=on,wait=off \
-mon chardev=charmonitor,id=monitor,mode=control \
-rtc base=utc,driftfix=slew \
-global kvm-pit.lost_tick_policy=delay \
-no-hpet \
-no-shutdown \
-global PIIX4_PM.disable_s3=1 \
-global PIIX4_PM.disable_s4=1 \
-boot menu=on,strict=on \
-device '{"driver":"qemu-xhci","p2":15,"p3":15,"id":"usb","bus":"pci.0","addr":"0x5"}' \
-device '{"driver":"virtio-scsi-pci","id":"scsi0","bus":"pci.0","addr":"0xa"}' \
-device '{"driver":"ahci","id":"sata0","bus":"pci.0","addr":"0xb"}' \
-device '{"driver":"virtio-serial-pci","id":"virtio-serial0","bus":"pci.0","addr":"0x6"}' \
-blockdev '{"driver":"file","filename":"/data/ISOs/archlinux-2022.09.03-x86_64.iso","node-name":"libvirt-2-storage","auto-read-only":true,"discard":"unmap"}' \
-blockdev '{"node-name":"libvirt-2-format","read-only":true,"driver":"raw","file":"libvirt-2-storage"}' \
-device '{"driver":"ide-cd","bus":"sata0.0","drive":"libvirt-2-format","id":"sata0-0-0","bootindex":2}' \
-blockdev '{"driver":"file","filename":"/home/jayson/VMs/arch/Test2.img","node-name":"libvirt-1-storage","auto-read-only":true,"discard":"unmap"}' \
-blockdev '{"node-name":"libvirt-1-format","read-only":false,"driver":"raw","file":"libvirt-1-storage"}' \
-device '{"driver":"virtio-blk-pci","bus":"pci.0","addr":"0x7","drive":"libvirt-1-format","id":"virtio-disk0","bootindex":1}' \
-netdev tap,fd=38,vhost=on,vhostfd=40,id=hostnet0 \
-device '{"driver":"virtio-net-pci","netdev":"hostnet0","id":"net0","mac":"52:54:00:41:8d:c4","bus":"pci.0","addr":"0x3"}' \
-chardev pty,id=charserial0 \
-device '{"driver":"isa-serial","chardev":"charserial0","id":"serial0","index":0}' \
-chardev socket,id=charchannel0,fd=34,server=on,wait=off \
-device '{"driver":"virtserialport","bus":"virtio-serial0.0","nr":1,"chardev":"charchannel0","id":"channel0","name":"org.qemu.guest_agent.0"}' \
-chardev spicevmc,id=charchannel1,name=vdagent \
-device '{"driver":"virtserialport","bus":"virtio-serial0.0","nr":2,"chardev":"charchannel1","id":"channel1","name":"com.redhat.spice.0"}' \
-device '{"driver":"usb-tablet","id":"input0","bus":"usb.0","port":"1"}' \
-audiodev '{"id":"audio1","driver":"spice"}' \
-spice port=0,disable-ticketing=on,image-compression=off,gl=on,rendernode=/dev/dri/by-path/pci-0000:03:00.0-render,seamless-migration=on \
-device '{"driver":"virtio-vga-gl","id":"video0","max_outputs":1,"bus":"pci.0","addr":"0x2"}' \
-device '{"driver":"ich9-intel-hda","id":"sound0","bus":"pci.0","addr":"0x4"}' \
-device '{"driver":"hda-duplex","id":"sound0-codec0","bus":"sound0.0","cad":0,"audiodev":"audio1"}' \
-chardev spicevmc,id=charredir0,name=usbredir \
-device '{"driver":"usb-redir","chardev":"charredir0","id":"redir0","bus":"usb.0","port":"2"}' \
-chardev spicevmc,id=charredir1,name=usbredir \
-device '{"driver":"usb-redir","chardev":"charredir1","id":"redir1","bus":"usb.0","port":"3"}' \
-device '{"driver":"virtio-balloon-pci","id":"balloon0","bus":"pci.0","addr":"0x8"}' \
-object '{"qom-type":"rng-random","id":"objrng0","filename":"/dev/urandom"}' \
-device '{"driver":"virtio-rng-pci","rng":"objrng0","id":"rng0","bus":"pci.0","addr":"0x9"}' \
-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \
-msg timestamp=on
char device redirected to /dev/pts/0 (label charserial0)
gl_version 46 - core profile enabled
2022-09-26T18:35:47.412614Z qemu-system-x86_64: warning: console: no gl-unblock within one second
2022-09-26T18:35:47.412708Z qemu-system-x86_64: warning: spice: no gl-draw-done within one second
vrend_renderer_fill_caps: Entering with stale GL error: 1280
GLSL feature level 460
2022-09-26T20:17:37.549722Z qemu-system-x86_64: warning: console: no gl-unblock within one second
2022-09-26T20:17:37.573871Z qemu-system-x86_64: warning: spice: no gl-draw-done within one second
2022-09-26T20:17:38.644610Z qemu-system-x86_64: warning: spice: no gl-draw-done within one second
2022-09-26T20:49:04.568747Z qemu-system-x86_64: terminating on signal 15 from pid 36720 (/usr/bin/libvirtd)
2022-09-26 20:49:06.368+0000: shutting down, reason=shutdown

I can send the full log and the Libvirt XML used too, if you need them.

btw: no problem about sending debug info. I'm a programmer too, so I know how it's important to get these kind of info. =)

Torxed commented 1 year ago

Sweet thanks! I got everything I need there, the qemu-system-x86_64 startup string is all I need :) It's especially the -blockdev '{"driver":"file","filename":"/home/jayson/VMs/arch/Test2.img","node-name":"libvirt-1-storage","auto-read-only":true,"discard":"unmap"}'. Fun fact the /dev/vda devices gets emulated quite differently from virtio-scsi-pci, as vda is paravirtualized thus quicker but behaves less "natrual" to a standard scsi device. But I'll experiment and see what could be causing this issue.

NickNackGus commented 1 year ago

I just hit the stacktrace from the title of this bug report, but I'm getting it on real hardware instead of a VM - so different bugs past that point, I'm sure. Before I go wiping the relevant btrfs partition, I'm up for helping to debug why the original error occurred. My first guess is that an incorrect data type is found for unwiped BTRFS partitions when creating subvolumes. I'm out of time for tonight, but tomorrow I'd like to try logging the data type that doesn't have a create_subvolumes method, and where it comes from. Would that help diagnose the original issue? PXL_20230727_233423530

Torxed commented 1 year ago

@NickNackGus could you try with [testing] version, or even better git master version?

NickNackGus commented 1 year ago

I'll give it a go with git master tomorrow - I don't see a [testing] version, but if master will give better info, I won't worry about it.

NickNackGus commented 1 year ago

@NickNackGus could you try with [testing] version, or even better git master version?

One other thing - how confident are you that the main branch won't lose any data in partitions not marked to be wiped? This is my main computer, and I don't have a 3 2 1 backup system set up yet. I can unplug my backup drive as a precaution if you're unsure.

Torxed commented 1 year ago

I haven't tested master extensively since we changed to libparted, so I can't be certain of the outcome.

I haven't seen anything in the code that could be dangerous, but I would unplug the backup drive just to be sure.

NickNackGus commented 1 year ago

@Torxed It looks like the version on master doesn't accept the old disk layout config file, and doesn't let me mount an existing partition without wiping it? There is an option to set up the mount points externally and use that, but that's not really relevant.

Disk configuration -> Manual Partitioning -> select the relevant drive -> use arrow keys to highlight a partition -> enter -> the following options are shown regardless of partition type:

svartkanin commented 1 year ago

@NickNackGus that's correct, master has some breaking changes and the old configuration will not work anymore. The manual setup should however work as the previous versions

NickNackGus commented 1 year ago

So should I use that first option to mark the partition for formatting? It definitely sounds like that option isn't what I want, but I can't figure out how else to mount a partition without wiping it. If I can't get this sorted out with the version on master, I'd rather fall back to the version on the live CD, where I assume I can wipe just the root partition, since that's the only BTRFS partition I strictly need to mount for installation.

svartkanin commented 1 year ago

You would select the manual option, select your disk, and then mark whichever existing partitions for formatting. Would that not work for you?

NickNackGus commented 1 year ago

You would select the manual option, select your disk, and then mark whichever existing partitions for formatting. Would that not work for you? @svartkanin

That works for any partitions that I want to wipe and recreate, but not for partitions that have data I want to mount and keep their contents. For example, if I want to mount /home, and that already has all my files on it, I probably don't want to erase that, but I do want my files to appear when I log in after an install. I can get away with adding my backup partition and the like after installation. If I remember right, deleting everything on the EFI partition would wipe out the Windows boot entry from the UEFI as well, which would mean I'm stuck with my previous computer while I get things reinstalled and restored from backup.

So is there an option to mount without wiping during installation, or was that removed like it looks like? PXL_20230728_192302132.jpg

NickNackGus commented 1 year ago

Unless one of those options actually doesn't wipe the partition, there's some other option I can be directed towards that mounts without wiping, or there's another commit/branch that has such an option, I'm going to have to use the version that comes with the live CD, wiping the partitions containing / and /boot, and leaving everything else intact. Assuming doing that allows me to configure the subvolumes for / and /home, I can handle the rest through /etc/fstab later. I just don't have much more time to debug this right now.

svartkanin commented 12 months ago

This should be resolved in the latest version