1.查看当前硬盘使用状况:

df -h
root@VM_160_34_centos:~> df -h
Filesystem Size Used Avail Use% Mounted on
/dev/xvda1 .9G .5G .1G % /

2.查看新硬盘 

 fdisk -l 
 root@VM_160_34_centos:~> fdisk -l            

 Disk /dev/xvda:  MB,  bytes
heads, sectors/track, cylinders
Units = cylinders of * = bytes
Sector size (logical/physical): bytes / bytes
I/O size (minimum/optimal): bytes / bytes
Disk identifier: 0xcd6e8236 Device Boot Start End Blocks Id System
/dev/xvda1 * + Linux Disk /dev/xvdb: 53.7 GB, bytes
heads, sectors/track, cylinders
Units = cylinders of * = bytes
Sector size (logical/physical): bytes / bytes
I/O size (minimum/optimal): bytes / bytes
Disk identifier: 0x00000000 Disk /dev/xvdb doesn't contain a valid partition table Disk /dev/xvdc: MB, bytes
heads, sectors/track, cylinders
Units = cylinders of * = bytes
Sector size (logical/physical): bytes / bytes
I/O size (minimum/optimal): bytes / bytes
Disk identifier: 0x00000000 Disk /dev/xvdc doesn't contain a valid partition table

这结果很明显让人烦躁,一坨屎一样,下面我们过滤一下

命令:

fdisk -l  |grep Disk

结果:

root@VM_160_34_centos:~> fdisk -l  |grep Disk
Disk /dev/xvdb doesn't contain a valid partition table
Disk /dev/xvdc doesn't contain a valid partition table
Disk /dev/xvda: MB, bytes
Disk identifier: 0xcd6e8236
Disk /dev/xvdb: 53.7 GB, bytes
Disk identifier: 0x00000000
Disk /dev/xvdc: MB, bytes
Disk identifier: 0x00000000

这个看起来让人舒心多了,

结果中:

提示这个

Disk /dev/xvdb doesn't contain a valid partition table
Disk /dev/xvdc doesn't contain a valid partition table

这两行应该就是说还没有挂载上去的硬盘了.

新添加的硬盘的编号为

/dev/xvdb
/dev/xvdc

3.硬盘分区

  • 进入fdisk模式
 fdisk /dev/xvdb  
 root@VM_160_34_centos:~> fdisk /dev/xvdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x7ca79642.
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 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):
  •  输入n进行分区 
Command (m for help): n
Command action
e extended
p primary partition (-)
p

这里有两个选项: 
   p: 主分区 linux上主分区最多能有4个 
   e: 扩展分区 linux上扩展分区只能有1个,扩展分区创建后不能直接使用,还要在扩展分区上创建逻辑分区。

这里我选择的p。

  • 选择分区个数
Partition number (-): 

可以选择4个分区,这里我只分成1个分区

  • 设置柱面,这里选择默认值就可以,直接按回车过去
First cylinder (-, default ):
Using default value
Last cylinder, +cylinders or +size{K,M,G} (-, default ):
Using default value
  • 输入w,写入分区表,进行分区 
Command (m for help):w
Command (m for help): w
The partition table has been altered! Calling ioctl() to re-read partition table.
Syncing disks.

整个过程如下:

root@VM_160_34_centos:~> fdisk /dev/xvdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x7ca79642.
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 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): n
Command action
e extended
p primary partition (-) Last login: Fri Jun :: from 112.90.239.105
root@VM_160_34_centos:~>
Display all possibilities? (y or n)
root@VM_160_34_centos:~>
root@VM_160_34_centos:~> fdisk /dev/xvd
xvda xvda1 xvdb xvdc
root@VM_160_34_centos:~> fdisk /dev/xvdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0xc925c1ae.
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 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): n
Command action
e extended
p primary partition (-)
p
Partition number (-):
First cylinder (-, default ):
Using default value
Last cylinder, +cylinders or +size{K,M,G} (-, default ):
Using default value Command (m for help): w
The partition table has been altered! Calling ioctl() to re-read partition table.
Syncing disks.

4.格式化分区 

将新分区格式化为ext3文件系统

  • 如果创建的是主分区
#mkfs -t ext3  /dev/xvdb
root@VM_160_34_centos:~> mkfs -t ext3  /dev/xvdb
mke2fs 1.41. (-May-)
Filesystem label=
OS type: Linux
Block size= (log=)
Fragment size= (log=)
Stride= blocks, Stripe width= blocks
inodes, blocks
blocks (5.00%) reserved for the super user
First data block=
Maximum filesystem blocks=
block groups
blocks per group, fragments per group
inodes per group
Superblock backups stored on blocks:
, , , , , , , , ,
, , Writing inode tables: done
Creating journal ( blocks): done
Writing superblocks and filesystem accounting information: done This filesystem will be automatically checked every mounts or
days, whichever comes first. Use tune2fs -c or -i to override.

5.  挂载硬盘

  • 创建挂载点

在根目录下创建storage目录

#mkdir /storage 
  • 将/dev/xvdb挂载到/storage下 
#mount /dev/xvdb /storage
  • 设置开机启动自动挂载 

新创建的分区不能开机自动挂载,每次重启机器都要手动挂载。 
    设置开机自动挂载需要修改/etc/fstab文件

 #vi /etc/fstab 

在文件的最后增加一行

 /dev/xvdb /storage ext3 defaults   

过程如下:

 root@VM_160_34_centos:~> mkdir /storage
root@VM_160_34_centos:~> mount /dev/xvdb /storage
root@VM_160_34_centos:~> vi /etc/fstab /dev/xvda1 / ext3 noatime,acl,user_xattr
/dev/xvdc swap swap defaults
proc /proc proc defaults
sysfs /sys sysfs noauto
debugfs /sys/kernel/debug debugfs noauto
devpts /dev/pts devpts mode=,gid=
/dev/xvdb /storage ext3 defaults
~
~
~
~
~
"/etc/fstab" 7L, 536C written
root@VM_160_34_centos:~> clear

结果:

root@VM_160_34_centos:/storage> ll /
total
dr-xr-xr-x root root May : bin
dr-xr-xr-x root root May boot
drwxr-xr-x root root Dec : data
drwxr-xr-x root root Jun : dev
drwxr-xr-x root root Jun : etc
drwxr-xr-x root root Jun : home
dr-xr-xr-x root root Jun lib
dr-xr-xr-x root root Jun lib64
drwx------ root root May lost+found
drwxr-xr-x root root Sep media
drwxr-xr-x root root Sep mnt
drwxr-xr-x root root Sep opt
dr-xr-xr-x root root Jun proc
dr-xr-x--- root root Jun : root
dr-xr-xr-x root root Jun sbin
drwxr-xr-x root root May selinux
drwxr-xr-x root root Sep srv
drwxr-xr-x root root Jun : storage
drwxr-xr-x root root Jun sys
drwxrwxrwt root root Jun : tmp
drwxr-xr-x root root May usr
drwxr-xr-x root root Jul var
root@VM_160_34_centos:/storage> fdisk -l |grep Disk
Disk /dev/xvdb doesn't contain a valid partition table
Disk /dev/xvdc doesn't contain a valid partition table
Disk /dev/xvda: MB, bytes
Disk identifier: 0xcd6e8236
Disk /dev/xvdb: 53.7 GB, bytes
Disk identifier: 0x00000000
Disk /dev/xvdc: MB, bytes
Disk identifier: 0x00000000
root@VM_160_34_centos:/storage> df -lh
Filesystem Size Used Avail Use% Mounted on
/dev/xvda1 .9G .5G .1G % /
/dev/xvdb 50G 180M 47G % /storage

教程到此结束!

CentOS挂载新硬盘的更多相关文章

  1. CentOS添加新硬盘到新的分区(xfs/ext4) 或者添加新分区

    CentOs添加新硬盘到新的分区(xfs/ext4)  添加新分区 转载请注明:http://www.cnblogs.com/juandx/p/5618162.html 这篇文章介绍怎么添加一块新的硬 ...

  2. 【转】linux挂载新硬盘,开机自动挂载

    [转]linux挂载新硬盘,开机自动挂载 ※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※ Linux的硬盘识别: 2.6 kernel以后,linux会将 ...

  3. linux挂载新硬盘并进行分区格式化

    最近要给小伙伴们写几篇文章,关于<linux下误删除文件之后该如何恢复>.对于没有进程占用的文件想要进行数据恢复,不同的文件系统格式需要使用不同的工具,比如:ext4.xfs等.我找遍了我 ...

  4. CentOS添加并挂载新硬盘

    1.查看当前硬盘使用状况: [test@master Desktop]$ df -hFilesystem Size Used Avail Use% Mounted on/dev/sda2 13G 12 ...

  5. linux下挂载新硬盘

    挂载好新硬盘后输入fdisk -l命令看当前磁盘信息 1.创建新硬盘分区 用fdisk  + 路径 进行分区 进入磁盘,对磁盘进行分区 #fdisk /dev/sdb Command (m for h ...

  6. Linux 挂载新硬盘

    Linux 的硬盘识别 在 /dev/ 下建立相应的设备文件.如 sda 表示第一块 SCSI 硬盘 hda 表示第一块 IDE 硬盘(即连接在第一个 IDE 接口的 Master 口上) scd0 ...

  7. linux挂载新硬盘

    Linux添加新硬盘自动挂载硬盘的具体步骤 1.插入新硬盘,启动Linux服务器,使用fdisk -l 查看硬盘 #fdisk -l Disk /dev/sdb: 1000.2 GB, 1000204 ...

  8. Linux下挂载新硬盘方法

     Linux的硬盘识别在/dev/下建立相应的设备文件.如 sda 表示第一块SCSI硬盘 hda 表示第一块IDE硬盘(即连接在第一个IDE接口的Master口上) scd0 表示第一个USB光 ...

  9. linux硬盘挂载-新硬盘挂载和扩容硬盘挂载

    这里对当前我实际操作后的两种硬盘挂载进行整理: 第1种是直接添加一块新硬盘,然后进行挂载. 第2种是对硬盘进行扩容后,对扩容后的空间进行分区再进行挂载. [内容为参考网上资料,再加自已实际操作情况进行 ...

随机推荐

  1. Mac下Sublime Text Vim模式 方向键无法长按

    在Mac终端输入(不是sublime text里的console),分别对应ST2.ST3: defaults ApplePressAndHoldEnabled -bool false default ...

  2. 一些ecplise 快捷键

    1 F5:下一步,可以进入下一个函数栈 2 F6:当前函数的下一步,不会进入其他的函数. 3 F8:下一个断点. 4 选中一个变量或者表达式,按ctrl+shift+i 来查看内容或者添加监视的方式. ...

  3. bvp4c--语法

    bvp4c--语法   1. bvp4c: sol = bvp4c(odefun,bcfun,solinit) sol = bvp4c(odefun,bcfun,solinit,options) so ...

  4. MATLAB LU函数

    高斯消元法求解线性方程,包括把增广矩阵转换为三角矩阵形式的过程,消去阶段工作 步骤是把矩阵A分解成为下三角L和上三角U的乘积.这种计算L,U的过程称为LU分解法. lu实现对矩阵的分解. [L,U] ...

  5. JavaScript高级程序设计(第三版)学习笔记13、14章

    第13章,事件 事件冒泡 IE的事件叫做事件冒泡:由具体到不具体 <!DOCTYPE html> <html> <head>      <title>E ...

  6. JAXB - The JAXB Context

    As we have seen, an object of the class JAXBContext must be constructed as a starting point for othe ...

  7. JAXB - The Object Factory

    Usually hidden in the middle of the list of the classes derived from the types defined in an XML sch ...

  8. 使用resumable.js上传大文件(视频)兵转换flv格式

    前台代码 <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Video.asp ...

  9. 杂技之sharpdevelop调试aps.net

    背景: 本人笔记本电脑不给力,vs打开实在太慢,因此考虑使用sharpdevelop,但sharpdevelop有点麻烦事,就是不支持asp.net的调试,为解决此问题,本人在此杂技一把了 方案一: ...

  10. elementary os进入GUI桌面环境失败

    问题描述:电脑上安装了elementary os,重启后系统很顺利的到达了Login图形界面,在选定用户并键入正确的密码后,电脑黑屏了一至两秒钟后又回到的Login界面,一开始以为是密码输入错误了,就 ...