基本步骤:分区——格式化——挂载——写入文件

1、首先用fdisk -l命令查看添加的硬盘名称,可以看到sdb为新增的硬盘

[root@oracle ~]# fdisk -l

Disk /dev/sdb: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000 Disk /dev/sda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0006b59c Device Boot Start End Blocks Id System
/dev/sda1 * 1 39 307200 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 39 2358 18631680 83 Linux
/dev/sda3 2358 2611 2031616 82 Linux swap / Solaris

2、进行分区,输入m查看提示

[root@oracle ~]# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x09f38795.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable. Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite) WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u'). 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
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)

分析:主要参数的解析

  1. 输入 m 显示所有命令列示。

  2. 输入 p 显示硬盘分割情形,打印分区表。

  3. 输入 a 设定硬盘启动区。

  4. 输入 n 创建新的硬盘分割区。

    4.1. 输入 e 硬盘为[延伸]分割区(extend)。

    4.2. 输入 p 硬盘为[主要]分割区(primary)。

  5. 输入 t 改变硬盘分割区属性。          

       t:分区系统id号
         L:82:linux swap
        83:linux
        86:NTFS window分区

  6. 输入 d 删除硬盘分割区属性。

  7. 输入 q 结束不存入硬盘分割区属性。

  8. 输入 w 结束并写入硬盘分割区属性

3、输入n创建新的硬盘分区——输入p创建主分区——输入1设置一个分区——回车——回车(默认全部空间)

Command (m for help): n
Command action
e extended ···扩展分区
p primary partition (1-4) ···主分区
p
Partition number (1-4): 1
First cylinder (1-2610, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-2610, default 2610):
Using default value 2610

4、输入p查看分区情况——输入w保存退出(一定要w保存不然无效)

Command (m for help): p

Disk /dev/sdb: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x09f38795 Device Boot Start End Blocks Id System
/dev/sdb1 1 2610 20964793+ 83 Linux Command (m for help): w
The partition table has been altered! Calling ioctl() to re-read partition table.
Syncing disks.

5、mkfs命令格式化磁盘

[root@oracle ~]# mkfs.ext4  /dev/sdb1
mkfs.ext4: invalid fragment size - /dev/sdb1

6、mount命令挂载分区

[root@oracle ~]# mount /dev/sdb1 /oracle/
You have new mail in /var/spool/mail/root
[root@oracle ~]# df -TH
Filesystem Type Size Used Avail Use% Mounted on
/dev/sda2 ext4 19G 11G 7.3G 60% /
tmpfs tmpfs 2.1G 74k 2.1G 1% /dev/shm
/dev/sda1 ext4 297M 29M 253M 11% /boot
/dev/sdb1 ext4 22G 47M 20G 1% /oracle

7、添加到/etc/fstab文件下保存退出否则重启后硬盘消失

/dev/sdb1        /oracle          ext4   defaults,noatime        0 0

linux添加硬盘分区挂载教程的更多相关文章

  1. Linux添加硬盘和挂载

    1.使用fdisk -l 查看硬盘的详细信息 分析: 2.分区初始化 fdisk /dev/sdb 分析:各个参数的解析                   1. 输入 m 显示所有命令列示. 2. ...

  2. Linux 添加硬盘并分区

    Linux 添加硬盘并分区 *********************** 1.fdisk /dev/sdb 2.m   //帮助 3.p   // p 列出分区表 4.q   //不保存退出: 5. ...

  3. Linux 添加硬盘

    一.简介 本文介绍为Linux 添加硬盘的基本方法,同时适用于为虚拟机添加硬盘的情况.   二.添加小于2T的硬盘 1)分区 fdisk /dev/hda 2)建立文件系统 3)设置开机自动挂载磁盘 ...

  4. Linux添加硬盘创建新的逻辑卷方式

    有同仁看了上文<Linux添加硬盘扩充已有分区存储空间方式>一文后,提出疑问,现在很多云服务器本来没有逻辑卷,添加数据盘后需要自行添加,如何处理? 此文将以某云服务器为例,详细进行解说. ...

  5. linux中硬盘分区、格式化、挂载

    已经接触了小半年的linux,基本命令用的还行,就是涉及到深入操作,就显得不够看了,比如linux中的硬盘操作,于是整理了这篇博客. 1. 主分区,扩展分区,逻辑分区的联系和区别 ​ 一个硬盘可以有1 ...

  6. Linux下硬盘分区

    1  fdisk -l查看硬盘及分区信息 我的系统(Archlinux)下的命令效果如下: 由上面的图片可以得知该系统只挂载了1个硬盘,命名为sda,其有2个主分区,sda1和sda2,至于为什么这么 ...

  7. Linux 添加硬盘设备

    fdisk命令用于管理磁盘分区,格式为:“fdisk [磁盘名称]”. 管理Linux系统中的硬盘设备最常用的方法就当属是用fdisk命令了,这条命令提供了添加.删除.转换分区等等功能于一身的“一站式 ...

  8. Linux基础——硬盘分区、格式化及文件系统的管理

    1. 硬件设备与文件名的对应关系 掌握在Linux系统中,每个设备都被当初一个文件来对待. 设备 设备在Linux内的文件名 IDE硬盘 /dev/hd[a-d] SCSI硬盘 /dev/sd[a-p ...

  9. Linux下磁盘分区挂载

    一般你去买vps都会看到介绍说硬盘多少G  比如 80G 但是你进入系统df -h的时候发现怎么只有10G呢, 其实这10G是用来装系统的和一些常用服务软件的  不是给你放网站数据的 那50G硬盘在哪 ...

随机推荐

  1. 8.String StringBuffer StringBuilder

    http://www.cnblogs.com/xiohao/p/4271140.html

  2. [模拟赛] T2 不等数列

    Description 将1到n任意排列,然后在排列的每两个数之间根据他们的大小关系插入">"和"<".问在所有排列中,有多少个排列恰好有k个&qu ...

  3. 微信小程序学习笔记(阶段二)

    二阶段学习过程: (一)看官方文档的框架.组件.API:https://mp.weixin.qq.com/debug/wxadoc/dev/ (二)看极客学院第3.4章视频:http://www.ph ...

  4. Spring Boot 1.4测试的改进

    对Pivotal团队来说,工作上的好事情是他们拥有一个被叫做Pivotal Labs的灵活发展部门,拥有Labs团队的Lean 和 XP程序设计方法学的强大支持,例如结对编程和测试驱动开发.他们对于测 ...

  5. 国内可用的Internet时间同步服务器地址(NTP时间服务器)

    不知道什么鬼我这系统自带的Internet时间同步服务器地址居然不可用,终端ping系统自带服务器两个居然都不通???难道时间服务器也和谐么? 好在阿里云提供了7个NTP时间服务器也就是Interne ...

  6. 在react中引入下拉刷新和上拉加载

    1. 首先引入插件 import ReactPullLoad, {STATS} from 'react-pullload' 2. 初始化: constructor(props) { super(pro ...

  7. Hibernate学习(1)- 初识

    一.概念引入 1.持久化: 狭义概念:数据存储在物理介质不会丢失. 广义概念:对数据的CRUD操作都叫做持久化. 2.加载: hibernate里,数据从数据库中加载到session. 3.ORM - ...

  8. sql的优化30条

    1. 对查询进行优化,应尽量避免全表扫描,首先应考虑在 where 及 order by 涉及的列上建立索引. 2. 应尽量避免在 where 子句中对字段进行 null 值判断,否则将导致引擎放弃使 ...

  9. Struts2学习笔记二 配置详解

    Struts2执行流程 1.简单执行流程,如下所示: 在浏览器输入请求地址,首先会被过滤器处理,然后查找主配置文件,然后根据地址栏中输入的/hello去每个package中查找为/hello的name ...

  10. 第2次作业:Wechat创作史

    Wechat创作史   比尔盖茨曾经说过一句话:21世纪要么电子商务,要么无商可务. 2.1 介绍产品相关信息 -the information about Wechat 你选择的产品是? 选择微信作 ...