mount.go 3.9 KB

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