162306a36Sopenharmony_ci.. SPDX-License-Identifier: GPL-2.0
262306a36Sopenharmony_ci
362306a36Sopenharmony_ci===========================================
462306a36Sopenharmony_ciMounting root file system via SMB (cifs.ko)
562306a36Sopenharmony_ci===========================================
662306a36Sopenharmony_ci
762306a36Sopenharmony_ciWritten 2019 by Paulo Alcantara <palcantara@suse.de>
862306a36Sopenharmony_ci
962306a36Sopenharmony_ciWritten 2019 by Aurelien Aptel <aaptel@suse.com>
1062306a36Sopenharmony_ci
1162306a36Sopenharmony_ciThe CONFIG_CIFS_ROOT option enables experimental root file system
1262306a36Sopenharmony_cisupport over the SMB protocol via cifs.ko.
1362306a36Sopenharmony_ci
1462306a36Sopenharmony_ciIt introduces a new kernel command-line option called 'cifsroot='
1562306a36Sopenharmony_ciwhich will tell the kernel to mount the root file system over the
1662306a36Sopenharmony_cinetwork by utilizing SMB or CIFS protocol.
1762306a36Sopenharmony_ci
1862306a36Sopenharmony_ciIn order to mount, the network stack will also need to be set up by
1962306a36Sopenharmony_ciusing 'ip=' config option. For more details, see
2062306a36Sopenharmony_ciDocumentation/admin-guide/nfs/nfsroot.rst.
2162306a36Sopenharmony_ci
2262306a36Sopenharmony_ciA CIFS root mount currently requires the use of SMB1+UNIX Extensions
2362306a36Sopenharmony_ciwhich is only supported by the Samba server. SMB1 is the older
2462306a36Sopenharmony_cideprecated version of the protocol but it has been extended to support
2562306a36Sopenharmony_ciPOSIX features (See [1]). The equivalent extensions for the newer
2662306a36Sopenharmony_cirecommended version of the protocol (SMB3) have not been fully
2762306a36Sopenharmony_ciimplemented yet which means SMB3 doesn't support some required POSIX
2862306a36Sopenharmony_cifile system objects (e.g. block devices, pipes, sockets).
2962306a36Sopenharmony_ci
3062306a36Sopenharmony_ciAs a result, a CIFS root will default to SMB1 for now but the version
3162306a36Sopenharmony_cito use can nonetheless be changed via the 'vers=' mount option.  This
3262306a36Sopenharmony_cidefault will change once the SMB3 POSIX extensions are fully
3362306a36Sopenharmony_ciimplemented.
3462306a36Sopenharmony_ci
3562306a36Sopenharmony_ciServer configuration
3662306a36Sopenharmony_ci====================
3762306a36Sopenharmony_ci
3862306a36Sopenharmony_ciTo enable SMB1+UNIX extensions you will need to set these global
3962306a36Sopenharmony_cisettings in Samba smb.conf::
4062306a36Sopenharmony_ci
4162306a36Sopenharmony_ci    [global]
4262306a36Sopenharmony_ci    server min protocol = NT1
4362306a36Sopenharmony_ci    unix extension = yes        # default
4462306a36Sopenharmony_ci
4562306a36Sopenharmony_ciKernel command line
4662306a36Sopenharmony_ci===================
4762306a36Sopenharmony_ci
4862306a36Sopenharmony_ci::
4962306a36Sopenharmony_ci
5062306a36Sopenharmony_ci    root=/dev/cifs
5162306a36Sopenharmony_ci
5262306a36Sopenharmony_ciThis is just a virtual device that basically tells the kernel to mount
5362306a36Sopenharmony_cithe root file system via SMB protocol.
5462306a36Sopenharmony_ci
5562306a36Sopenharmony_ci::
5662306a36Sopenharmony_ci
5762306a36Sopenharmony_ci    cifsroot=//<server-ip>/<share>[,options]
5862306a36Sopenharmony_ci
5962306a36Sopenharmony_ciEnables the kernel to mount the root file system via SMB that are
6062306a36Sopenharmony_cilocated in the <server-ip> and <share> specified in this option.
6162306a36Sopenharmony_ci
6262306a36Sopenharmony_ciThe default mount options are set in fs/smb/client/cifsroot.c.
6362306a36Sopenharmony_ci
6462306a36Sopenharmony_ciserver-ip
6562306a36Sopenharmony_ci	IPv4 address of the server.
6662306a36Sopenharmony_ci
6762306a36Sopenharmony_cishare
6862306a36Sopenharmony_ci	Path to SMB share (rootfs).
6962306a36Sopenharmony_ci
7062306a36Sopenharmony_cioptions
7162306a36Sopenharmony_ci	Optional mount options. For more information, see mount.cifs(8).
7262306a36Sopenharmony_ci
7362306a36Sopenharmony_ciExamples
7462306a36Sopenharmony_ci========
7562306a36Sopenharmony_ci
7662306a36Sopenharmony_ciExport root file system as a Samba share in smb.conf file::
7762306a36Sopenharmony_ci
7862306a36Sopenharmony_ci    ...
7962306a36Sopenharmony_ci    [linux]
8062306a36Sopenharmony_ci	    path = /path/to/rootfs
8162306a36Sopenharmony_ci	    read only = no
8262306a36Sopenharmony_ci	    guest ok = yes
8362306a36Sopenharmony_ci	    force user = root
8462306a36Sopenharmony_ci	    force group = root
8562306a36Sopenharmony_ci	    browseable = yes
8662306a36Sopenharmony_ci	    writeable = yes
8762306a36Sopenharmony_ci	    admin users = root
8862306a36Sopenharmony_ci	    public = yes
8962306a36Sopenharmony_ci	    create mask = 0777
9062306a36Sopenharmony_ci	    directory mask = 0777
9162306a36Sopenharmony_ci    ...
9262306a36Sopenharmony_ci
9362306a36Sopenharmony_ciRestart smb service::
9462306a36Sopenharmony_ci
9562306a36Sopenharmony_ci    # systemctl restart smb
9662306a36Sopenharmony_ci
9762306a36Sopenharmony_ciTest it under QEMU on a kernel built with CONFIG_CIFS_ROOT and
9862306a36Sopenharmony_ciCONFIG_IP_PNP options enabled::
9962306a36Sopenharmony_ci
10062306a36Sopenharmony_ci    # qemu-system-x86_64 -enable-kvm -cpu host -m 1024 \
10162306a36Sopenharmony_ci    -kernel /path/to/linux/arch/x86/boot/bzImage -nographic \
10262306a36Sopenharmony_ci    -append "root=/dev/cifs rw ip=dhcp cifsroot=//10.0.2.2/linux,username=foo,password=bar console=ttyS0 3"
10362306a36Sopenharmony_ci
10462306a36Sopenharmony_ci
10562306a36Sopenharmony_ci1: https://wiki.samba.org/index.php/UNIX_Extensions
106