# Move, back up, and export machines

Put machines on another drive, back them up with Time Machine, or export a disk for another app.

## Put a machine on another drive

The drive must be APFS and attached to your Mac. Reformatting a drive as APFS in Disk Utility erases it.

1. Choose **File > New Machine** and select a system.
2. Under **Volume**, choose the drive.
3. Compare **Needed** and **Available**, then click **Create**.

`osmates vm volumes` lists the volumes and why OSMates can't use one. In Terminal, name the drive, or give its UUID when two drives share a name:

```sh
osmates vm create dev --volume "Samsung T7"
```

Machines on your startup disk live in `~/Library/Application Support/OSMates/Machines`. Another drive gets an `OSMates Machines` folder. Downloads still go to the [image cache](https://osmates.com/docs/volumes#keep-downloaded-images-on-another-drive), so its drive needs room too.

## Move a machine

1. Shut down the machine.
2. Select it, choose **Machine > Move to**, then choose a drive and click **Move**.
3. Follow the progress in the Overview. Click **Cancel** to stop.

```sh
osmates vm move-to dev "Samsung T7"
```

OSMates checks the copy before it removes the original, and a failed move leaves the machine where it was. Running, suspended, and temporary machines can't move.

Snapshots share space with the disk only on one drive. Check that the new drive has more room than the machine used.

A macOS machine on a drive you unplug can start on another Mac, with a [new identity](https://osmates.com/docs/macos#use-icloud).

To see a machine's file, choose **Machine > Show in Finder**. OSMates ignores a copy made in Finder, so [clone the machine](https://osmates.com/docs/clone) instead.

## Unplug a drive

Shut down the drive's machines before you eject it. Until it's back, they show as Offline, and you can't start, change, or delete them.

A running machine whose drive you unplug can't read or write its disk. Shut it down, then attach the drive again.

The first time you use a removable drive, you see requests for OSMates and OSMates Worker to access it. Click **Allow** for both.

## Keep downloaded images on another drive

Restore images, disk images, and installers download once into `~/Library/Caches/OSMates/Images`.

1. Choose **OSMates > Settings**, then click **General**.
2. Under **Downloaded Images**, click **Change**.
3. Choose an empty folder on an APFS drive, not in iCloud Drive or a shared folder, then click **Move Here**.

```sh
osmates settings image-cache move "/Volumes/Samsung T7/OSMates Images"
```

To bring the images back, click **Use Default Folder**. While the drive is away, downloads go to your startup disk. General settings offer to move them once it's back. No machine can be created while images move.

## Back up machines with Time Machine

Time Machine skips machines unless you turn this on, because their disks are large and change while they run.

1. Choose **OSMates > Settings**, then click **General**.
2. Under **Backups**, turn on **Back up machines with Time Machine**.

```sh
osmates backups include
```

The setting covers every machine, also one excluded with `tmutil addexclusion` or on another drive. Time Machine still backs up an external drive only if its own settings include it. Snapshots stay on this Mac and don't replace a backup.

## Export a disk

1. Shut down the machine.
2. Choose **Machine > Export Disk**.
3. Choose **RAW** or **qcow2**, and a disk if the machine has several, then click **Export**.

```sh
osmates vm export dev ~/Desktop/dev.qcow2 --format qcow2
```

The export reads a clone of the disk, so the machine can start meanwhile. `--replace` writes over an existing file. RAW on exFAT takes the full disk size, and FAT32 can't hold files over 4 GB.

To bring the file back, run `osmates vm import <file>`.
