树莓3B+_挂载硬盘
前面参考: http://www.cnblogs.com/xiaowuyi/p/4051238.html
- 插上硬盘,查看状态
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | root@raspberrypi: /home/pi # 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.7 GiB, 31914983424 bytes, 62333952 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: 0xa0068976 Device Boot Start End Sectors Size Id Type /dev/mmcblk0p1 8192 98045 89854 43.9M c W95 FAT32 (LBA) /dev/mmcblk0p2 98304 62333951 62235648 29.7G 83 Linux Disk /dev/sda : 465.8 GiB, 500107862016 bytes, 976773168 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: 0xff2d845c Device Boot Start End Sectors Size Id Type /dev/sda1 2048 976766975 976764928 465.8G 83 Linux |
- 使用df 命令查看自动挂载的硬盘
df命令的功能是用来检查linux服务器的文件系统的磁盘空间占用情况。可以利用该命令来获取硬盘被占用了多少空间,目前还剩下多少空间等信息。
1 2 3 4 5 6 7 8 9 10 11 | root@raspberrypi: /home/pi # df -h 文件系统 容量 已用 可用 已用% 挂载点 /dev/root 30G 4.8G 24G 18% / devtmpfs 434M 0 434M 0% /dev tmpfs 438M 0 438M 0% /dev/shm tmpfs 438M 12M 427M 3% /run tmpfs 5.0M 4.0K 5.0M 1% /run/lock tmpfs 438M 0 438M 0% /sys/fs/cgroup /dev/mmcblk0p1 44M 23M 22M 51% /boot tmpfs 88M 0 88M 0% /run/user/1000 /dev/sda1 437G 8.0K 414G 1% /media/pi/nas465 |
最后一行/dev/sda1说明硬盘已经挂载。
为下一步安装samba,将共享文件夹设为/samba。
于是新建文件夹:
1 | mkdir /samba |
设置访问权限:
1 | chmod 777 /samba |
将硬盘挂载到/samba文件夹:
1 | umount /dev/sda1 #取消自动的挂载 |
1 | mount /dev/sda1 /samba #将硬盘挂载到/samba文件夹 |
- 使用df 命令再次查看挂载的硬盘
1 2 3 4 5 6 7 8 9 10 11 | root@raspberrypi: /home/pi # df -h 文件系统 容量 已用 可用 已用% 挂载点 /dev/root 30G 4.8G 24G 18% / devtmpfs 434M 0 434M 0% /dev tmpfs 438M 0 438M 0% /dev/shm tmpfs 438M 12M 427M 3% /run tmpfs 5.0M 4.0K 5.0M 1% /run/lock tmpfs 438M 0 438M 0% /sys/fs/cgroup /dev/mmcblk0p1 44M 23M 22M 51% /boot tmpfs 88M 0 88M 0% /run/user/1000 /dev/sda1 437G 8.0K 414G 1% /samba |
- 解决硬盘的自动挂载
每次树莓派重启或者硬盘插拔都需要对硬盘进行重新挂载,比较麻烦,因此需要自动挂载。这里要修改/etc/fstab文件。
1 | sudo nano /etc/fstab |
1 2 3 4 5 | proc /proc proc defaults 0 0 PARTUUID=a0068976-01 /boot vfat defaults 0 2 PARTUUID=a0068976-02 / ext4 defaults,noatime 0 1 # a swapfile is not a swap partition, no line here # use dphys-swapfile swap[on|off] for that |
修改后:
1 2 3 4 5 6 | proc /proc proc defaults 0 0 PARTUUID=a0068976-01 /boot vfat defaults 0 2 PARTUUID=a0068976-02 / ext4 defaults,noatime 0 1 /dev/sda1 /samba ext4 defaults 0 0 # a swapfile is not a swap partition, no line here # use dphys-swapfile swap[on|off] for that |
备注:
可以看到,fstab文件其实就是一个表格,表格各列的含意如下:
第一列:磁盘分区名/卷标,一般是/dev/sdaN(N表示正整数)
第二列:挂载点,我们在这里把/dev/sda1挂到/samba上。
第三列:缺省设置,一般用defautls。
第四列:是否备份:0——表示不做 dump 备份;1——表示要将整个 <fie sysytem> 里的内容备份;2 也表示要做 dump 备份,但该分区的重要性比 1 小。
第五列:检测顺序:0——不进行检测;根分区(/),必须填写 1,其它的都不能填写 1。如果有分区填写大于 1 的话,则在检查完根分区后,从小到大依次检查下去。
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· .NET Core 托管堆内存泄露/CPU异常的常见思路
· PostgreSQL 和 SQL Server 在统计信息维护中的关键差异
· C++代码改造为UTF-8编码问题的总结
· DeepSeek 解答了困扰我五年的技术问题
· 为什么说在企业级应用开发中,后端往往是效率杀手?
· Deepseek官网太卡,教你白嫖阿里云的Deepseek-R1满血版
· 2分钟学会 DeepSeek API,竟然比官方更好用!
· .NET 使用 DeepSeek R1 开发智能 AI 客户端
· DeepSeek本地性能调优
· 一文掌握DeepSeek本地部署+Page Assist浏览器插件+C#接口调用+局域网访问!全攻略