1

I wish to test code that may have trouble on file systems that do not support d_type. In order to do so I would like to create two small xfs file systems that respectively have ftype=0 which does not support d_type, and ftype=1 which does.

I'd like to run these tests in a Docker container as that is how our testing is set up. It looks like I might be able to take advantage of the Docker devicemapper https://docs.docker.com/storage/storagedriver/device-mapper-driver/ .

I do not necessarily control the Docker Engine, that is I don't want to rely on creating these filesystems on the underlying machine and then exposing them to my container - so I would want to be able to do this in my Dockerfile or one I am running in the container.

But maybe there are other or better ways to do this.

  • Docker generally tries to hide details like the underlying file system from the container, and there are some layers of indirection you don't see or control. A container also typically can't mount new filesystems. A virtual machine with a virtual disk where you can manually `mkfs.xfs` might be a better match. – David Maze May 21 '21 at 17:33
  • I agree @DavidMaze that a VM would offer an easy solution but we currently use GitLab Runners based on Docker for CICD and if I can do it in that context it would be good. If not, then I move on. – Andrew Kaluzniacki May 21 '21 at 17:54

1 Answers1

1

I'm not sure this is a complete answer but hopefully a step towards it.

I am trying to do something similar. I want to do some tests using at least xfs, tmpfs & sshfs. I was hoping to find a fuse solution to emulate xfs as well.

You could definitely put a tmpfs, fuse-sshfs and even nfs inside a docker.

I have no experience with nbd but I think you could it within docker to provide xfs via a loopback device. See this blog for example.

This might not be necessary though as you can mount an image as a partition E.g.

mount -t <fs type> -o loop file.img /mnt

Assuming this works in docker we have our solution. I haven't tried this myself yet. If you get there first please post your solution (perhaps you did as this question is a year old).

See also Emulate a hard drive in Linux

Otherwise vagrant is probably good solution for this kind of problem.

Bruce Adams
  • 4,953
  • 4
  • 48
  • 111