zoukankan      html  css  js  c++  java
  • 树莓3B+_挂载硬盘

    前面参考:  http://www.cnblogs.com/xiaowuyi/p/4051238.html

    • 插上硬盘,查看状态
    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服务器的文件系统的磁盘空间占用情况。可以利用该命令来获取硬盘被占用了多少空间,目前还剩下多少空间等信息。

    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。

    于是新建文件夹:

    mkdir /samba
    

    设置访问权限:

    chmod 777 /samba
    

    将硬盘挂载到/samba文件夹:

    umount /dev/sda1   #取消自动的挂载
    
    mount /dev/sda1 /samba  #将硬盘挂载到/samba文件夹
    
    • 使用df 命令再次查看挂载的硬盘
    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文件。 

    sudo nano /etc/fstab
    
    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
    

      

    修改后:

    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 的话,则在检查完根分区后,从小到大依次检查下去。

      

      

      

      

  • 相关阅读:
    C#算法,二叉树,单链表,反向链表,stack栈
    系统架构师学习笔记_第十一章(上)_连载
    系统架构师学习笔记_第四章(下)_连载
    [项目过程中所遇到的各种问题记录]ORM篇——使用NHibernate配置对象实体的一些小问题
    含HTML标记的内容分页 (C#)
    PowerShell在SharePoint 2010自动化部署中的应用(1)代码获取
    走向ASP.NET架构设计第一章:走向设计
    asp.net 遍历XML文件节点信息
    系统架构师学习笔记_第一章_连载
    AOP 你想干什么 IOC 你服务什么
  • 原文地址:https://www.cnblogs.com/quixon/p/10424219.html
Copyright © 2011-2022 走看看