1

/cygdrive/d/ is a USB hard disk formatted as ext2 and mounted with ext2fsd.

When I try cp -al /cygdrive/d/X /cygdrive/d/Y where X is a file, I get the error in the title.

Things I've Tried/Verified

I did chmod -R 777 /cygdrive/d but I still get the same result.

I am running as local administrator, who is the owner of /cygdrive/d.

X is a file, not a directory.

Windows Server 2012 R2 running cygwin64 current as of today.

It's ext2 because I can, for example, touch /cygdrive/d/filename_with_a_colon:in_it and it works and I can see it with ls. Not to mention, it says so in ext2fsd and the Windows Disk Manager.

Ironically, the same syntax on an NTFS drive works fine and creates an NTFS hardlink.

I've also tried reformatting the drive as ext3, with the same results. I had figured on ext2 being more likely to be fully supported on account of it being older than ext3/4, but I guess it doesn't make a difference.

The question

How can I create simple ext2 hardlinks with cygwin?

Kev
  • 1,184

1 Answers1

3

Windows does indeed support hard links. However, the documentation on CreateHardLink says it all:

This function is only supported on the NTFS file system

This limitation is probably hard-coded. Because ext2fsd is clearly not NTFS, Windows will refuse to create hard links on it.

Cygwin provides POSIX API compatibility (of sorts) on top of Windows APIs. This means that it ultimately also calls CreateHardLink and is subject to the same limitations like mklink and other Windows software.

Many tools of the e2fsprogs package (like mke2fs, e2fsck, resize2fs, ...) operate directly on the disk, without relying on filesystem drivers. That’s why the filesystem has to be unmounted before using them to change stuff. This is also why they can work without Windows (natively) being able to access ext2/3/4 at all.

user219095
  • 65,551