cifsroot.rst 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. .. SPDX-License-Identifier: GPL-2.0
  2. ===========================================
  3. Mounting root file system via SMB (cifs.ko)
  4. ===========================================
  5. Written 2019 by Paulo Alcantara <palcantara@suse.de>
  6. Written 2019 by Aurelien Aptel <aaptel@suse.com>
  7. The CONFIG_CIFS_ROOT option enables experimental root file system
  8. support over the SMB protocol via cifs.ko.
  9. It introduces a new kernel command-line option called 'cifsroot='
  10. which will tell the kernel to mount the root file system over the
  11. network by utilizing SMB or CIFS protocol.
  12. In order to mount, the network stack will also need to be set up by
  13. using 'ip=' config option. For more details, see
  14. Documentation/admin-guide/nfs/nfsroot.rst.
  15. A CIFS root mount currently requires the use of SMB1+UNIX Extensions
  16. which is only supported by the Samba server. SMB1 is the older
  17. deprecated version of the protocol but it has been extended to support
  18. POSIX features (See [1]). The equivalent extensions for the newer
  19. recommended version of the protocol (SMB3) have not been fully
  20. implemented yet which means SMB3 doesn't support some required POSIX
  21. file system objects (e.g. block devices, pipes, sockets).
  22. As a result, a CIFS root will default to SMB1 for now but the version
  23. to use can nonetheless be changed via the 'vers=' mount option. This
  24. default will change once the SMB3 POSIX extensions are fully
  25. implemented.
  26. Server configuration
  27. ====================
  28. To enable SMB1+UNIX extensions you will need to set these global
  29. settings in Samba smb.conf::
  30. [global]
  31. server min protocol = NT1
  32. unix extension = yes # default
  33. Kernel command line
  34. ===================
  35. ::
  36. root=/dev/cifs
  37. This is just a virtual device that basically tells the kernel to mount
  38. the root file system via SMB protocol.
  39. ::
  40. cifsroot=//<server-ip>/<share>[,options]
  41. Enables the kernel to mount the root file system via SMB that are
  42. located in the <server-ip> and <share> specified in this option.
  43. The default mount options are set in fs/smb/client/cifsroot.c.
  44. server-ip
  45. IPv4 address of the server.
  46. share
  47. Path to SMB share (rootfs).
  48. options
  49. Optional mount options. For more information, see mount.cifs(8).
  50. Examples
  51. ========
  52. Export root file system as a Samba share in smb.conf file::
  53. ...
  54. [linux]
  55. path = /path/to/rootfs
  56. read only = no
  57. guest ok = yes
  58. force user = root
  59. force group = root
  60. browseable = yes
  61. writeable = yes
  62. admin users = root
  63. public = yes
  64. create mask = 0777
  65. directory mask = 0777
  66. ...
  67. Restart smb service::
  68. # systemctl restart smb
  69. Test it under QEMU on a kernel built with CONFIG_CIFS_ROOT and
  70. CONFIG_IP_PNP options enabled::
  71. # qemu-system-x86_64 -enable-kvm -cpu host -m 1024 \
  72. -kernel /path/to/linux/arch/x86/boot/bzImage -nographic \
  73. -append "root=/dev/cifs rw ip=dhcp cifsroot=//10.0.2.2/linux,username=foo,password=bar console=ttyS0 3"
  74. 1: https://wiki.samba.org/index.php/UNIX_Extensions