Skip to content
View in the app

A better way to browse. Learn more.

Unraid

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Cloning a VM

Featured Replies

Is it possible to clone a VM that has already been created, and have it behave completely independently of the original?

If the VM is stored on a BTRFS-formatted device, you can use the cp command to create reflink copies which are essentially the best of snapshots and clones in a single method:

 

cp --reflink /path/to/vdisk.img /path/to/snapshotorclone.img

 

The only catch is that both the source and destination file must exist in the same BTRFS volume.  This can be inside a btrfs pool or a single btrfs device.  An example of an INVALID use of the command:

 

cp --reflink /mnt/disk1/domains/domain1/domain1.img /mnt/disk2/domains/domain2/domain2.img

 

This won't work even if both disk1 and disk2 are btrfs because they will be separate volumes.

 

Also, you cannot use this command through the user share file system (/mnt/user).  Instead, always path through the device itself (e.g. /mnt/disk or /mnt/cache).

  • Author

I just tried that but its giving me an error:

 

cp: failed to clone ‘/mnt/cache/VM/UbuntuNew/vdisk1.img’ from ‘/mnt/cache/VM/UbuntuBase/vdisk1.img’: Invalid argument

 

What I ran was:

 

cp --reflink /mnt/cache/VM/UbuntuBase/vdisk1.img /mnt/cache/VM/UbuntuNew/vdisk1.img

 

Both source and destination are on my SSD, which is BTRFS formatted

 

A file shows up at the destination but its size is 0, so at least the paths are correct

  • 3 months later...

Figured out the soloution. Two things seem to create the problem you mentioned about invalid argument and 0KB.

 

1. If COW (Copy on Write) settings are disabled then this happens - this setting is in the share settings and you have to set it to "Auto" instead of "disabled" when creating the share

 

2. If you create your VM disk folders through the network/SAMBA I.e. You access it from my network places and you create subdirectories via that in Windows then try to cf reflink to there. The way around this is is, go to your VM, create a vdisk through the settings panel in a new folder of your choice, going via usershares to navigate to the folder of your choice.. Then delete the vdisk1.img and use the standard instructions posted above and being aware of not doing from 1 disk to another or going via user shares.

 

This seems to do the trick, I'm new to UNRAID but that worked for me. Hope it helps!

  • 1 year later...

Also, figured out that you can only reflink to the exact same folder. So in the case of @Nem, if he had done the above, to not get the error he got, he would need to have done:

 

cp --reflink /mnt/cache/VM/UbuntuBase/vdisk1.img /mnt/cache/VM/UbuntuBase/disk1.img

 

You can then copy the image to another folder however you cannot reflink from e.g. UbuntuBase to UbuntuNew, it has to the same folder it appears.

  • 4 years later...

I cloned a Debian VM and all I had to do was copy the vdisk and reinstall grub, filesystem included an efi partition 512MB and LVM2 vgroup with / /var /tmp /home.

The main trick was getting past the yellow efi CLI.

 

# Copy vdisk

ssh unraid

cd /mnt/disk1/domains

cp -rp DebianTemplate/vdisk1.img NewMachineName
# Double check the owner and permissions are the same as other VM's

ls -ld *; ls -l */vdisk1.img

# Use chown and chmod if owner and permissions don't match

# Create a new VM called NewMachineName but leave startup ISO blank


# If use vdisk location as automatic and the machine name is the same as the directory you copied to NewMachineName in this case
# it will automagically show you the vdisk location correctly otherwise manually adjust the vdisk location.

 

# Boot and you get the yellow efi shell menu
# Type exit (if I recall correctly) to get another graphical boot system test menu it looks like a UEFI/BIOS
# The last entry I think where you navigate the file system
# Go to to EFI or efi
# then debian
# then select grub and it boots into grub
# login as root user, open a terminal, and run
update-grub
# check where is the efi filesystem with
lsblk
# reinstall the grub to the efi paritition created on the original install in my case /devvda1
grub-install /dev/vda1

 

.. and it boots
 

I would guess you could copy and Windows vdisk the same way and navigate the efi CLI to boot to windows and do a boot repair.

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.