From b3dafb250b1925c35342b1a81d3433bfd7ad8574 Mon Sep 17 00:00:00 2001 From: Michael Hudson-Doyle Date: Mon, 24 Jul 2023 12:18:05 +1200 Subject: [PATCH] fix detection of mounted partitions Even if we are going to ignore a mountpoint, we still need to process its children... Add machine config where the installer is running from a partition of a disk you might want to install to, and an api test. --- examples/machines/booted-from-rp.json | 1219 +++++++++++++++++++++++++ subiquity/models/filesystem.py | 5 +- subiquity/tests/api/test_api.py | 14 + 3 files changed, 1237 insertions(+), 1 deletion(-) create mode 100644 examples/machines/booted-from-rp.json diff --git a/examples/machines/booted-from-rp.json b/examples/machines/booted-from-rp.json new file mode 100644 index 00000000..9209a612 --- /dev/null +++ b/examples/machines/booted-from-rp.json @@ -0,0 +1,1219 @@ +{ + "network": { + "links": [ + { + "addresses": [ + { + "address": "10.0.2.15/24", + "family": 2, + "scope": "global", + "source": "dhcp" + }, + { + "address": "fec0::5054:ff:fe12:3456/64", + "family": 10, + "scope": "site", + "source": "dhcp" + }, + { + "address": "fe80::5054:ff:fe12:3456/64", + "family": 10, + "scope": "link", + "source": "static" + } + ], + "bond": { + "is_master": false, + "is_slave": false, + "lacp_rate": null, + "master": null, + "mode": null, + "slaves": [], + "xmit_hash_policy": null + }, + "bridge": { + "interfaces": [], + "is_bridge": false, + "is_port": false, + "options": {} + }, + "netlink_data": { + "arptype": 1, + "family": 0, + "flags": 69699, + "ifindex": 2, + "is_vlan": false, + "name": "ens3" + }, + "type": "eth", + "udev_data": { + "CURRENT_TAGS": ":systemd:", + "DEVPATH": "/devices/pci0000:00/0000:00:03.0/virtio0/net/ens3", + "ID_BUS": "pci", + "ID_MM_CANDIDATE": "1", + "ID_MODEL_FROM_DATABASE": "Virtio network device", + "ID_MODEL_ID": "0x1000", + "ID_NET_DRIVER": "virtio_net", + "ID_NET_LINK_FILE": "/usr/lib/systemd/network/99-default.link", + "ID_NET_NAME": "ens3", + "ID_NET_NAME_MAC": "enx525400123456", + "ID_NET_NAME_PATH": "enp0s3", + "ID_NET_NAME_SLOT": "ens3", + "ID_NET_NAMING_SCHEME": "v252", + "ID_PATH": "pci-0000:00:03.0", + "ID_PATH_TAG": "pci-0000_00_03_0", + "ID_PCI_CLASS_FROM_DATABASE": "Network controller", + "ID_PCI_SUBCLASS_FROM_DATABASE": "Ethernet controller", + "ID_VENDOR_FROM_DATABASE": "Red Hat, Inc.", + "ID_VENDOR_ID": "0x1af4", + "IFINDEX": "2", + "INTERFACE": "ens3", + "SUBSYSTEM": "net", + "SYSTEMD_ALIAS": "/sys/subsystem/net/devices/ens3", + "TAGS": ":systemd:", + "USEC_INITIALIZED": "1748300", + "attrs": { + "addr_assign_type": "0", + "addr_len": "6", + "address": "52:54:00:12:34:56", + "broadcast": "ff:ff:ff:ff:ff:ff", + "carrier": "1", + "carrier_changes": "2", + "carrier_down_count": "1", + "carrier_up_count": "1", + "dev_id": "0x0", + "dev_port": "0", + "device": null, + "dormant": "0", + "duplex": "unknown", + "flags": "0x1003", + "gro_flush_timeout": "0", + "ifalias": "", + "ifindex": "2", + "iflink": "2", + "link_mode": "0", + "mtu": "1500", + "name_assign_type": "4", + "napi_defer_hard_irqs": "0", + "netdev_group": "0", + "operstate": "up", + "phys_port_id": null, + "phys_port_name": null, + "phys_switch_id": null, + "power/async": "disabled", + "power/autosuspend_delay_ms": null, + "power/control": "auto", + "power/runtime_active_kids": "0", + "power/runtime_active_time": "0", + "power/runtime_enabled": "disabled", + "power/runtime_status": "unsupported", + "power/runtime_suspended_time": "0", + "power/runtime_usage": "0", + "proto_down": "0", + "queues/rx-0/rps_cpus": "0", + "queues/rx-0/rps_flow_cnt": "0", + "queues/rx-0/virtio_net/mergeable_rx_buffer_size": "1536", + "queues/tx-0/byte_queue_limits/hold_time": "1000", + "queues/tx-0/byte_queue_limits/inflight": "0", + "queues/tx-0/byte_queue_limits/limit": "0", + "queues/tx-0/byte_queue_limits/limit_max": "1879048192", + "queues/tx-0/byte_queue_limits/limit_min": "0", + "queues/tx-0/traffic_class": null, + "queues/tx-0/tx_maxrate": "0", + "queues/tx-0/tx_timeout": "0", + "queues/tx-0/xps_cpus": null, + "queues/tx-0/xps_rxqs": "0", + "speed": "-1", + "statistics/collisions": "0", + "statistics/multicast": "0", + "statistics/rx_bytes": "285792", + "statistics/rx_compressed": "0", + "statistics/rx_crc_errors": "0", + "statistics/rx_dropped": "0", + "statistics/rx_errors": "0", + "statistics/rx_fifo_errors": "0", + "statistics/rx_frame_errors": "0", + "statistics/rx_length_errors": "0", + "statistics/rx_missed_errors": "0", + "statistics/rx_nohandler": "0", + "statistics/rx_over_errors": "0", + "statistics/rx_packets": "329", + "statistics/tx_aborted_errors": "0", + "statistics/tx_bytes": "58992", + "statistics/tx_carrier_errors": "0", + "statistics/tx_compressed": "0", + "statistics/tx_dropped": "0", + "statistics/tx_errors": "0", + "statistics/tx_fifo_errors": "0", + "statistics/tx_heartbeat_errors": "0", + "statistics/tx_packets": "186", + "statistics/tx_window_errors": "0", + "subsystem": "net", + "testing": "0", + "threaded": "0", + "tx_queue_len": "1000", + "type": "1", + "uevent": "INTERFACE=ens3\nIFINDEX=2" + } + } + }, + { + "addresses": [ + { + "address": "127.0.0.1/8", + "family": 2, + "scope": "host", + "source": "static" + }, + { + "address": "::1/128", + "family": 10, + "scope": "host", + "source": "static" + } + ], + "bond": { + "is_master": false, + "is_slave": false, + "lacp_rate": null, + "master": null, + "mode": null, + "slaves": [], + "xmit_hash_policy": null + }, + "bridge": { + "interfaces": [], + "is_bridge": false, + "is_port": false, + "options": {} + }, + "netlink_data": { + "arptype": 772, + "family": 0, + "flags": 65609, + "ifindex": 1, + "is_vlan": false, + "name": "lo" + }, + "type": "lo", + "udev_data": { + "DEVPATH": "/devices/virtual/net/lo", + "ID_MM_CANDIDATE": "1", + "IFINDEX": "1", + "INTERFACE": "lo", + "SUBSYSTEM": "net", + "USEC_INITIALIZED": "1721549", + "attrs": { + "addr_assign_type": "0", + "addr_len": "6", + "address": "00:00:00:00:00:00", + "broadcast": "00:00:00:00:00:00", + "carrier": "1", + "carrier_changes": "0", + "carrier_down_count": "0", + "carrier_up_count": "0", + "dev_id": "0x0", + "dev_port": "0", + "dormant": "0", + "duplex": null, + "flags": "0x9", + "gro_flush_timeout": "0", + "ifalias": "", + "ifindex": "1", + "iflink": "1", + "link_mode": "0", + "mtu": "65536", + "name_assign_type": "2", + "napi_defer_hard_irqs": "0", + "netdev_group": "0", + "operstate": "unknown", + "phys_port_id": null, + "phys_port_name": null, + "phys_switch_id": null, + "power/async": "disabled", + "power/autosuspend_delay_ms": null, + "power/control": "auto", + "power/runtime_active_kids": "0", + "power/runtime_active_time": "0", + "power/runtime_enabled": "disabled", + "power/runtime_status": "unsupported", + "power/runtime_suspended_time": "0", + "power/runtime_usage": "0", + "proto_down": "0", + "queues/rx-0/rps_cpus": "0", + "queues/rx-0/rps_flow_cnt": "0", + "queues/tx-0/byte_queue_limits/hold_time": "1000", + "queues/tx-0/byte_queue_limits/inflight": "0", + "queues/tx-0/byte_queue_limits/limit": "0", + "queues/tx-0/byte_queue_limits/limit_max": "1879048192", + "queues/tx-0/byte_queue_limits/limit_min": "0", + "queues/tx-0/traffic_class": null, + "queues/tx-0/tx_maxrate": "0", + "queues/tx-0/tx_timeout": "0", + "queues/tx-0/xps_cpus": null, + "queues/tx-0/xps_rxqs": "0", + "speed": null, + "statistics/collisions": "0", + "statistics/multicast": "0", + "statistics/rx_bytes": "17184", + "statistics/rx_compressed": "0", + "statistics/rx_crc_errors": "0", + "statistics/rx_dropped": "0", + "statistics/rx_errors": "0", + "statistics/rx_fifo_errors": "0", + "statistics/rx_frame_errors": "0", + "statistics/rx_length_errors": "0", + "statistics/rx_missed_errors": "0", + "statistics/rx_nohandler": "0", + "statistics/rx_over_errors": "0", + "statistics/rx_packets": "196", + "statistics/tx_aborted_errors": "0", + "statistics/tx_bytes": "17184", + "statistics/tx_carrier_errors": "0", + "statistics/tx_compressed": "0", + "statistics/tx_dropped": "0", + "statistics/tx_errors": "0", + "statistics/tx_fifo_errors": "0", + "statistics/tx_heartbeat_errors": "0", + "statistics/tx_packets": "196", + "statistics/tx_window_errors": "0", + "subsystem": "net", + "testing": "0", + "threaded": "0", + "tx_queue_len": "1000", + "type": "772", + "uevent": "INTERFACE=lo\nIFINDEX=1" + } + } + } + ], + "routes": [ + { + "dst": "default", + "family": 2, + "ifindex": 2, + "table": 254, + "type": 1 + }, + { + "dst": "10.0.2.0/24", + "family": 2, + "ifindex": 2, + "table": 254, + "type": 1 + }, + { + "dst": "10.0.2.2", + "family": 2, + "ifindex": 2, + "table": 254, + "type": 1 + }, + { + "dst": "10.0.2.3", + "family": 2, + "ifindex": 2, + "table": 254, + "type": 1 + }, + { + "dst": "10.0.2.15", + "family": 2, + "ifindex": 2, + "table": 255, + "type": 2 + }, + { + "dst": "10.0.2.255", + "family": 2, + "ifindex": 2, + "table": 255, + "type": 3 + }, + { + "dst": "127.0.0.0/8", + "family": 2, + "ifindex": 1, + "table": 255, + "type": 2 + }, + { + "dst": "127.0.0.1", + "family": 2, + "ifindex": 1, + "table": 255, + "type": 2 + }, + { + "dst": "127.255.255.255", + "family": 2, + "ifindex": 1, + "table": 255, + "type": 3 + }, + { + "dst": "::1", + "family": 10, + "ifindex": 1, + "table": 254, + "type": 1 + }, + { + "dst": "fe80::/64", + "family": 10, + "ifindex": 2, + "table": 254, + "type": 1 + }, + { + "dst": "fec0::/64", + "family": 10, + "ifindex": 2, + "table": 254, + "type": 1 + }, + { + "dst": "default", + "family": 10, + "ifindex": 2, + "table": 254, + "type": 1 + }, + { + "dst": "::1", + "family": 10, + "ifindex": 1, + "table": 255, + "type": 2 + }, + { + "dst": "fe80::5054:ff:fe12:3456", + "family": 10, + "ifindex": 2, + "table": 255, + "type": 2 + }, + { + "dst": "fec0::5054:ff:fe12:3456", + "family": 10, + "ifindex": 2, + "table": 255, + "type": 2 + }, + { + "dst": "ff00::/8", + "family": 10, + "ifindex": 2, + "table": 255, + "type": 5 + } + ] + }, + "storage": { + "bcache": { + "backing": {}, + "caching": {} + }, + "blockdev": { + "/dev/fd0": { + "CURRENT_TAGS": ":systemd:", + "DEVNAME": "/dev/fd0", + "DEVPATH": "/devices/platform/floppy.0/block/fd0", + "DEVTYPE": "disk", + "DISKSEQ": "29", + "ID_DRIVE_FLOPPY": "1", + "MAJOR": "2", + "MINOR": "0", + "SUBSYSTEM": "block", + "TAGS": ":systemd:", + "USEC_INITIALIZED": "8206612", + "attrs": { + "alignment_offset": "0", + "bdi": null, + "capability": "5", + "dev": "2:0", + "device": null, + "discard_alignment": "0", + "diskseq": "29", + "events": "", + "events_async": "", + "events_poll_msecs": "-1", + "ext_range": "1", + "hidden": "0", + "inflight": " 0 0", + "integrity/device_is_integrity_capable": "0", + "integrity/format": "none", + "integrity/protection_interval_bytes": "0", + "integrity/read_verify": "0", + "integrity/tag_size": "0", + "integrity/write_generate": "0", + "mq/0/cpu_list": "0, 1", + "mq/0/nr_reserved_tags": "0", + "mq/0/nr_tags": "2", + "power/async": "disabled", + "power/autosuspend_delay_ms": null, + "power/control": "auto", + "power/runtime_active_kids": "0", + "power/runtime_active_time": "0", + "power/runtime_enabled": "disabled", + "power/runtime_status": "unsupported", + "power/runtime_suspended_time": "0", + "power/runtime_usage": "0", + "queue/add_random": "0", + "queue/chunk_sectors": "0", + "queue/dax": "0", + "queue/discard_granularity": "0", + "queue/discard_max_bytes": "0", + "queue/discard_max_hw_bytes": "0", + "queue/discard_zeroes_data": "0", + "queue/dma_alignment": "511", + "queue/fua": "0", + "queue/hw_sector_size": "512", + "queue/io_poll": "0", + "queue/io_poll_delay": "-1", + "queue/iosched/async_depth": "3", + "queue/iosched/fifo_batch": "16", + "queue/iosched/front_merges": "1", + "queue/iosched/prio_aging_expire": "10000", + "queue/iosched/read_expire": "500", + "queue/iosched/write_expire": "5000", + "queue/iosched/writes_starved": "2", + "queue/iostats": "1", + "queue/logical_block_size": "512", + "queue/max_discard_segments": "1", + "queue/max_hw_sectors_kb": "32", + "queue/max_integrity_segments": "0", + "queue/max_sectors_kb": "32", + "queue/max_segment_size": "65536", + "queue/max_segments": "128", + "queue/minimum_io_size": "512", + "queue/nomerges": "0", + "queue/nr_requests": "4", + "queue/nr_zones": "0", + "queue/optimal_io_size": "0", + "queue/physical_block_size": "512", + "queue/read_ahead_kb": "128", + "queue/rotational": "1", + "queue/rq_affinity": "1", + "queue/scheduler": "none [mq-deadline] ", + "queue/stable_writes": "0", + "queue/virt_boundary_mask": "0", + "queue/wbt_lat_usec": "75000", + "queue/write_cache": "write through", + "queue/write_same_max_bytes": "0", + "queue/write_zeroes_max_bytes": "0", + "queue/zone_append_max_bytes": "0", + "queue/zone_write_granularity": "0", + "queue/zoned": "none", + "range": "1", + "removable": "1", + "ro": "0", + "size": "4096", + "stat": " 6 0 48 259 0 0 0 0 0 288 259 0 0 0 0 0 0", + "subsystem": "block", + "trace/act_mask": "disabled", + "trace/enable": "0", + "trace/end_lba": "disabled", + "trace/pid": "disabled", + "trace/start_lba": "disabled", + "uevent": "MAJOR=2\nMINOR=0\nDEVNAME=fd0\nDEVTYPE=disk\nDISKSEQ=29" + } + }, + "/dev/sr0": { + "CURRENT_TAGS": ":systemd:seat:uaccess:", + "DEVLINKS": "/dev/disk/by-id/ata-QEMU_DVD-ROM_QM00003 /dev/disk/by-diskseq/10 /dev/cdrom /dev/disk/by-path/pci-0000:00:01.1-ata-2 /dev/disk/by-path/pci-0000:00:01.1-ata-2.0", + "DEVNAME": "/dev/sr0", + "DEVPATH": "/devices/pci0000:00/0000:00:01.1/ata2/host1/target1:0:0/1:0:0:0/block/sr0", + "DEVTYPE": "disk", + "DISKSEQ": "10", + "ID_ATA": "1", + "ID_BUS": "ata", + "ID_CDROM": "1", + "ID_CDROM_DVD": "1", + "ID_CDROM_MRW": "1", + "ID_CDROM_MRW_W": "1", + "ID_FOR_SEAT": "block-pci-0000_00_01_1-ata-2_0", + "ID_MODEL": "QEMU_DVD-ROM", + "ID_MODEL_ENC": "QEMU\\x20DVD-ROM\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20\\x20", + "ID_PATH": "pci-0000:00:01.1-ata-2.0", + "ID_PATH_ATA_COMPAT": "pci-0000:00:01.1-ata-2", + "ID_PATH_TAG": "pci-0000_00_01_1-ata-2_0", + "ID_REVISION": "2.5+", + "ID_SCSI": "1", + "ID_SCSI_INQUIRY": "1", + "ID_SERIAL": "QEMU_DVD-ROM_QM00003", + "ID_SERIAL_SHORT": "QM00003", + "ID_TYPE": "cd", + "ID_VENDOR": "QEMU", + "ID_VENDOR_ENC": "QEMU\\x20\\x20\\x20\\x20", + "MAJOR": "11", + "MINOR": "0", + "SCSI_MODEL": "QEMU_DVD-ROM", + "SCSI_MODEL_ENC": "QEMU\\x20DVD-ROM\\x20\\x20\\x20\\x20", + "SCSI_REVISION": "2.5+", + "SCSI_TPGS": "0", + "SCSI_TYPE": "cd/dvd", + "SCSI_VENDOR": "QEMU", + "SCSI_VENDOR_ENC": "QEMU\\x20\\x20\\x20\\x20", + "SUBSYSTEM": "block", + "TAGS": ":systemd:seat:uaccess:", + "USEC_INITIALIZED": "2114550", + "attrs": { + "alignment_offset": "0", + "bdi": null, + "capability": "5", + "dev": "11:0", + "device": null, + "discard_alignment": "0", + "diskseq": "10", + "events": "media_change eject_request", + "events_async": "", + "events_poll_msecs": "-1", + "ext_range": "1", + "hidden": "0", + "inflight": " 0 0", + "integrity/device_is_integrity_capable": "0", + "integrity/format": "none", + "integrity/protection_interval_bytes": "0", + "integrity/read_verify": "0", + "integrity/tag_size": "0", + "integrity/write_generate": "0", + "mq/0/cpu_list": "0, 1", + "mq/0/nr_reserved_tags": "0", + "mq/0/nr_tags": "1", + "power/async": "disabled", + "power/autosuspend_delay_ms": null, + "power/control": "auto", + "power/runtime_active_kids": "0", + "power/runtime_active_time": "0", + "power/runtime_enabled": "disabled", + "power/runtime_status": "unsupported", + "power/runtime_suspended_time": "0", + "power/runtime_usage": "0", + "queue/add_random": "0", + "queue/bsg": null, + "queue/chunk_sectors": "0", + "queue/dax": "0", + "queue/discard_granularity": "0", + "queue/discard_max_bytes": "0", + "queue/discard_max_hw_bytes": "0", + "queue/discard_zeroes_data": "0", + "queue/dma_alignment": "511", + "queue/fua": "0", + "queue/hw_sector_size": "512", + "queue/io_poll": "0", + "queue/io_poll_delay": "-1", + "queue/io_timeout": "30000", + "queue/iosched/async_depth": "1", + "queue/iosched/fifo_batch": "16", + "queue/iosched/front_merges": "1", + "queue/iosched/prio_aging_expire": "10000", + "queue/iosched/read_expire": "500", + "queue/iosched/write_expire": "5000", + "queue/iosched/writes_starved": "2", + "queue/iostats": "1", + "queue/logical_block_size": "512", + "queue/max_discard_segments": "1", + "queue/max_hw_sectors_kb": "128", + "queue/max_integrity_segments": "0", + "queue/max_sectors_kb": "128", + "queue/max_segment_size": "65536", + "queue/max_segments": "127", + "queue/minimum_io_size": "512", + "queue/nomerges": "0", + "queue/nr_requests": "2", + "queue/nr_zones": "0", + "queue/optimal_io_size": "0", + "queue/physical_block_size": "512", + "queue/read_ahead_kb": "128", + "queue/rotational": "1", + "queue/rq_affinity": "1", + "queue/scheduler": "none [mq-deadline] ", + "queue/stable_writes": "0", + "queue/virt_boundary_mask": "0", + "queue/wbt_lat_usec": "75000", + "queue/write_cache": "write through", + "queue/write_same_max_bytes": "0", + "queue/write_zeroes_max_bytes": "0", + "queue/zone_append_max_bytes": "0", + "queue/zone_write_granularity": "0", + "queue/zoned": "none", + "range": "1", + "removable": "1", + "ro": "0", + "size": "1073741312", + "stat": " 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0", + "subsystem": "block", + "trace/act_mask": "disabled", + "trace/enable": "0", + "trace/end_lba": "disabled", + "trace/pid": "disabled", + "trace/start_lba": "disabled", + "uevent": "MAJOR=11\nMINOR=0\nDEVNAME=sr0\nDEVTYPE=disk\nDISKSEQ=10" + } + }, + "/dev/vda": { + "CURRENT_TAGS": ":systemd:", + "DEVLINKS": "/dev/disk/by-path/virtio-pci-0000:00:04.0 /dev/disk/by-diskseq/19 /dev/disk/by-path/pci-0000:00:04.0", + "DEVNAME": "/dev/vda", + "DEVPATH": "/devices/pci0000:00/0000:00:04.0/virtio0/block/vda", + "DEVTYPE": "disk", + "DISKSEQ": "19", + "ID_PART_TABLE_TYPE": "gpt", + "ID_PART_TABLE_UUID": "4ccece18-17cb-704e-b38c-895181b8b7d1", + "ID_PATH": "pci-0000:00:04.0", + "ID_PATH_TAG": "pci-0000_00_04_0", + "MAJOR": "252", + "MINOR": "0", + "SUBSYSTEM": "block", + "TAGS": ":systemd:", + "USEC_INITIALIZED": "1865161", + "attrs": { + "alignment_offset": "0", + "bdi": null, + "cache_type": "write back", + "capability": "0", + "dev": "252:0", + "device": null, + "discard_alignment": "0", + "diskseq": "19", + "events": "", + "events_async": "", + "events_poll_msecs": "-1", + "ext_range": "256", + "hidden": "0", + "inflight": " 0 0", + "integrity/device_is_integrity_capable": "0", + "integrity/format": "none", + "integrity/protection_interval_bytes": "0", + "integrity/read_verify": "0", + "integrity/tag_size": "0", + "integrity/write_generate": "0", + "mq/0/cpu_list": "0", + "mq/0/nr_reserved_tags": "0", + "mq/0/nr_tags": "256", + "mq/1/cpu_list": "1", + "mq/1/nr_reserved_tags": "0", + "mq/1/nr_tags": "256", + "power/async": "disabled", + "power/autosuspend_delay_ms": null, + "power/control": "auto", + "power/runtime_active_kids": "0", + "power/runtime_active_time": "0", + "power/runtime_enabled": "disabled", + "power/runtime_status": "unsupported", + "power/runtime_suspended_time": "0", + "power/runtime_usage": "0", + "queue/add_random": "0", + "queue/chunk_sectors": "0", + "queue/dax": "0", + "queue/discard_granularity": "512", + "queue/discard_max_bytes": "2147483136", + "queue/discard_max_hw_bytes": "2147483136", + "queue/discard_zeroes_data": "0", + "queue/dma_alignment": "511", + "queue/fua": "0", + "queue/hw_sector_size": "512", + "queue/io_poll": "0", + "queue/io_poll_delay": "-1", + "queue/iostats": "1", + "queue/logical_block_size": "512", + "queue/max_discard_segments": "1", + "queue/max_hw_sectors_kb": "2147483647", + "queue/max_integrity_segments": "0", + "queue/max_sectors_kb": "1280", + "queue/max_segment_size": "4294967295", + "queue/max_segments": "254", + "queue/minimum_io_size": "512", + "queue/nomerges": "0", + "queue/nr_requests": "256", + "queue/nr_zones": "0", + "queue/optimal_io_size": "0", + "queue/physical_block_size": "512", + "queue/read_ahead_kb": "128", + "queue/rotational": "1", + "queue/rq_affinity": "1", + "queue/scheduler": "[none] mq-deadline ", + "queue/stable_writes": "0", + "queue/virt_boundary_mask": "0", + "queue/wbt_lat_usec": "75000", + "queue/write_cache": "write back", + "queue/write_same_max_bytes": "0", + "queue/write_zeroes_max_bytes": "2147483136", + "queue/zone_append_max_bytes": "0", + "queue/zone_write_granularity": "0", + "queue/zoned": "none", + "range": "16", + "removable": "0", + "ro": "0", + "serial": "", + "size": "137438953472", + "stat": " 9644 5578 1439439 4095 0 0 0 0 2 6856 4095 0 0 0 0 0 0", + "subsystem": "block", + "trace/act_mask": "disabled", + "trace/enable": "0", + "trace/end_lba": "disabled", + "trace/pid": "disabled", + "trace/start_lba": "disabled", + "uevent": "MAJOR=252\nMINOR=0\nDEVNAME=vda\nDEVTYPE=disk\nDISKSEQ=19" + }, + "partitiontable": { + "device": "/dev/vda", + "firstlba": 2048, + "id": "4CCECE18-17CB-704E-B38C-895181B8B7D1", + "label": "gpt", + "lastlba": 268435422, + "partitions": [ + { + "node": "/dev/vda1", + "size": 2201600, + "start": 2048, + "type": "C12A7328-F81F-11D2-BA4B-00A0C93EC93B", + "uuid": "A0B5B098-6E0D-C44A-A88E-5B942E6B277D" + }, + { + "node": "/dev/vda2", + "size": 5767168, + "start": 2203648, + "type": "E3C9E316-0B5C-4DB8-817D-F92DF00215AE", + "uuid": "471DC21D-8054-B542-86C9-F530A85FCC1F" + } + ], + "sectorsize": 512, + "unit": "sectors" + } + }, + "/dev/vda1": { + "CURRENT_TAGS": ":systemd:", + "DEVLINKS": "/dev/disk/by-path/pci-0000:00:04.0-part1 /dev/disk/by-path/virtio-pci-0000:00:04.0-part1 /dev/disk/by-uuid/F659-DBF7 /dev/disk/by-partuuid/a0b5b098-6e0d-c44a-a88e-5b942e6b277d", + "DEVNAME": "/dev/vda1", + "DEVPATH": "/devices/pci0000:00/0000:00:04.0/virtio0/block/vda/vda1", + "DEVTYPE": "partition", + "DISKSEQ": "19", + "ID_FS_TYPE": "vfat", + "ID_FS_USAGE": "filesystem", + "ID_FS_UUID": "F659-DBF7", + "ID_FS_UUID_ENC": "F659-DBF7", + "ID_FS_VERSION": "FAT32", + "ID_PART_ENTRY_DISK": "252:0", + "ID_PART_ENTRY_NUMBER": "1", + "ID_PART_ENTRY_OFFSET": "2048", + "ID_PART_ENTRY_SCHEME": "gpt", + "ID_PART_ENTRY_SIZE": "2201600", + "ID_PART_ENTRY_TYPE": "c12a7328-f81f-11d2-ba4b-00a0c93ec93b", + "ID_PART_ENTRY_UUID": "a0b5b098-6e0d-c44a-a88e-5b942e6b277d", + "ID_PART_TABLE_TYPE": "gpt", + "ID_PART_TABLE_UUID": "4ccece18-17cb-704e-b38c-895181b8b7d1", + "ID_PATH": "pci-0000:00:04.0", + "ID_PATH_TAG": "pci-0000_00_04_0", + "MAJOR": "252", + "MINOR": "1", + "PARTN": "1", + "SUBSYSTEM": "block", + "TAGS": ":systemd:", + "UDISKS_IGNORE": "1", + "USEC_INITIALIZED": "1879436", + "attrs": { + "alignment_offset": "0", + "dev": "252:1", + "discard_alignment": "0", + "inflight": " 0 0", + "partition": "1", + "power/async": "disabled", + "power/autosuspend_delay_ms": null, + "power/control": "auto", + "power/runtime_active_kids": "0", + "power/runtime_active_time": "0", + "power/runtime_enabled": "disabled", + "power/runtime_status": "unsupported", + "power/runtime_suspended_time": "0", + "power/runtime_usage": "0", + "ro": "0", + "size": "1127219200", + "start": "2048", + "stat": " 169 0 11779 68 0 0 0 0 0 124 68 0 0 0 0 0 0", + "subsystem": "block", + "trace/act_mask": "disabled", + "trace/enable": "0", + "trace/end_lba": "disabled", + "trace/pid": "disabled", + "trace/start_lba": "disabled", + "uevent": "MAJOR=252\nMINOR=1\nDEVNAME=vda1\nDEVTYPE=partition\nDISKSEQ=19\nPARTN=1" + }, + "partitiontable": { + "device": "/dev/vda1", + "id": "0x00000000", + "label": "dos", + "sectorsize": 512, + "unit": "sectors" + } + }, + "/dev/vda2": { + "CURRENT_TAGS": ":systemd:", + "DEVLINKS": "/dev/disk/by-path/virtio-pci-0000:00:04.0-part2 /dev/disk/by-partuuid/471dc21d-8054-b542-86c9-f530a85fcc1f /dev/disk/by-path/pci-0000:00:04.0-part2 /dev/disk/by-uuid/F667-A987", + "DEVNAME": "/dev/vda2", + "DEVPATH": "/devices/pci0000:00/0000:00:04.0/virtio0/block/vda/vda2", + "DEVTYPE": "partition", + "DISKSEQ": "19", + "ID_FS_TYPE": "vfat", + "ID_FS_USAGE": "filesystem", + "ID_FS_UUID": "F667-A987", + "ID_FS_UUID_ENC": "F667-A987", + "ID_FS_VERSION": "FAT32", + "ID_PART_ENTRY_DISK": "252:0", + "ID_PART_ENTRY_NUMBER": "2", + "ID_PART_ENTRY_OFFSET": "2203648", + "ID_PART_ENTRY_SCHEME": "gpt", + "ID_PART_ENTRY_SIZE": "5767168", + "ID_PART_ENTRY_TYPE": "e3c9e316-0b5c-4db8-817d-f92df00215ae", + "ID_PART_ENTRY_UUID": "471dc21d-8054-b542-86c9-f530a85fcc1f", + "ID_PART_TABLE_TYPE": "gpt", + "ID_PART_TABLE_UUID": "4ccece18-17cb-704e-b38c-895181b8b7d1", + "ID_PATH": "pci-0000:00:04.0", + "ID_PATH_TAG": "pci-0000_00_04_0", + "MAJOR": "252", + "MINOR": "2", + "PARTN": "2", + "SUBSYSTEM": "block", + "TAGS": ":systemd:", + "UDISKS_IGNORE": "1", + "USEC_INITIALIZED": "1879149", + "attrs": { + "alignment_offset": "0", + "dev": "252:2", + "discard_alignment": "0", + "inflight": " 0 0", + "partition": "2", + "power/async": "disabled", + "power/autosuspend_delay_ms": null, + "power/control": "auto", + "power/runtime_active_kids": "0", + "power/runtime_active_time": "0", + "power/runtime_enabled": "disabled", + "power/runtime_status": "unsupported", + "power/runtime_suspended_time": "0", + "power/runtime_usage": "0", + "ro": "0", + "size": "2952790016", + "start": "2203648", + "stat": " 9336 5578 1426524 4007 0 0 0 0 0 6732 4007 0 0 0 0 0 0", + "subsystem": "block", + "trace/act_mask": "disabled", + "trace/enable": "0", + "trace/end_lba": "disabled", + "trace/pid": "disabled", + "trace/start_lba": "disabled", + "uevent": "MAJOR=252\nMINOR=2\nDEVNAME=vda2\nDEVTYPE=partition\nDISKSEQ=19\nPARTN=2" + }, + "partitiontable": { + "device": "/dev/vda2", + "id": "0x00000000", + "label": "dos", + "sectorsize": 512, + "unit": "sectors" + } + } + }, + "dasd": {}, + "dmcrypt": {}, + "filesystem": { + "/dev/vda1": { + "ESTIMATED_MIN_SIZE": -1, + "TYPE": "vfat", + "USAGE": "filesystem", + "UUID": "F659-DBF7", + "UUID_ENC": "F659-DBF7", + "VERSION": "FAT32" + }, + "/dev/vda2": { + "ESTIMATED_MIN_SIZE": -1, + "TYPE": "vfat", + "USAGE": "filesystem", + "UUID": "F667-A987", + "UUID_ENC": "F667-A987", + "VERSION": "FAT32" + } + }, + "lvm": {}, + "mount": [ + { + "children": [ + { + "children": [ + { + "fstype": "securityfs", + "maj:min": "0:6", + "options": "rw,nosuid,nodev,noexec,relatime", + "source": "securityfs", + "target": "/sys/kernel/security" + }, + { + "fstype": "cgroup2", + "maj:min": "0:39", + "options": "rw,nosuid,nodev,noexec,relatime,nsdelegate,memory_recursiveprot", + "source": "cgroup2", + "target": "/sys/fs/cgroup" + }, + { + "fstype": "pstore", + "maj:min": "0:40", + "options": "rw,nosuid,nodev,noexec,relatime", + "source": "pstore", + "target": "/sys/fs/pstore" + }, + { + "fstype": "efivarfs", + "maj:min": "0:41", + "options": "rw,nosuid,nodev,noexec,relatime", + "source": "efivarfs", + "target": "/sys/firmware/efi/efivars" + }, + { + "fstype": "bpf", + "maj:min": "0:42", + "options": "rw,nosuid,nodev,noexec,relatime,mode=700", + "source": "bpf", + "target": "/sys/fs/bpf" + }, + { + "fstype": "debugfs", + "maj:min": "0:7", + "options": "rw,nosuid,nodev,noexec,relatime", + "source": "debugfs", + "target": "/sys/kernel/debug" + }, + { + "fstype": "tracefs", + "maj:min": "0:12", + "options": "rw,nosuid,nodev,noexec,relatime", + "source": "tracefs", + "target": "/sys/kernel/tracing" + }, + { + "fstype": "configfs", + "maj:min": "0:19", + "options": "rw,nosuid,nodev,noexec,relatime", + "source": "configfs", + "target": "/sys/kernel/config" + }, + { + "fstype": "fusectl", + "maj:min": "0:45", + "options": "rw,nosuid,nodev,noexec,relatime", + "source": "fusectl", + "target": "/sys/fs/fuse/connections" + } + ], + "fstype": "sysfs", + "maj:min": "0:20", + "options": "rw,nosuid,nodev,noexec,relatime", + "source": "sysfs", + "target": "/sys" + }, + { + "children": [ + { + "children": [ + { + "fstype": "binfmt_misc", + "maj:min": "0:53", + "options": "rw,nosuid,nodev,noexec,relatime", + "source": "binfmt_misc", + "target": "/proc/sys/fs/binfmt_misc" + } + ], + "fstype": "autofs", + "maj:min": "0:43", + "options": "rw,relatime,fd=29,pgrp=1,timeout=0,minproto=5,maxproto=5,direct,pipe_ino=14905", + "source": "systemd-1", + "target": "/proc/sys/fs/binfmt_misc" + } + ], + "fstype": "proc", + "maj:min": "0:21", + "options": "rw,nosuid,nodev,noexec,relatime", + "source": "proc", + "target": "/proc" + }, + { + "children": [ + { + "fstype": "devpts", + "maj:min": "0:22", + "options": "rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000", + "source": "devpts", + "target": "/dev/pts" + }, + { + "fstype": "tmpfs", + "maj:min": "0:37", + "options": "rw,nosuid,nodev,inode64", + "source": "tmpfs", + "target": "/dev/shm" + }, + { + "fstype": "hugetlbfs", + "maj:min": "0:44", + "options": "rw,relatime,pagesize=2M", + "source": "hugetlbfs", + "target": "/dev/hugepages" + }, + { + "fstype": "mqueue", + "maj:min": "0:18", + "options": "rw,nosuid,nodev,noexec,relatime", + "source": "mqueue", + "target": "/dev/mqueue" + } + ], + "fstype": "devtmpfs", + "maj:min": "0:5", + "options": "rw,nosuid,relatime,size=1920176k,nr_inodes=480044,mode=755,inode64", + "source": "udev", + "target": "/dev" + }, + { + "children": [ + { + "fstype": "tmpfs", + "maj:min": "0:38", + "options": "rw,nosuid,nodev,noexec,relatime,size=5120k,inode64", + "source": "tmpfs", + "target": "/run/lock" + }, + { + "fstype": "ramfs", + "maj:min": "0:46", + "options": "ro,nosuid,nodev,noexec,relatime,mode=700", + "source": "ramfs", + "target": "/run/credentials/systemd-sysusers.service" + }, + { + "fstype": "ramfs", + "maj:min": "0:47", + "options": "ro,nosuid,nodev,noexec,relatime,mode=700", + "source": "ramfs", + "target": "/run/credentials/systemd-tmpfiles-setup-dev.service" + }, + { + "fstype": "ramfs", + "maj:min": "0:48", + "options": "ro,nosuid,nodev,noexec,relatime,mode=700", + "source": "ramfs", + "target": "/run/credentials/systemd-sysctl.service" + }, + { + "fstype": "ramfs", + "maj:min": "0:50", + "options": "ro,nosuid,nodev,noexec,relatime,mode=700", + "source": "ramfs", + "target": "/run/credentials/systemd-tmpfiles-setup.service" + }, + { + "children": [ + { + "fstype": "nsfs", + "maj:min": "0:4", + "options": "rw", + "source": "nsfs[mnt:[4026532175]]", + "target": "/run/snapd/ns/lxd.mnt" + } + ], + "fstype": "tmpfs", + "maj:min": "0:23", + "options": "rw,nosuid,nodev,noexec,relatime,size=398776k,mode=755,inode64", + "source": "tmpfs[/snapd/ns]", + "target": "/run/snapd/ns" + } + ], + "fstype": "tmpfs", + "maj:min": "0:23", + "options": "rw,nosuid,nodev,noexec,relatime,size=398776k,mode=755,inode64", + "source": "tmpfs", + "target": "/run" + }, + { + "fstype": "vfat", + "maj:min": "252:2", + "options": "ro,noatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro", + "source": "/dev/vda2", + "target": "/cdrom" + }, + { + "fstype": "squashfs", + "maj:min": "7:0", + "options": "ro,noatime,errors=continue,threads=single", + "source": "/dev/loop0", + "target": "/rofs" + }, + { + "fstype": "squashfs", + "maj:min": "7:5", + "options": "ro,relatime,errors=continue,threads=single", + "source": "/dev/loop5", + "target": "/media/minimal" + }, + { + "fstype": "squashfs", + "maj:min": "7:6", + "options": "ro,relatime,errors=continue,threads=single", + "source": "/dev/loop6", + "target": "/media/full" + }, + { + "fstype": "overlay", + "maj:min": "0:33", + "options": "ro,relatime,lowerdir=/root/media/full:/root/media/minimal", + "source": "overlay", + "target": "/media/filesystem" + }, + { + "fstype": "tmpfs", + "maj:min": "0:49", + "options": "rw,nosuid,nodev,relatime,inode64", + "source": "tmpfs", + "target": "/tmp" + }, + { + "fstype": "squashfs", + "maj:min": "7:7", + "options": "ro,nodev,relatime,errors=continue,threads=single", + "source": "/dev/loop7", + "target": "/snap/core22/607" + }, + { + "fstype": "squashfs", + "maj:min": "7:9", + "options": "ro,nodev,relatime,errors=continue,threads=single", + "source": "/dev/loop9", + "target": "/snap/lxd/24643" + }, + { + "fstype": "squashfs", + "maj:min": "7:8", + "options": "ro,nodev,relatime,errors=continue,threads=single", + "source": "/dev/loop8", + "target": "/snap/subiquity/x1" + }, + { + "fstype": "squashfs", + "maj:min": "7:10", + "options": "ro,nodev,relatime,errors=continue,threads=single", + "source": "/dev/loop10", + "target": "/snap/snapd/18596" + } + ], + "fstype": "overlay", + "maj:min": "0:26", + "options": "rw,relatime,lowerdir=/ubuntu-server-minimal.ubuntu-server.installer.generic.custom.squashfs:/ubuntu-server-minimal.ubuntu-server.installer.generic.squashfs:/ubuntu-server-minimal.ubuntu-server.installer.squashfs:/ubuntu-server-minimal.ubuntu-server.squashfs:/ubuntu-server-minimal.squashfs,upperdir=/cow/upper,workdir=/cow/work,xino=off", + "source": "/cow", + "target": "/" + } + ], + "multipath": {}, + "raid": {}, + "zfs": { + "zpools": {} + } + } +} \ No newline at end of file diff --git a/subiquity/models/filesystem.py b/subiquity/models/filesystem.py index 512bb101..587df49a 100644 --- a/subiquity/models/filesystem.py +++ b/subiquity/models/filesystem.py @@ -1292,15 +1292,19 @@ class FilesystemModel(object): continue majmin_to_dev[f'{major}:{minor}'] = obj + log.debug("majmin_to_dev %s", majmin_to_dev) + mounts = list(self._probe_data.get('mount', [])) while mounts: mount = mounts.pop(0) + mounts.extend(mount.get('children', [])) if mount['target'].startswith(self.target): # Completely ignore mounts under /target, they are probably # leftovers from a previous install attempt. continue if 'maj:min' not in mount: continue + log.debug("considering mount of %s", mount['maj:min']) obj = majmin_to_dev.get(mount['maj:min']) if obj is None: continue @@ -1312,7 +1316,6 @@ class FilesystemModel(object): if isinstance(o, Disk): o._has_in_use_partition = True work.extend(dependencies(o)) - mounts.extend(mount.get('children', [])) # This is a special hack for the install media. When written to a USB # stick or similar, both the block device for the whole drive and for diff --git a/subiquity/tests/api/test_api.py b/subiquity/tests/api/test_api.py index 9154d9c1..12ffc224 100644 --- a/subiquity/tests/api/test_api.py +++ b/subiquity/tests/api/test_api.py @@ -2075,3 +2075,17 @@ class TestActiveDirectory(TestAPI): # manager will fail to POST /shutdown. except aiohttp.client_exceptions.ClientOSError: pass + + +class TestMountDetection(TestAPI): + @timeout() + async def test_mount_detection(self): + # Test that the partition the installer is running from is + # correctly identified as mounted. + cfg = 'examples/machines/booted-from-rp.json' + async with start_server(cfg) as instance: + result = await instance.get('/storage/v2') + [disk1] = result['disks'] + self.assertTrue(disk1['has_in_use_partition']) + disk1p2 = disk1['partitions'][1] + self.assertTrue(disk1p2['is_in_use'])