You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

92 lines
4.5 KiB

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