18c2ecf20Sopenharmony_ci.. SPDX-License-Identifier: GPL-2.0 28c2ecf20Sopenharmony_ci 38c2ecf20Sopenharmony_ci=========================================== 48c2ecf20Sopenharmony_ciMounting root file system via SMB (cifs.ko) 58c2ecf20Sopenharmony_ci=========================================== 68c2ecf20Sopenharmony_ci 78c2ecf20Sopenharmony_ciWritten 2019 by Paulo Alcantara <palcantara@suse.de> 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ciWritten 2019 by Aurelien Aptel <aaptel@suse.com> 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ciThe CONFIG_CIFS_ROOT option enables experimental root file system 128c2ecf20Sopenharmony_cisupport over the SMB protocol via cifs.ko. 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_ciIt introduces a new kernel command-line option called 'cifsroot=' 158c2ecf20Sopenharmony_ciwhich will tell the kernel to mount the root file system over the 168c2ecf20Sopenharmony_cinetwork by utilizing SMB or CIFS protocol. 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_ciIn order to mount, the network stack will also need to be set up by 198c2ecf20Sopenharmony_ciusing 'ip=' config option. For more details, see 208c2ecf20Sopenharmony_ciDocumentation/admin-guide/nfs/nfsroot.rst. 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_ciA CIFS root mount currently requires the use of SMB1+UNIX Extensions 238c2ecf20Sopenharmony_ciwhich is only supported by the Samba server. SMB1 is the older 248c2ecf20Sopenharmony_cideprecated version of the protocol but it has been extended to support 258c2ecf20Sopenharmony_ciPOSIX features (See [1]). The equivalent extensions for the newer 268c2ecf20Sopenharmony_cirecommended version of the protocol (SMB3) have not been fully 278c2ecf20Sopenharmony_ciimplemented yet which means SMB3 doesn't support some required POSIX 288c2ecf20Sopenharmony_cifile system objects (e.g. block devices, pipes, sockets). 298c2ecf20Sopenharmony_ci 308c2ecf20Sopenharmony_ciAs a result, a CIFS root will default to SMB1 for now but the version 318c2ecf20Sopenharmony_cito use can nonetheless be changed via the 'vers=' mount option. This 328c2ecf20Sopenharmony_cidefault will change once the SMB3 POSIX extensions are fully 338c2ecf20Sopenharmony_ciimplemented. 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_ciServer configuration 368c2ecf20Sopenharmony_ci==================== 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_ciTo enable SMB1+UNIX extensions you will need to set these global 398c2ecf20Sopenharmony_cisettings in Samba smb.conf:: 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_ci [global] 428c2ecf20Sopenharmony_ci server min protocol = NT1 438c2ecf20Sopenharmony_ci unix extension = yes # default 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_ciKernel command line 468c2ecf20Sopenharmony_ci=================== 478c2ecf20Sopenharmony_ci 488c2ecf20Sopenharmony_ci:: 498c2ecf20Sopenharmony_ci 508c2ecf20Sopenharmony_ci root=/dev/cifs 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_ciThis is just a virtual device that basically tells the kernel to mount 538c2ecf20Sopenharmony_cithe root file system via SMB protocol. 548c2ecf20Sopenharmony_ci 558c2ecf20Sopenharmony_ci:: 568c2ecf20Sopenharmony_ci 578c2ecf20Sopenharmony_ci cifsroot=//<server-ip>/<share>[,options] 588c2ecf20Sopenharmony_ci 598c2ecf20Sopenharmony_ciEnables the kernel to mount the root file system via SMB that are 608c2ecf20Sopenharmony_cilocated in the <server-ip> and <share> specified in this option. 618c2ecf20Sopenharmony_ci 628c2ecf20Sopenharmony_ciThe default mount options are set in fs/cifs/cifsroot.c. 638c2ecf20Sopenharmony_ci 648c2ecf20Sopenharmony_ciserver-ip 658c2ecf20Sopenharmony_ci IPv4 address of the server. 668c2ecf20Sopenharmony_ci 678c2ecf20Sopenharmony_cishare 688c2ecf20Sopenharmony_ci Path to SMB share (rootfs). 698c2ecf20Sopenharmony_ci 708c2ecf20Sopenharmony_cioptions 718c2ecf20Sopenharmony_ci Optional mount options. For more information, see mount.cifs(8). 728c2ecf20Sopenharmony_ci 738c2ecf20Sopenharmony_ciExamples 748c2ecf20Sopenharmony_ci======== 758c2ecf20Sopenharmony_ci 768c2ecf20Sopenharmony_ciExport root file system as a Samba share in smb.conf file:: 778c2ecf20Sopenharmony_ci 788c2ecf20Sopenharmony_ci ... 798c2ecf20Sopenharmony_ci [linux] 808c2ecf20Sopenharmony_ci path = /path/to/rootfs 818c2ecf20Sopenharmony_ci read only = no 828c2ecf20Sopenharmony_ci guest ok = yes 838c2ecf20Sopenharmony_ci force user = root 848c2ecf20Sopenharmony_ci force group = root 858c2ecf20Sopenharmony_ci browseable = yes 868c2ecf20Sopenharmony_ci writeable = yes 878c2ecf20Sopenharmony_ci admin users = root 888c2ecf20Sopenharmony_ci public = yes 898c2ecf20Sopenharmony_ci create mask = 0777 908c2ecf20Sopenharmony_ci directory mask = 0777 918c2ecf20Sopenharmony_ci ... 928c2ecf20Sopenharmony_ci 938c2ecf20Sopenharmony_ciRestart smb service:: 948c2ecf20Sopenharmony_ci 958c2ecf20Sopenharmony_ci # systemctl restart smb 968c2ecf20Sopenharmony_ci 978c2ecf20Sopenharmony_ciTest it under QEMU on a kernel built with CONFIG_CIFS_ROOT and 988c2ecf20Sopenharmony_ciCONFIG_IP_PNP options enabled:: 998c2ecf20Sopenharmony_ci 1008c2ecf20Sopenharmony_ci # qemu-system-x86_64 -enable-kvm -cpu host -m 1024 \ 1018c2ecf20Sopenharmony_ci -kernel /path/to/linux/arch/x86/boot/bzImage -nographic \ 1028c2ecf20Sopenharmony_ci -append "root=/dev/cifs rw ip=dhcp cifsroot=//10.0.2.2/linux,username=foo,password=bar console=ttyS0 3" 1038c2ecf20Sopenharmony_ci 1048c2ecf20Sopenharmony_ci 1058c2ecf20Sopenharmony_ci1: https://wiki.samba.org/index.php/UNIX_Extensions 106