Invalid cross-device link (18) when saving a file on arch linux

조회 수: 149 (최근 30일)
Youp Lamb
Youp Lamb 2022년 9월 7일
답변: FEDERICO 2023년 3월 30일
I have installed matlab on arch linux. everything works fine, even simulink. I can also open files without a problem. But whenever i try to save a file, i get the error. I cant find anything about it online
Error writing file "[path]"Invalid cross-device link (18)".

채택된 답변

Joshua Ortiga
Joshua Ortiga 2022년 9월 7일
이동: Walter Roberson 2022년 9월 7일
I am also using Arch Linux and having the same problem as well. Unfortunately this is an issue that is currently only resolved by downgrading your kernel to <=Linux 5.18.9
  댓글 수: 4
Ali
Ali 2022년 10월 12일
I reported this issue two weeks ago.
LP
LP 2023년 1월 13일
Alos have error on 5.15.0-57-generic

댓글을 달려면 로그인하십시오.

추가 답변 (9개)

simone rotondi
simone rotondi 2022년 10월 12일
I had the same behaviour.
Anyway i have figured out that a big problem are the temp files, if i set the matlab tempdir to a file system different wrt btrfs or tempfs and the file is also in a different file system it works with no problem.
If the filesystem of the temp files or the files you are working with is btrfs with a newer kernel it wont work. i have tried also to disable the COW on the folder i was working but no improvement at all.
For instance to change the temp dir of matlab
clear all
tempdir
setenv('TMPDIR','FOLDER FROM NTFS,EXT4..')
clear all
tempdir
and it should be fixed (for files not on btrfs)
  댓글 수: 6
FEDERICO
FEDERICO 2023년 3월 21일
Same for me, inside /home, works!
FEDERICO
FEDERICO 2023년 3월 30일
Since It is needed to do it any time you open matlab.
Open (or create) startup.m in your userpath folder, with the following command:
edit(fullfile(userpath,'startup.m'))
And then place inside this file the following line (with the correct folder path):
setenv('TMPDIR','/home/youruser/yourtempdir');

댓글을 달려면 로그인하십시오.


Jacek Jagosz
Jacek Jagosz 2022년 11월 9일
To someone from Matlab, this is to help them fix this issue.
This seems to be the commit that introduced this issue, not only present in kernel 5.18 but even backported to 5.15 LTS https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=linux-5.15.y&id=4d5055873e24bba9e01b3b5d16790714b0d38533
Some other applications broke with this change, not just Matlab. For example qBittorrent, they discussed the whole issue here: https://github.com/qbittorrent/qBittorrent/issues/17352
And they fixed it in this particular commit: https://github.com/arvidn/libtorrent/pull/6965
Hope Matlab can introduce the same fix, and hope it finds its way to the new release.
Can I ping someone so this gets to someone from Mathworks, this could probably help them fix this issue.
  댓글 수: 3
Jacek Jagosz
Jacek Jagosz 2023년 1월 30일
@Walter Roberson Could you check if this bug got fixed in R2022b Update 3 or maybe in the R2023a prerelease? I want to install a matlab release that is fully working.
Walter Roberson
Walter Roberson 2023년 1월 31일
  • R2022a Update 6
  • R2022b Update 4
I am not authorized to comment on pre-releases.

댓글을 달려면 로그인하십시오.


Adrian Dummermuth
Adrian Dummermuth 2022년 9월 22일
I am getting this error while I try to save a .mlx file provided by the professor. I have write permissions in /tmp/ but I am not sure why saving the .mlx doesn't work but if I create a new file that works. Any suggestions?
Running on Pop!_OS 22.04 LTS
Linux pop-os 5.19.0-76051900-generic #202207312230~1660780566~22.04~9d60db1 SMP PREEMPT_DYNAMIC Thu A x86_64 x86_64 x86_64 GNU/Linux
Unable to save file ex_1_1_tmp.mlx.
java.lang.RuntimeException: Internal Exception in writing MLX file : Could not commit changes: copy failed: fl:filesystem:SystemError: /tmp/.ed28-df99-8888-aaaa.tmp Invalid cross-device link
  댓글 수: 4
Youp Lamb
Youp Lamb 2022년 9월 27일
i also get the tmp file in the directory
Maciej
Maciej 2022년 9월 29일
You can save the .mlx file to your /tmp directory, and then move the file to your prefferred location. It is a poor workaround, though.

댓글을 달려면 로그인하십시오.


Carlos Planelles Otero
Carlos Planelles Otero 2022년 9월 28일
I have same issue on Pop!_OS 22.04, saving as a .m file works fine but not .mlx.

Lennart Guderian
Lennart Guderian 2022년 11월 30일
Hey guys,
this issue has been bugging me too (on Garuda (Arch) Linux) and I just wanted to share a solution I came up with that doesn't require you to downgrade your kernel since that was something I wasn't really excited about. Thank you @simone rotondi for the information about the filesystem being the issue in conjunction with the temp dir!
Since on my main hard drive I have a btrfs, I just formatted a small USB-Stick with FAT, named it matlab, created a tmp and set the TMPDIR var to point to it (`/run/media/uname/matlab/tmp`). Then I save all matlab files on this usb stick - works like a charm. Surely not optimal (looking forward to a soon fix from the MathWorks Team) but for me that was the more chill option than downgrading and version locking my kernel.
Hope it helps someone!
Cheers
  댓글 수: 2
Rishab Kumar
Rishab Kumar 2023년 3월 3일
Could you send the CLI commands with which you set the TMPDIR var pointer
Lennart Guderian
Lennart Guderian 2023년 3월 3일
The command to use in Matlab is setenv('TMPDIR','FOLDER FROM NTFS,EXT4..')as you can see in Simone's answer above. In Matlab there is a startup script you can write that is run automatically when you open the program, if you add this line in there, it will be set automatically on every start and the problem is solved (if you also have your external storage device with FAT filesystem connected).

댓글을 달려면 로그인하십시오.


Eugene Feinberg
Eugene Feinberg 2022년 12월 8일
After wasting (I hate to admit it) a few days trying to find a complete workaround to varients of this issue, I found that the root cause for me is the old version of the Java JRE that Mathworks packages with R2022b. Replacing the JRE with a newer version fixes every instance of the copy_file_range cross device problem (temporary directory, simulink saving issues, Xilinx blockset compile).
Process:
  • Download and untar or install java from https://www.java.com/en/download/manual.jsp
  • In the matlab install directory, rename R2022b/sys/java/jre/glnxa64 to R2022b/sys/java/glnxa64.orig
  • In the R2022b/sys/java/jre directory create a symlink to the download jre named glnxa64. There should now be a glnxa64/bin/java pointing to the new java binary.
The shipping version with R2022b update 2 is from January 2019
java version "1.8.0_202"
Java(TM) SE Runtime Environment (build 1.8.0_202-b08)
Java HotSpot(TM) 64-Bit Server VM (build 25.202-b08, mixed mode)
After installing the newer version
java version "1.8.0_351"
Java(TM) SE Runtime Environment (build 1.8.0_351-b10)
Java HotSpot(TM) 64-Bit Server VM (build 25.351-b10, mixed mode)
  댓글 수: 1
simone rotondi
simone rotondi 2022년 12월 9일
Hi, i thought this was a cool solution but i didnt manage to fix the problem.
I'm on fedora 37 and Matlab 2022b update1
I tried this trick with both the java oracle libraries and the openjdk libs .. but both of them didnt solved the error. (anyway i'll keep using it)
'Java 1.8.0_352-b08 with Red Hat, Inc. OpenJDK 64-Bit Server VM mixed mode'
'Java 1.8.0_351-b10 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode'
This could be totally my fault and i hope it is. I'll keep trying , thanks anyway!

댓글을 달려면 로그인하십시오.


Eugene Feinberg
Eugene Feinberg 2022년 9월 27일
I have the same problem on 22.04.1 LTS. MATLAB is installed on a different volume than /tmp. An strace shows the pattern below. By creating a temporary directory on the same disk volume that matlab is installed on and running matlab with the TMP variable set to that directory the error is resolved but that seems like a bad solution.
[pid 38662] openat(AT_FDCWD, "/opt/MATLAB/R2022b/toolbox/simulink/blocks/obsolete/simulink_need_slupdate.mdl", O_RDONLY|O_CLOEXEC) = 948
[pid 38662] fstat(948, {st_mode=S_IFREG|0444, st_size=164480, ...}) = 0
[pid 38662] openat(AT_FDCWD, "/tmp/.d1ee-e4b5-3401-aa22.tmp_extracted_package_simulink_need_slupdate.mdl/_mwopc_packageCopy.txt", O_WRONLY|O_CREAT|O_EXCL|O_TRUNC|O_CLOEXEC, 0100644) = 950
[pid 38662] fstat(950, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
[pid 38662] copy_file_range(948, NULL, 950, NULL, 164480, 0) = -1 EXDEV (Invalid cross-device link)

simone rotondi
simone rotondi 2022년 9월 30일
On fedora 36 with btrfs file system there is the same error both in R2022a and in R2022b.
Linux 5.18.9 is the last one working well but is now 4 months old and from 5.18.10 to 5.19.12 the problem persists.
Everytime i have to save a slx file it gives me
Error writing file "[path]/name.slx": Failed to close the package: "Collegamento tra dispositivi non valido (18)".
Where "Collegamento tra dispositivi non valido" means "Invalid cross link device"
  댓글 수: 6
Walter Roberson
Walter Roberson 2022년 11월 10일
You would need to have a partition available on a hard disk or SSD or flash drive (such as USB stick). The command line command that would be used at the Linux console would be mkfs -- see https://www.howtogeek.com/443342/how-to-use-the-mkfs-command-on-linux/
If I recall correctly there is a GUI available that will invoke the command on your behalf, but it has been several years since I last booted Linux so unfortunately I do not know where the GUI would be located.
simone rotondi
simone rotondi 2022년 11월 11일
편집: simone rotondi 2022년 11월 11일
If you are on Fedora36 i would just recommend to go back to kernel 5.18.9
You can download and install it with
mkdir KernDown
cd KernDown
koji download-build kernel-5.18.9-200.fc36
sudo dnf install ./kernel-*
and lock it with
sudo dnf versionlock add kernel-5.18.9-200.fc36
then unlock when the problem will be fixed whith
sudo dnf versionlock delete kernel-5.18.200.fc36
Otherwise you should follow @Walter Roberson advice

댓글을 달려면 로그인하십시오.


FEDERICO
FEDERICO 2023년 3월 30일
SOLUTION, LATEST KERNEL, MATLAB R2022b
Make sure to chose a TMPDIR inside your /home partition:
Since It is needed to do it any time you open matlab.
Open (or create) startup.m in your userpath folder, with the following command:
edit(fullfile(userpath,'startup.m'))
And then place inside this file the following line (with the correct folder path):
setenv('TMPDIR','/home/youruser/yourtempdir');

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by