• 【原创】Linux基础之挂载硬盘


    1 查看哪些硬盘没有挂载

    # fdisk -l

    Disk /dev/vdb: 107.4 GB, 107374182400 bytes, 209715200 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

    2 将新硬盘分区

    # 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 0xd5cf1096.

    Command (m for help): m
    Command action
    a toggle a bootable flag
    b edit bsd disklabel
    c toggle the dos compatibility flag
    d delete a partition
    g create a new empty GPT partition table
    G create an IRIX (SGI) partition table
    l list known partition types
    m print this menu
    n add a new partition
    o create a new empty DOS partition table
    p print the partition table
    q quit without saving changes
    s create a new empty Sun disklabel
    t change a partition's system id
    u change display/entry units
    v verify the partition table
    w write table to disk and exit
    x extra functionality (experts only)

    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): 1
    First sector (2048-209715199, default 2048):
    Using default value 2048
    Last sector, +sectors or +size{K,M,G} (2048-209715199, default 209715199):
    Using default value 209715199
    Partition 1 of type Linux and of size 100 GiB is set

    Command (m for help): p

    Disk /dev/vdb: 107.4 GB, 107374182400 bytes, 209715200 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: 0xd5cf1096

    Device Boot Start End Blocks Id System
    /dev/vdb1 2048 209715199 104856576 83 Linux

    Command (m for help): w
    The partition table has been altered!

    Calling ioctl() to re-read partition table.
    Syncing disks.

    3 指定分区的文件系统格式

    ext2

    # mke2fs /dev/sda1

    ext3

    # mke2fs -j /dev/sda1

    ext4

    # mke2fs -t ext4 /dev/sda1

    btrfs

    # mkfs.btrfs -f /dev/sda1

    3.1 查看各个分区的文件系统格式

    # parted -l
    # file -s /dev/sda1
    # df -T

    4 挂载分区到目录

    # mkdir /test
    # mount /dev/sda1 /test

    4.1 永久挂载

    # vi /etc/fstab

    /dev/sda1 /test ext4 defaults 1 1

    5 查看目录以及分区

    # df -h

    如果想通过uuid的方式来挂载磁盘,可以在这里查看每个磁盘分区的uuid

    # /dev/disk/by-uuid/ 

  • 相关阅读:
    zookeeper 入门知识
    MySQL: InnoDB的并发控制,锁,事务模型
    分布式理论: CAP、BASE (转)
    Nginx 入门了解
    基于RSA的前后端登陆密码加密JAVA实现(转)
    分库分表?如何做到永不迁移数据和避免热点? (转)
    node.js(一)
    c# 事件
    C#委托
    SQL Server控制执行计划
  • 原文地址:https://www.cnblogs.com/barneywill/p/10365848.html
Copyright © 2020-2023  润新知