mount.go 4.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. package command
  2. import (
  3. "os"
  4. "time"
  5. )
  6. type MountOptions struct {
  7. filer *string
  8. filerMountRootPath *string
  9. dir *string
  10. dirAutoCreate *bool
  11. collection *string
  12. collectionQuota *int
  13. replication *string
  14. diskType *string
  15. ttlSec *int
  16. chunkSizeLimitMB *int
  17. concurrentWriters *int
  18. cacheDirForRead *string
  19. cacheDirForWrite *string
  20. cacheSizeMBForRead *int64
  21. dataCenter *string
  22. allowOthers *bool
  23. umaskString *string
  24. nonempty *bool
  25. volumeServerAccess *string
  26. uidMap *string
  27. gidMap *string
  28. readOnly *bool
  29. debug *bool
  30. debugPort *int
  31. localSocket *string
  32. disableXAttr *bool
  33. extraOptions []string
  34. }
  35. var (
  36. mountOptions MountOptions
  37. mountCpuProfile *string
  38. mountMemProfile *string
  39. mountReadRetryTime *time.Duration
  40. )
  41. func init() {
  42. cmdMount.Run = runMount // break init cycle
  43. mountOptions.filer = cmdMount.Flag.String("filer", "localhost:8888", "comma-separated weed filer location")
  44. mountOptions.filerMountRootPath = cmdMount.Flag.String("filer.path", "/", "mount this remote path from filer server")
  45. mountOptions.dir = cmdMount.Flag.String("dir", ".", "mount weed filer to this directory")
  46. mountOptions.dirAutoCreate = cmdMount.Flag.Bool("dirAutoCreate", false, "auto create the directory to mount to")
  47. mountOptions.collection = cmdMount.Flag.String("collection", "", "collection to create the files")
  48. mountOptions.collectionQuota = cmdMount.Flag.Int("collectionQuotaMB", 0, "quota for the collection")
  49. mountOptions.replication = cmdMount.Flag.String("replication", "", "replication(e.g. 000, 001) to create to files. If empty, let filer decide.")
  50. mountOptions.diskType = cmdMount.Flag.String("disk", "", "[hdd|ssd|<tag>] hard drive or solid state drive or any tag")
  51. mountOptions.ttlSec = cmdMount.Flag.Int("ttl", 0, "file ttl in seconds")
  52. mountOptions.chunkSizeLimitMB = cmdMount.Flag.Int("chunkSizeLimitMB", 2, "local write buffer size, also chunk large files")
  53. mountOptions.concurrentWriters = cmdMount.Flag.Int("concurrentWriters", 32, "limit concurrent goroutine writers")
  54. mountOptions.cacheDirForRead = cmdMount.Flag.String("cacheDir", os.TempDir(), "local cache directory for file chunks and meta data")
  55. mountOptions.cacheSizeMBForRead = cmdMount.Flag.Int64("cacheCapacityMB", 0, "file chunk read cache capacity in MB")
  56. mountOptions.cacheDirForWrite = cmdMount.Flag.String("cacheDirWrite", os.TempDir(), "buffer writes mostly for large files")
  57. mountOptions.dataCenter = cmdMount.Flag.String("dataCenter", "", "prefer to write to the data center")
  58. mountOptions.allowOthers = cmdMount.Flag.Bool("allowOthers", true, "allows other users to access the file system")
  59. mountOptions.umaskString = cmdMount.Flag.String("umask", "022", "octal umask, e.g., 022, 0111")
  60. mountOptions.nonempty = cmdMount.Flag.Bool("nonempty", false, "allows the mounting over a non-empty directory")
  61. mountOptions.volumeServerAccess = cmdMount.Flag.String("volumeServerAccess", "direct", "access volume servers by [direct|publicUrl|filerProxy]")
  62. mountOptions.uidMap = cmdMount.Flag.String("map.uid", "", "map local uid to uid on filer, comma-separated <local_uid>:<filer_uid>")
  63. mountOptions.gidMap = cmdMount.Flag.String("map.gid", "", "map local gid to gid on filer, comma-separated <local_gid>:<filer_gid>")
  64. mountOptions.readOnly = cmdMount.Flag.Bool("readOnly", false, "read only")
  65. mountOptions.debug = cmdMount.Flag.Bool("debug", false, "serves runtime profiling data, e.g., http://localhost:<debug.port>/debug/pprof/goroutine?debug=2")
  66. mountOptions.debugPort = cmdMount.Flag.Int("debug.port", 6061, "http port for debugging")
  67. mountOptions.localSocket = cmdMount.Flag.String("localSocket", "", "default to /tmp/seaweedfs-mount-<mount_dir_hash>.sock")
  68. mountOptions.disableXAttr = cmdMount.Flag.Bool("disableXAttr", false, "disable xattr")
  69. mountCpuProfile = cmdMount.Flag.String("cpuprofile", "", "cpu profile output file")
  70. mountMemProfile = cmdMount.Flag.String("memprofile", "", "memory profile output file")
  71. mountReadRetryTime = cmdMount.Flag.Duration("readRetryTime", 6*time.Second, "maximum read retry wait time")
  72. }
  73. var cmdMount = &Command{
  74. UsageLine: "mount -filer=localhost:8888 -dir=/some/dir",
  75. Short: "mount weed filer to a directory as file system in userspace(FUSE)",
  76. Long: `mount weed filer to userspace.
  77. Pre-requisites:
  78. 1) have SeaweedFS master and volume servers running
  79. 2) have a "weed filer" running
  80. These 2 requirements can be achieved with one command "weed server -filer=true"
  81. This uses github.com/seaweedfs/fuse, which enables writing FUSE file systems on
  82. Linux, and OS X.
  83. On OS X, it requires OSXFUSE (https://osxfuse.github.io/).
  84. `,
  85. }