xref: /OK3568_Linux_fs/kernel/Documentation/filesystems/cifs/cifsroot.rst (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun.. SPDX-License-Identifier: GPL-2.0
2*4882a593Smuzhiyun
3*4882a593Smuzhiyun===========================================
4*4882a593SmuzhiyunMounting root file system via SMB (cifs.ko)
5*4882a593Smuzhiyun===========================================
6*4882a593Smuzhiyun
7*4882a593SmuzhiyunWritten 2019 by Paulo Alcantara <palcantara@suse.de>
8*4882a593Smuzhiyun
9*4882a593SmuzhiyunWritten 2019 by Aurelien Aptel <aaptel@suse.com>
10*4882a593Smuzhiyun
11*4882a593SmuzhiyunThe CONFIG_CIFS_ROOT option enables experimental root file system
12*4882a593Smuzhiyunsupport over the SMB protocol via cifs.ko.
13*4882a593Smuzhiyun
14*4882a593SmuzhiyunIt introduces a new kernel command-line option called 'cifsroot='
15*4882a593Smuzhiyunwhich will tell the kernel to mount the root file system over the
16*4882a593Smuzhiyunnetwork by utilizing SMB or CIFS protocol.
17*4882a593Smuzhiyun
18*4882a593SmuzhiyunIn order to mount, the network stack will also need to be set up by
19*4882a593Smuzhiyunusing 'ip=' config option. For more details, see
20*4882a593SmuzhiyunDocumentation/admin-guide/nfs/nfsroot.rst.
21*4882a593Smuzhiyun
22*4882a593SmuzhiyunA CIFS root mount currently requires the use of SMB1+UNIX Extensions
23*4882a593Smuzhiyunwhich is only supported by the Samba server. SMB1 is the older
24*4882a593Smuzhiyundeprecated version of the protocol but it has been extended to support
25*4882a593SmuzhiyunPOSIX features (See [1]). The equivalent extensions for the newer
26*4882a593Smuzhiyunrecommended version of the protocol (SMB3) have not been fully
27*4882a593Smuzhiyunimplemented yet which means SMB3 doesn't support some required POSIX
28*4882a593Smuzhiyunfile system objects (e.g. block devices, pipes, sockets).
29*4882a593Smuzhiyun
30*4882a593SmuzhiyunAs a result, a CIFS root will default to SMB1 for now but the version
31*4882a593Smuzhiyunto use can nonetheless be changed via the 'vers=' mount option.  This
32*4882a593Smuzhiyundefault will change once the SMB3 POSIX extensions are fully
33*4882a593Smuzhiyunimplemented.
34*4882a593Smuzhiyun
35*4882a593SmuzhiyunServer configuration
36*4882a593Smuzhiyun====================
37*4882a593Smuzhiyun
38*4882a593SmuzhiyunTo enable SMB1+UNIX extensions you will need to set these global
39*4882a593Smuzhiyunsettings in Samba smb.conf::
40*4882a593Smuzhiyun
41*4882a593Smuzhiyun    [global]
42*4882a593Smuzhiyun    server min protocol = NT1
43*4882a593Smuzhiyun    unix extension = yes        # default
44*4882a593Smuzhiyun
45*4882a593SmuzhiyunKernel command line
46*4882a593Smuzhiyun===================
47*4882a593Smuzhiyun
48*4882a593Smuzhiyun::
49*4882a593Smuzhiyun
50*4882a593Smuzhiyun    root=/dev/cifs
51*4882a593Smuzhiyun
52*4882a593SmuzhiyunThis is just a virtual device that basically tells the kernel to mount
53*4882a593Smuzhiyunthe root file system via SMB protocol.
54*4882a593Smuzhiyun
55*4882a593Smuzhiyun::
56*4882a593Smuzhiyun
57*4882a593Smuzhiyun    cifsroot=//<server-ip>/<share>[,options]
58*4882a593Smuzhiyun
59*4882a593SmuzhiyunEnables the kernel to mount the root file system via SMB that are
60*4882a593Smuzhiyunlocated in the <server-ip> and <share> specified in this option.
61*4882a593Smuzhiyun
62*4882a593SmuzhiyunThe default mount options are set in fs/cifs/cifsroot.c.
63*4882a593Smuzhiyun
64*4882a593Smuzhiyunserver-ip
65*4882a593Smuzhiyun	IPv4 address of the server.
66*4882a593Smuzhiyun
67*4882a593Smuzhiyunshare
68*4882a593Smuzhiyun	Path to SMB share (rootfs).
69*4882a593Smuzhiyun
70*4882a593Smuzhiyunoptions
71*4882a593Smuzhiyun	Optional mount options. For more information, see mount.cifs(8).
72*4882a593Smuzhiyun
73*4882a593SmuzhiyunExamples
74*4882a593Smuzhiyun========
75*4882a593Smuzhiyun
76*4882a593SmuzhiyunExport root file system as a Samba share in smb.conf file::
77*4882a593Smuzhiyun
78*4882a593Smuzhiyun    ...
79*4882a593Smuzhiyun    [linux]
80*4882a593Smuzhiyun	    path = /path/to/rootfs
81*4882a593Smuzhiyun	    read only = no
82*4882a593Smuzhiyun	    guest ok = yes
83*4882a593Smuzhiyun	    force user = root
84*4882a593Smuzhiyun	    force group = root
85*4882a593Smuzhiyun	    browseable = yes
86*4882a593Smuzhiyun	    writeable = yes
87*4882a593Smuzhiyun	    admin users = root
88*4882a593Smuzhiyun	    public = yes
89*4882a593Smuzhiyun	    create mask = 0777
90*4882a593Smuzhiyun	    directory mask = 0777
91*4882a593Smuzhiyun    ...
92*4882a593Smuzhiyun
93*4882a593SmuzhiyunRestart smb service::
94*4882a593Smuzhiyun
95*4882a593Smuzhiyun    # systemctl restart smb
96*4882a593Smuzhiyun
97*4882a593SmuzhiyunTest it under QEMU on a kernel built with CONFIG_CIFS_ROOT and
98*4882a593SmuzhiyunCONFIG_IP_PNP options enabled::
99*4882a593Smuzhiyun
100*4882a593Smuzhiyun    # qemu-system-x86_64 -enable-kvm -cpu host -m 1024 \
101*4882a593Smuzhiyun    -kernel /path/to/linux/arch/x86/boot/bzImage -nographic \
102*4882a593Smuzhiyun    -append "root=/dev/cifs rw ip=dhcp cifsroot=//10.0.2.2/linux,username=foo,password=bar console=ttyS0 3"
103*4882a593Smuzhiyun
104*4882a593Smuzhiyun
105*4882a593Smuzhiyun1: https://wiki.samba.org/index.php/UNIX_Extensions
106