Score:-1

How to use external SSD to store files for VM?

co flag

enter image description here

I'm using an external SSD portioned as exfat to store files for my vm. I'm using the tool virt manager to manage this.

While trying to store the vm on SSD I got this message: "The emulator may not have search permissions for the path".

So I tried sudo virt-manager. This did the trick.

After I tried to write the file to the external hard drive, I noticed I did not have write permissions. So I tried:

sudo mount -o remount,uid1000,gid1000,rw /dev/sda1

After I get error:

/dev/sda1: mount point not mounted or bad option.
dmesg(1) may have more information after failed mount system call.

Can someone help me out?

Contents of the file /etc/fstab:

# <file system> <mount point>   <type>  <options>       <dump>  <pass>
# /boot/efi was on /dev/nvme0n1p1 during installation
UUID=E9FD-8605  /boot/efi       vfat    umask=0022,fmask=0022,dmask=0022      0       1
/boot/efi/grub  /boot/grub  none    defaults,bind   0   0
UUID=8d091d18-ed63-46fd-b343-f6ef2213d433   none    swap    sw  0   0

Have reformatted the whole external drive by using sudo mkfs -t ext4 /dev/sda

Then I tried :sudo mount -o remount,uid1000,gid1000,rw /dev/sda

and got message: mount:

/media/alexander/64713888-76cb-4409-96b2-9685a120f63e: mount point not mounted or bad option.
dmesg(1) may have more information after failed mount system call.

Downloaded new ISO file will store on SSD and try again.

Update: enter image description here

Hooked it on my MacBook (Before my pc build I used parallels and runned windows with parallels on the same SSD on which I run multiple vm's with hyper-v.) So now I'm performing a secure erase re-partitioning to ex fat. After I will hook it back up to Ubuntu re-partition it to ext4 and will give update after I again download ISO on folder in newly partitioned SSD.

user1686925 avatar
co flag
I do not understand your answer.
ar flag
I found a way to keep the partition `ExFat` and do what you want and wrote out an answer. If this works feel free to accept the answer as "correct" by clicking on the gray check mark next to the answer and turn it green ✅. This will help others.
Score:2
ar flag

The Problem

When QEMU/KVM runs, it runs as a special user called libvert. This user must be able to read and write to the external drive, in particular, the partition formatted ExFat inside the external drive.

When an user, let's say adam is logged on and connects an USB drive to the Ubuntu computer, Ubuntu mounts the partition(s) in that USB drive so that only the user, adam in this example, can write to that partition. When libvert or any other user tries to write, or modify a file in that partition it fails.

The Solution

I have tried this solution on a 32GB USB flash drive formatted ExFat. I was able to install Ubuntu 22.04 Minimal installation, and run the VM from the USB drive. However, this is a very unusual setup and may break under heavy testing.

1. Find the UUID of the partition of the external drive

Open the app Disks and click on the external drive on the left panel. Then click on the main partition on the main window. You will see something like the screenshot below. Note down the UUID of the partition. In this case, the UUID is 6431-BACB.

enter image description here

2. Create a new mount-point

Make sure the external drive is not plugged in. If plugged in, unmount the drive (partition) and unplug it when it is safe to do so.

Open a terminal and enter the following two commands:

sudo mkdir -p /media/alexander/VM
sudo chmod 0777 /media/alexander/VM

Change alexander with your username.

The first command creates the folder VM inside /media/alexander/. The second command allows other users to read and write inside this folder. You have to use these commands only once.

Note, usually the folder /alexander/VM is dynamically created when this USB drive is plugged in. Since we will stop this automatic mounting process, we need to create this folder manually. If you want this USB drive to be mounted as "root" you may want to create a different mount-point such as /media/VM or /mnt/VM.

3. Edit /etc/fstab

Open the file /etc/fstab using the command:

sudo gedit /etc/fstab

Go to the bottom of the file and add these lines:

# The next line is for the external VM Drive
UUID=6431-BACB  /media/32GBExFat exfat user,uid=1000,umask=000,utf8,noauto,nofail 0 0

Make sure the UUID is the correct one for the partition in the external drive that is to contain the VM related files.

I have assumed that you are the first and only user of this computer. If your UID is not 1000, you will have to change it in the above command. The partition will be mounted with your credentials.If you want the partition to be mounted as "root", remove the option uid=1000 from the above line.

Save the file and exit the editor.

Warning: The ExFat partition of this disk will not be automatically mounted when an user plugs in this drive after this step. You will have to manually mount the drive using one of the methods described in the next step.

4. Test and Build VMs

Plugin the external drive. It should not be auto-mounted. Mount the partition by any one of the following methods:

  1. Click on the icon that appeared on the Dock.
  2. Click on the "VM" item on the left panel of Files (AKA Nautilus).
  3. On the terminal type sudo mount /dev/sda2

Once the partition is mounted, open the folder "VM" and right click on any blank space. Then select Properties from the context menu. Go to the Permissions tab and verify "Others" can "Create and Delete Files".

Now you should be able to continue creating VM storage files in the external drive.

Note: It is a good idea to create a folder inside the "VM" partition. You may call it "VM_Storage" or something. Keep your ISO and qcow files in this folder rather than in the "root" of the partition.

For ext4, try VMM as root

first, make sure all the files and folders in this partition can be written to by any users. This can be done in Nautilus of using the command:

sudo chmod 0777 -R /media/alexander/VM

Try starting the Virtual Machine Manager with sudo before you build a new virtual machine. Open VMM as root using this command in the terminal:

sudo virt-manager 

See Virt-Manager error to create an images qcow2 on an external HDD for more details.

Hope this helps

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.