首页 > 其他分享 >玩转树莓派[02树莓派+u盘搭建家庭共享]

玩转树莓派[02树莓派+u盘搭建家庭共享]

时间:2022-10-10 21:56:21浏览次数:79  
标签:02 树莓 4096 sectors bytes dev 玩转 512 size


title: 玩转树莓派[02:树莓派+u盘搭建家庭共享]
excerpt: 论智慧家庭~
tags: [raspberry, 基地2.0,samba,家庭共享,U盘,挂载]
categories:


1.硬盘挂载

1.1 使用fdisk -l 查看硬盘的详细信息

pi@raspbian:~$ sudo fdisk -l
Disk /dev/ram0: 4 MiB, 4194304 bytes, 8192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk /dev/ram1: 4 MiB, 4194304 bytes, 8192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk /dev/ram2: 4 MiB, 4194304 bytes, 8192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk /dev/ram3: 4 MiB, 4194304 bytes, 8192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk /dev/ram4: 4 MiB, 4194304 bytes, 8192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk /dev/ram5: 4 MiB, 4194304 bytes, 8192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk /dev/ram6: 4 MiB, 4194304 bytes, 8192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk /dev/ram7: 4 MiB, 4194304 bytes, 8192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk /dev/ram8: 4 MiB, 4194304 bytes, 8192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk /dev/ram9: 4 MiB, 4194304 bytes, 8192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk /dev/ram10: 4 MiB, 4194304 bytes, 8192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk /dev/ram11: 4 MiB, 4194304 bytes, 8192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk /dev/ram12: 4 MiB, 4194304 bytes, 8192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk /dev/ram13: 4 MiB, 4194304 bytes, 8192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk /dev/ram14: 4 MiB, 4194304 bytes, 8192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk /dev/ram15: 4 MiB, 4194304 bytes, 8192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk /dev/mmcblk0: 29.9 GiB, 32105299968 bytes, 62705664 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
Disklabel type: dos
Disk identifier: 0x68339dda
Device         Boot  Start      End  Sectors  Size Id Type
/dev/mmcblk0p1 *      8192   524287   516096  252M  c W95 FAT32 (LBA)
/dev/mmcblk0p2      524288 62705663 62181376 29.7G 83 Linux
Disk /dev/sda: 30 GiB, 32212254720 bytes, 62914560 sectors
Disk model: U310
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xb64d29a8
Device     Boot Start      End  Sectors Size Id Type
/dev/sda1        8192 62914559 62906368  30G  7 HPFS/NTFS/exFAT

1.2 挂载到指定位置

pi@raspbian:~$ mkdir share
pi@raspbian:~$ ls
share
pi@raspbian:~$ sudo mount /dev/sda1 share

1.3 查看挂载情况

df -h
pi@raspbian:~$ df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/root        30G  4.2G   24G  15% /
devtmpfs        918M     0  918M   0% /dev
tmpfs           950M     0  950M   0% /dev/shm
tmpfs           950M  8.9M  941M   1% /run
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           950M     0  950M   0% /sys/fs/cgroup
/dev/mmcblk0p1  252M   71M  181M  29% /boot
tmpfs           190M     0  190M   0% /run/user/1000
/dev/sda1        30G   19G  9.9G  65% /home/pi/share

取消挂载 : sudo umount /dev/sda1

1.4 解决硬盘的自动挂载

每次树莓派重启或者硬盘插拔都需要对硬盘进行重新挂载,比较麻烦,因此需要自动挂载。这里要修改/etc/fstab文件。

可以看到,fstab文件其实就是一个表格,表格各列的含意如下:
第一列:磁盘分区名/卷标,一般是/dev/sdaN(N表示正整数)
第二列:挂载点,我们在这里把/dev/sda1挂到/samba上。
第三列:缺省设置,一般用defautls。
第四列:是否备份:0——表示不做 dump 备份;1——表示要将整个 fie sysytem 里的内容备份;2 也表示要做 dump 备份,但该分区的重要性比 1 小。
第五列:检测顺序:0——不进行检测;根分区(/),必须填写 1,其它的都不能填写 1。如果有分区填写大于 1 的话,则在检查完根分区后,从小到大依次检查下去。
具体填写方法在图中已注明。

2.df -h查看盘符挂载情况

pi@raspbian:~$ df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            788M     0  788M   0% /dev
tmpfs           185M   12M  173M   7% /run
/dev/mmcblk0p2   30G  8.8G   20G  32% /
tmpfs           925M     0  925M   0% /dev/shm
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
tmpfs           925M     0  925M   0% /sys/fs/cgroup
/dev/mmcblk0p1  252M   89M  163M  36% /boot
tmpfs           185M   16K  185M   1% /run/user/1000
/dev/sda        500G   28G  473G   6% /media/pi/AE57-581F

3.已知盘符已自动挂载在/home/pi/share文件夹下

4.安装samba

更新一下源 :sudo apt-get update

安装samba : sudo apt-get install samba samba-common-bin

5.安装完成后,配置/etc/samba/smb.conf文件

sudo vim /etc/samba/smb.conf

<span class=label label-primary">在其最后添加以下命令:

#共享文件的名称,将在网络上以此名称显示
path = /home/pi/share #共享文件的路径
valid users = root pi #允许访问的用户,这里我用的是root 和 pi 两个用户
browseable = yes  #允许浏览
public = yes  #共享开放
writable = yes  #可写

6.保存后,重启samba服务

sudo /usr/sbin/samba restart

(可通过 whereis samba 寻找 samba 所在位置)

7.最后使用root用户添加共享用户:

smbpasswd –a pi #这里我用的pi。

pi@raspbian:~$ sudo su
root@raspbian:/home/pi# smbpasswd -a pi
New SMB password:
Retype new SMB password:
Added user pi

8.ok 完成

参考

标签:02,树莓,4096,sectors,bytes,dev,玩转,512,size
From: https://www.cnblogs.com/baixf-xyz/p/16777548.html

相关文章

  • 玩转树莓派[01装系统]
    title:玩转树莓派[01:装系统]excerpt:基于树莓派爱好者基地的魔改系统(官方系统同)tags:[raspberry,基地2.0,系统]categories:[学习,raspberry]index_img:https......
  • 玩转树莓派[04pi-dashboard实时监控]
    title:玩转树莓派[04:pi-dashboard实时监控]excerpt:先搞一个本地树莓派监控网页tags:[raspberry,基地2.0,系统,mariadb,myadmin,mysqlmysql,nginxnginx,ph......
  • 玩转树莓派[03安装宝塔]
    title:玩转树莓派[03:安装宝塔]excerpt:开始快速搭建属于自己的网站了~tags:[raspberry,基地2.0,宝塔]categories:[学习,raspberry]index_img:https://pictu......
  • 玩转树莓派[05私有云搭建]
    title:玩转树莓派[05:私有云搭建]excerpt:我要……大战百度网盘!!tags:[raspberry,私有云,nextcloud]categories:[学习,raspberry]index_img:https://picture-s......
  • 2022-10-10学习内容
    1.RelativeLayout1.1activity_relative_layout.xml<?xmlversion="1.0"encoding="utf-8"?><RelativeLayoutxmlns:android="http://schemas.android.com/apk/res/andr......
  • 2022NOIPA层联测6
    设密码比较失败,所以,A.构造字符串(str)并查集维护一下相同的位置,注意到$LCP+1$位置不同,于是每个集合取出来最靠前的为代表,两个集合不同,大集合向小集合连边,每次集合复......
  • #yyds干货盘点#【愚公系列】2022年10月 微信小程序-全局配置属性之页面配置
    前言微信小程序是由一个个单页面组成,每个页面都是由固定规则的。小程序页面自身分为两个主要部分独立运行:view模块和service模块。在开发者工具中,它们独立运行于不同的......
  • Java Web 02
    DDL:操作数据库查询:showdatabases;-- 显示所有数据库 selectdatabase();--查询当前所使用的数据库创建:creatdatabase数据库名 ;creatdatabaseifno......
  • 【闲话】2022.10.10
    真的帮我妈登上了cnblogs好诶!今天Accoders考试T3T4真的不想改了除非我学到那一部分然后干了干李超树我完全明白了(不是继续搜索终于知道A*的用法了我好菜......
  • 20221005(补
    20221005题目简单点朴素算法​ 很容易想到存下每个位置后离它最近的各个字母的位置。然后再暴力地从答案区间\([l,r]\)的离左端点最近的\(e\)开始按\(e,a,s,y\)的顺序......