    async def install_os(self, iso_url: str):
        """Install OS from ISO with virtual hardware support"""
        # Generate unique ID for this OS image
        image_id = hashlib.sha256(f"os_image_{time.time()}".encode()).hexdigest()
        
        # Update VM state for installation
        self.vm_state["installation"].update({
            "iso_url": iso_url,
            "image_id": image_id,
            "completed": False
        })
        self.vm_state["status"] = "installing"
        for key, value in self.vm_state.items():
            self.storage.update_vm_state(key, value)
        
        logger.info(f"Starting OS installation from {iso_url}")
        
        try:
            # Create paths
            temp_dir = os.path.join(os.path.dirname(__file__), 'temp')
            disk_dir = os.path.join(os.path.dirname(__file__), 'disk')
            os.makedirs(temp_dir, exist_ok=True)
            os.makedirs(disk_dir, exist_ok=True)
            
            iso_path = os.path.join(temp_dir, f'os_{image_id}.iso')
            disk_path = os.path.join(disk_dir, 'os.qcow2')
            
            # Download ISO
            async with aiohttp.ClientSession() as session:
                async with session.get(iso_url) as response:
                    if response.status != 200:
                        raise RuntimeError(f"Failed to download ISO: {response.status}")
                        
                    # Download directly to file first
                    with open(iso_path, 'wb') as f:
                        async for chunk in response.content.iter_chunked(1024*1024):
                            f.write(chunk)
                    
                    # Now read the file and store in database
                    with open(iso_path, 'rb') as f:
                        total_size = 0
                        chunk_size = 1024 * 1024  # 1MB chunks
                        checksum = hashlib.sha256()
                        
                        while chunk := f.read(chunk_size):
                            checksum.update(chunk)
                            self.storage.store_os_image_chunk(image_id, total_size // chunk_size, chunk)
                            total_size += len(chunk)
                    
            # Create QEMU virtual disk
            subprocess.run(['qemu-img', 'create', '-f', 'qcow2', disk_path, '20G'])
            
            # Update installation state
            self.vm_state["installation"].update({
                "checksum": checksum.hexdigest(),
                "completed": False,
                "image_id": image_id
            })
            
            for key, value in self.vm_state.items():
                self.storage.update_vm_state(key, value)
                
            # Start QEMU with installation media
            cmd = self.get_qemu_command(disk_path, iso_path)
            logger.info("Starting OS installation with virtual hardware...")
            
            env = os.environ.copy()
            self.vm_process = subprocess.Popen(cmd, shell=True, env=env)
            
            return self.vnc_port
            
        except Exception as e:
            self.vm_state["status"] = "error"
            self.vm_state["installation"]["error"] = str(e)
            for key, value in self.vm_state.items():
                self.storage.update_vm_state(key, value)
            raise RuntimeError(f"Failed to download ISO: {e}")