mount.go 4.2 KB

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