zoukankan      html  css  js  c++  java
  • Linux新加硬盘如何识别 分区 持续挂载

    首先把500G硬盘插入    然后查看

    [root@localhost ~]# lsblk
    NAME     MAJ:MIN   RM   SIZE  RO   TYPE   MOUNTPOINT
    sda        8:0      0    20G   0   disk
    ├─sda1     8:1      0     1G   0   part /boot
    ├─sda2     8:2      0     2G   0   part [SWAP]
    └─sda3     8:3      0    17G   0   part /
    sr0        11:0     1   918M   0   rom

    没有识别硬盘

    查看当前系统的host目录

    [root@linux-host1 ~]# ls /sys/class/scsi_host/ -l
    total 0
    lrwxrwxrwx. 1 root root 0 Nov 4 1622 host0 -> ../../devices/pci0000:00/0000:00:10.0/host0/scsi_host/host0
    lrwxrwxrwx. 1 root root 0 Nov 4 1622 host1 -> ../../devices/pci0000:00/0000:00:07.1/ata1/host1/scsi_host/host1
    lrwxrwxrwx. 1 root root 0 Nov 4 1622 host2 -> ../../devices/pci0000:00/0000:00:07.1/ata2/host2/scsi_host/host2
    lrwxrwxrwx. 1 root root 0 Nov 4 1622 host3 -> ../../devices/pci0000:00/0000:00:07.1/ata3/host3/scsi_host/host3

    接着执行

    echo "- - -"> /sys/class/scsi_host/host0/scan
    echo "- - -"> /sys/class/scsi_host/host1/scan
    echo "- - -"> /sys/class/scsi_host/host2/scan
    echo "- - -"> /sys/class/scsi_host/host3/scan

    再次查看

    [root@localhost ~]# lsblk
    NAME     MAJ:MIN   RM   SIZE  RO   TYPE   MOUNTPOINT
    sda        8:0      0    20G   0   disk
    ├─sda1     8:1      0     1G   0   part /boot
    ├─sda2     8:2      0     2G   0   part [SWAP]
    └─sda3     8:3      0    17G   0   part /
    sdb        816   0  500G   0   disk
    sr0        11:0     1   918M   0   rom
    [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 0x4822f5b8.
    
    Command (m for help): n
    Partition type:
      p  primary (0 primary, 0 extended, 4 free)
      e  extended
    Select (default p): p
    Partition number (1-4, default 1):
    First sector (2048-1048575999, default 2048):
    Using default value 2048
    Last sector, +sectors or +size{K,M,G} (2048-1048575999, default 1048575999):
    Using default value 1048575999
    Partition 1 of type Linux and of size 500 GiB is set
    
    Command (m for help): w
    The partition table has been altered!
    
    Calling ioctl() to re-read partition table.
    Syncing disks.
    
    [root@localhost ~]#
    [root@localhost ~]# lsblk
    NAME     MAJ:MIN  RM   SIZE   RO TYPE   MOUNTPOINT
    sda           8:0     0     20G     0 disk
    ├─sda1        8:1     0      1G     0 part /boot
    ├─sda2        8:2     0      2G     0 part [SWAP]
    └─sda3        8:3     0     17G     0 part /
    sdb           8:16    0    500G     0 disk
    └─sdb1        8:17    0    500G     0 part
    sr0 11:0 1 918M 0 rom
    [root@localhost ~]#
    [root@localhost ~]#
    [root@localhost ~]# mkfs.ext4 /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
    32768000 inodes, 131071744 blocks
    6553587 blocks (5.00%) reserved for the super user
    First data block=0
    Maximum filesystem blocks=2279604224
    4000 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, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
        102400000
    Allocating group tables: done
    Writing inode tables: done
    Creating journal (32768 blocks): done
    Writing superblocks and filesystem accounting information: done
    
    [root@localhost ~]#
    [root@localhost ~]# vim /etc/fstab
    [root@localhost ~]#
    [root@localhost ~]# cat /etc/fstab
    # #
    /etc/fstab
    # Created by anaconda on Sat Oct 26 16:30:05 2019
    # #
    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=8741f8b3-f01d-4e6b-bfa1-99b38551ea2c /           xfs        defaults 0 0
    UUID=301fa7cc-ec30-442a-8795-76d98b31b0c6 /boot       xfs        defaults 0 0
    UUID=933d254a-8dec-41dd-9f84-f4d08d396796 swap       swap        defaults 0 0
    /dev/sdb1 /data/log                                  ext4        defaults 0 0
    
    
    [root@localhost ~]#
    [root@localhost ~]# mkdir -pv /data/log
    mkdir: created directory ‘/data’
    mkdir: created directory ‘/data/log’
    [root@localhost ~]#
    [root@localhost ~]# mount -a 
  • 相关阅读:
    浅析Python中bytes和str区别
    Python面对对象相关知识总结
    Django实现微信公众号简单自动回复
    阿里云部署django实现公网访问
    JDBC学习笔记(1)——JDBC概述
    Java单元测试初体验(JUnit4)
    Java设计模式系列之动态代理模式(转载)
    Java设计模式系列之责任链模式
    Java设计模式系列之观察者模式
    局部内部类和匿名内部类的对比
  • 原文地址:https://www.cnblogs.com/zhangty333/p/13941541.html
Copyright © 2011-2022 走看看