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. [记录] js判断数组key是否存在

    数组中判断key是否存在 可以通过arrayObject.hasOwnProperty(key)来进行判断数组key是否存在,返回的是boolean值,如果存在就返回true,不存在就返回false ...

  2. spark stream初探

    spark带了一个NetworkWordCount测试程序,用以统计来自某TCP连接的单词输入: /usr/local/spark/bin/run-example streaming.NetworkW ...

  3. linux shell if参数

    shell 编程中使用到得if语句内判断参数 –b 当file存在并且是块文件时返回真 -c 当file存在并且是字符文件时返回真 -d 当pathname存在并且是一个目录时返回真 -e 当path ...

  4. 使用SQLdiag Utility搜集SQL Server诊断信息

    SQLdiag Utility用于搜集诊断信息,给Microsoft技术支持人员做为判断依据. 使用SQLdiag 会进行信息搜集类型 Windows 系统性能日志 Windows 系统日志 SQL ...

  5. Android中FTP服务器搭建入门

    http://www.2cto.com/kf/201501/374048.html http://blog.csdn.net/smile3670/article/details/44343617  有 ...

  6. web开发常用图片格式

    web开发常用图片格式有:gif   jpg/jpeg    png gif:图片压缩率高,可以显示动画,但是只能显示256色,可能造成颜色丢失. jpg:图片压缩率高(有损压缩),可以用小文件来显示 ...

  7. Java的内存泄漏_与C/C++对比(转载总结)

    原文网址:http://developer.51cto.com/art/201111/302465.htm Java内存泄露的理解与解决(1)   一般来说内存泄漏有两种情况.一种情况如在C/C++ ...

  8. .NET 4 新建 webform 项目编译不通过

    .NET 4 新建 webform 项目编译不通过,可能需要做如下改动. 一.根据编译错误,删除 packages.config 中相关包 二.安装包install-package Microsoft ...

  9. JAVA远程执行Shell脚本类

    1.java远程执行shell脚本类 package com.test.common.utility; import java.io.IOException; import java.io.Input ...

  10. ###STL学习--vector

    点击查看Evernote原文. #@author: gr #@date: 2014-08-11 #@email: forgerui@gmail.com vector的相关问题.<stl学习> ...