workgroup = WORKGROUP server string = Samba Server %v netbios name = centos security = user map to guest = bad user dns proxy = no #============================ Share Definitions ============================== [share] path = /data browsable = yes writable = yes guest ok = yes read only = no
设置共享文件夹
1 2
mkdir /data chmod 777 /data
查看端口及防火墙
1 2 3 4
[root@localhost ~]# ss -tnl State Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0 50 *:445 *:* LISTEN 0 50 *:139 *:*
workgroup = WORKGROUP server string = Samba Server %v netbios name = centos security = user map to guest = bad user dns proxy = no #============================ Share Definitions ============================== [share] path = /data valid users = share #添加用户 browsable = yes writable = yes guest ok = yes read only = no
创建指定账户访问
1 2 3 4 5
[root@localhost ~]# useradd share [root@localhost data]# smbpasswd -a share New SMB password: Retype new SMB password: Added user share.
再次访问
三、添加硬盘后增加新的共享文件夹
查看服务器安装的硬盘状态(==可以看到有sdb硬盘,但是没有分区==)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
[root@localhost ~]# fdisk -l
Disk /dev/sda: 53.7 GB, 53687091200 bytes, 104857600 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos Disk identifier: 0x000a9170
Device Boot Start End Blocks Id System /dev/sda1 2048 8390655 4194304 82 Linux swap / Solaris /dev/sda2 * 8390656 104857599 48233472 83 Linux
[root@localhost ~]# fdisk /dev/sdb Welcome to fdisk (util-linux 2.23.2).
Changes will remain in memory only, until you decide to write them. Be careful before using the write command.
Device does not contain a recognized partition table Building a new DOS disklabel with disk identifier 0x78047679.
Command (m forhelp): n Partition type: p primary (0 primary, 0 extended, 4 free) e extended Select (default p): p Partition number (1-4, default 1): 1 First sector (2048-41943039, default 2048): Using default value 2048 Last sector, +sectors or +size{K,M,G} (2048-41943039, default 41943039): Using default value 41943039 Partition 1 of type Linux and of size 20 GiB is set
Command (m forhelp): W The partition table has been altered!
Calling ioctl() to re-read partition table. Syncing disks.
[root@localhost ~]# mkfs -t ext4 -c /dev/sdb1 mke2fs 1.42.9 (28-Dec-2013) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 1310720 inodes, 5242624 blocks 262131 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=2153775104 160 block groups 32768 blocks per group, 32768 fragments per group 8192 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000
Checking for bad blocks (read-only test): done Allocating group tables: done Writing inode tables: done Creating journal (32768 blocks): done Writing superblocks and filesystem accounting information: done
# # /etc/fstab # Created by anaconda on Fri Jan 10 15:18:10 2020 # # Accessible filesystems, by reference, are maintained under '/dev/disk' # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info # UUID=939f9e59-36cc-40d4-b7f6-302a85f949fb / xfs defaults 0 0 UUID=9824e948-e873-4f85-b180-ea2d65718a38 swap swap defaults 0 0 UUID=05a31bcf-1bb9-4076-b268-754a22f0da83 /document ext4 defaults 0 0