# Move a machine from another app

Bring a Windows, Linux, or macOS machine over from another app, which keeps the original as it is.

## Before you start

- Windows and Linux machines must be for Arm. OSMates refuses x86_64 disks.
- Shut the machine down in its original app. OSMates [can't always tell](https://osmates.com/docs/known-issues#import-doesnt-detect-a-running-machine) that it's running.
- Merge disk snapshot layers, and decrypt a disk the original app encrypted.

| System | OSMates reads |
|---|---|
| Windows | VMDK disks with a VMX file, `.hdd` folders, and bundles with a `config.plist` and qcow2 or RAW disks |
| Linux | The Windows sources, ASIF disks in bundles, and a single RAW, qcow2, or VMDK disk |
| macOS | A folder from another app on Apple Virtualization, with `HardwareModel`, `MachineIdentifier`, `AuxiliaryStorage`, and `Disk.img`, or a `config.plist` |

## Import a machine

1. Choose **File > Open** and select the machine's folder or disk, or drag it to the library.
2. Review what comes across and what stays behind.
3. Click **Import**, then start the machine.

The disk keeps its size, and CPUs and memory stay as they were, within what your Mac has. To check a source without importing it, then import it:

```sh
osmates vm import --check ~/Machines/Windows-11
osmates vm import ~/Machines/Windows-11 --name win11
```

The [`vm import` reference](https://osmates.com/docs/cli/vm/import) lists the other options.

## Move Windows from another app

### Prepare Windows

1. In the original app, start Windows and uninstall that app's tools.
2. In OSMates, choose **File > New Machine**, select **From Another App**, then click **Save Preparation Disc**.
3. Attach the disc in the original app. In Windows, open the **OSMATES** drive and run **Prepare for OSMates**.
4. Note the system UUID it prints, and let Windows shut down.

Preparation installs the guest agent, turns hibernation off, and suspends BitLocker for one start. `osmates vm import --preparation-disc ~/Desktop/OSMates.iso` saves the disc too.

### Import Windows

[Import the machine](https://osmates.com/docs/import-machine#import-a-machine). For a `.hdd` folder, paste the system UUID. To have OSMates sign in for you, enter the account password before you click **Import**, or pipe it in:

```sh
printf '%s\n' "$PASSWORD" | osmates vm import ~/Machines/Windows-11 --password-stdin
```

A library holds one machine per system UUID, and `--new-identity` gives Windows a new one. Windows sees new hardware either way, so it can need [activating again](https://osmates.com/docs/windows#activate-windows).

The TPM stays behind, so set up Windows Hello, passkeys, and work or school keys again. An account that signs in only with Windows Hello needs a password before you import.

Without preparation:

| If Windows | Do this |
|---|---|
| Shows the OSMATES disc at each start | Sign in, open the disc, and run **Install OSMates**. If Smart App Control blocks it, see [Allow the Windows guest agent](https://osmates.com/docs/windows-guest-agent) |
| Stops at BitLocker recovery | Enter the 48-digit key from [aka.ms/myrecoverykey](https://aka.ms/myrecoverykey) |
| Stops with `0x7B` after using SATA | Prepare it in the original app and import it again |

## Move Linux from another app

### Prepare Linux

1. Check that the disk has `\EFI\BOOT\BOOTAA64.EFI`. For an older Debian or a custom install, run `sudo grub-install --force-extra-removable` in the machine.
2. If the initramfs only fits the old hardware, rebuild it with virtio. On Fedora, run `sudo dracut -f --regenerate-all --no-hostonly`.
3. [Save the preparation disc](https://osmates.com/docs/import-machine#prepare-windows) and attach it in the original app.
4. In the machine, install the guest agent as root:

   ```sh
   d=$(findfs LABEL=OSMATES) && mount -o ro "$d" /mnt && sh /mnt/osmates-install
   umount /mnt
   ```

5. Shut the machine down.

### Import Linux

`--user` names the account OSMates uses. Without it, OSMates takes the first account that signs in to the desktop.

```sh
osmates vm import ~/Machines/Debian --user alex
osmates vm start debian --wait agent
```

SATA, SCSI, and IDE disks become virtio disks, and NVMe stays NVMe. The MAC address stays unless another machine uses it or you add `--new-identity`. Other disks come along, unless you add `--without-other-disks`.

If the machine has no network, see [Imported Linux machine has no network](https://osmates.com/docs/known-issues#imported-linux-machine-has-no-network). For a fresh machine with cloud-init, click **Use as Disk Image** in the import form.

## Move macOS from another app

OSMates first checks that your Mac supports the machine's hardware model.

1. In the original app, resume the machine if it's suspended, then shut it down.
2. In OSMates, choose **File > Open** and select its folder.
3. Start the machine and sign in.
4. Open **My Shared Files** and install **OSMates Agent.pkg**. For macOS 12, see [Install an older macOS](https://osmates.com/docs/macos#install-an-older-macos).

To save the password for `osmates vm sign-in`, import in Terminal:

```sh
printf '%s\n' "$PASSWORD" | osmates vm import ~/Machines/VM.bundle --password-stdin --user alex
```

The machine keeps its identifier, so run only one copy of it at a time. A second copy gets a [new identity](https://osmates.com/docs/macos#use-icloud).
