Back to home page

OSCL-LXR

 
 

    


0001 .. SPDX-License-Identifier: GPL-2.0
0002 
0003 ===========================================
0004 Mounting root file system via SMB (cifs.ko)
0005 ===========================================
0006 
0007 Written 2019 by Paulo Alcantara <palcantara@suse.de>
0008 
0009 Written 2019 by Aurelien Aptel <aaptel@suse.com>
0010 
0011 The CONFIG_CIFS_ROOT option enables experimental root file system
0012 support over the SMB protocol via cifs.ko.
0013 
0014 It introduces a new kernel command-line option called 'cifsroot='
0015 which will tell the kernel to mount the root file system over the
0016 network by utilizing SMB or CIFS protocol.
0017 
0018 In order to mount, the network stack will also need to be set up by
0019 using 'ip=' config option. For more details, see
0020 Documentation/admin-guide/nfs/nfsroot.rst.
0021 
0022 A CIFS root mount currently requires the use of SMB1+UNIX Extensions
0023 which is only supported by the Samba server. SMB1 is the older
0024 deprecated version of the protocol but it has been extended to support
0025 POSIX features (See [1]). The equivalent extensions for the newer
0026 recommended version of the protocol (SMB3) have not been fully
0027 implemented yet which means SMB3 doesn't support some required POSIX
0028 file system objects (e.g. block devices, pipes, sockets).
0029 
0030 As a result, a CIFS root will default to SMB1 for now but the version
0031 to use can nonetheless be changed via the 'vers=' mount option.  This
0032 default will change once the SMB3 POSIX extensions are fully
0033 implemented.
0034 
0035 Server configuration
0036 ====================
0037 
0038 To enable SMB1+UNIX extensions you will need to set these global
0039 settings in Samba smb.conf::
0040 
0041     [global]
0042     server min protocol = NT1
0043     unix extension = yes        # default
0044 
0045 Kernel command line
0046 ===================
0047 
0048 ::
0049 
0050     root=/dev/cifs
0051 
0052 This is just a virtual device that basically tells the kernel to mount
0053 the root file system via SMB protocol.
0054 
0055 ::
0056 
0057     cifsroot=//<server-ip>/<share>[,options]
0058 
0059 Enables the kernel to mount the root file system via SMB that are
0060 located in the <server-ip> and <share> specified in this option.
0061 
0062 The default mount options are set in fs/cifs/cifsroot.c.
0063 
0064 server-ip
0065         IPv4 address of the server.
0066 
0067 share
0068         Path to SMB share (rootfs).
0069 
0070 options
0071         Optional mount options. For more information, see mount.cifs(8).
0072 
0073 Examples
0074 ========
0075 
0076 Export root file system as a Samba share in smb.conf file::
0077 
0078     ...
0079     [linux]
0080             path = /path/to/rootfs
0081             read only = no
0082             guest ok = yes
0083             force user = root
0084             force group = root
0085             browseable = yes
0086             writeable = yes
0087             admin users = root
0088             public = yes
0089             create mask = 0777
0090             directory mask = 0777
0091     ...
0092 
0093 Restart smb service::
0094 
0095     # systemctl restart smb
0096 
0097 Test it under QEMU on a kernel built with CONFIG_CIFS_ROOT and
0098 CONFIG_IP_PNP options enabled::
0099 
0100     # qemu-system-x86_64 -enable-kvm -cpu host -m 1024 \
0101     -kernel /path/to/linux/arch/x86/boot/bzImage -nographic \
0102     -append "root=/dev/cifs rw ip=dhcp cifsroot=//10.0.2.2/linux,username=foo,password=bar console=ttyS0 3"
0103 
0104 
0105 1: https://wiki.samba.org/index.php/UNIX_Extensions