Linux添加新磁盘及挂载学习记录

版权声明:本文为转载文章,源文章链接 https://blog.csdn.net/c1481118216/article/details/81147402

查看磁盘

以root用户登录,执行fdisk -lu查看所有磁盘信息
这里写图片描述

创建分区

进入磁盘/dev/sdb命令: fdisk /dev/sdb 输入m 查看命令帮助如下:

root@lt-PC:/# fdisk /dev/sdb 

Welcome to fdisk (util-linux 2.29.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.
Created a new DOS disklabel with disk identifier 0x886fa276.

Command (m for help): m

Help:

  DOS (MBR)
   a   toggle a bootable flag
   b   edit nested BSD disklabel
   c   toggle the dos compatibility flag

  Generic
   d   delete a partition
   F   list free unpartitioned space
   l   list known partition types
   n   add a new partition
   p   print the partition table
   t   change a partition type
   v   verify the partition table
   i   print information about a partition

  Misc
   m   print this menu
   u   change display/entry units
   x   extra functionality (experts only)

  Script
   I   load disk layout from sfdisk script file
   O   dump disk layout to sfdisk script file

  Save & Exit
   w   write table to disk and exit
   q   quit without saving changes

  Create a new label
   g   create a new empty GPT partition table
   G   create a new empty SGI (IRIX) partition table
   o   create a new empty DOS partition table
   s   create a new empty Sun partition table

 
 

    输入n 进行分区:

    这里写图片描述

    一定记得输入w才能保存分区更改

    fdisk -l 新增分区为/dev/sdb1

    这里写图片描述

    格式化

    # mkfs.ext4 /dev/sdb1
    这里写图片描述

    挂载

    mount 命令可以将分区挂载到目录下

    建立/opt/app目录

    # mkdir /opt/app

    挂载

    # mount /dev/sdb1 /opt/app

    查看

    # df -h
    这里写图片描述

    配置开机自动挂载

    vim /etc/fstab

    后面追加一行:

    /dev/sdb1(磁盘分区) /opt/app(挂载目录) ext4(文件格式)defaults 0 0

    • 0
      点赞
    • 0
      收藏
      觉得还不错? 一键收藏
    • 0
      评论
    评论
    添加红包

    请填写红包祝福语或标题

    红包个数最小为10个

    红包金额最低5元

    当前余额3.43前往充值 >
    需支付:10.00
    成就一亿技术人!
    领取后你会自动成为博主和红包主的粉丝 规则
    hope_wisdom
    发出的红包
    实付
    使用余额支付
    点击重新获取
    扫码支付
    钱包余额 0

    抵扣说明:

    1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
    2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

    余额充值