zoukankan      html  css  js  c++  java
  • Linux添加硬盘设备

    1、添加完成磁盘后

    使用fdisk -l 查看计算机硬盘资源。

    出现如下信息:

    [root@localhost Desktop]# fdisk -l

    Disk /dev/sda: 26.8 GB, 26843545600 bytes, 52428800 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: 0x000a61e6

    Device Boot Start End Blocks Id System
    /dev/sda1 * 2048 1026047 512000 83 Linux
    /dev/sda2 1026048 52428799 25701376 8e Linux LVM

    Disk /dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 sectors      <----此处为要操作的磁盘,要管理设备的名称为 /dev/sdb
    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 /dev/mapper/rhel-root: 24.2 GB, 24150802432 bytes, 47169536 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 /dev/mapper/rhel-swap: 2164 MB, 2164260864 bytes, 4227072 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

    [root@localhost Desktop]# 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 0x37e3ca7d.

    Command (m for help): n     <----输入n,尝试添加新分区。

    Partition type:
    p primary (0 primary, 0 extended, 4 free)   <----创建主分区
    e extended                                                 <----创建扩展分区
    Select (default p): p                                    <----此处创建主分区
    Partition number (1-4, default 1): 1             <----主分区编号1-4,此处默认1
    First sector (2048-41943039, default 2048):
    Using default value 2048
    Last sector, +sectors or +size{K,M,G} (2048-41943039, default 41943039): +5G   <----输入+5G即可创建出一个容量为5G的硬盘分区
    Partition 1 of type Linux and of size 5 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 Desktop]# partprobe         <----partprobe命令手动将分区信息同步到内核

    [root@localhost ~]# mkfs                            <----输入mkfs双击tab键
    mkfs mkfs.cramfs mkfs.ext3 mkfs.fat mkfs.minix mkfs.vfat
    mkfs.btrfs mkfs.ext2 mkfs.ext4 mkfs.gfs2 mkfs.msdos mkfs.xfs
    [root@localhost ~]# mkfs.xfs /dev/sdb1       <----选择mkfs.xfs 格式化
    meta-data=/dev/sdb1 isize=256 agcount=4, agsize=327680 blks
    = sectsz=512 attr=2, projid32bit=1
    = crc=0
    data = bsize=4096 blocks=1310720, imaxpct=25
    = sunit=0 swidth=0 blks
    naming =version 2 bsize=4096 ascii-ci=0 ftype=0
    log =internal log bsize=4096 blocks=2560, version=2
    = sectsz=512 sunit=0 blks, lazy-count=1
    realtime =none extsz=4096 blocks=0, rtextents=0

    格式化完毕

    [root@localhost /]# mkdir /newFS             <----创建newFS
    [root@localhost /]# mount /dev/sdb1 /newFS/    <----挂载

    [root@localhost /]# df -l                              <----查看本地文件系统
    Filesystem 1K-blocks Used Available Use% Mounted on
    /dev/mapper/rhel-root 23573252 4679212 18894040 20% /
    devtmpfs 929800 0 929800 0% /dev
    tmpfs 939104 140 938964 1% /dev/shm
    tmpfs 939104 9068 930036 1% /run
    tmpfs 939104 0 939104 0% /sys/fs/cgroup
    /dev/sda1 508588 124220 384368 25% /boot
    /dev/sdb1 5232640 32928 5199712 1% /newFS  <----已经挂载到newFS

  • 相关阅读:
    第三方驱动备份与还原
    Greenplum 解决 gpstop -u 指令报错
    yum安装(卸载)本地rpm包的方法(卸载本地安装的greenplum 5.19.rpm)
    Java JUC(java.util.concurrent工具包)
    netty 详解(八)基于 Netty 模拟实现 RPC
    netty 详解(七)netty 自定义协议解决 TCP 粘包和拆包
    netty 详解(六)netty 自定义编码解码器
    netty 详解(五)netty 使用 protobuf 序列化
    netty 详解(四)netty 开发 WebSocket 长连接程序
    netty 详解(三)netty 心跳检测机制案例
  • 原文地址:https://www.cnblogs.com/Azaimer/p/10749221.html
Copyright © 2011-2022 走看看