CentOS挂载新硬盘
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挂载新硬盘的更多相关文章
- CentOS添加新硬盘到新的分区(xfs/ext4) 或者添加新分区
CentOs添加新硬盘到新的分区(xfs/ext4) 添加新分区 转载请注明:http://www.cnblogs.com/juandx/p/5618162.html 这篇文章介绍怎么添加一块新的硬 ...
- 【转】linux挂载新硬盘,开机自动挂载
[转]linux挂载新硬盘,开机自动挂载 ※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※ Linux的硬盘识别: 2.6 kernel以后,linux会将 ...
- linux挂载新硬盘并进行分区格式化
最近要给小伙伴们写几篇文章,关于<linux下误删除文件之后该如何恢复>.对于没有进程占用的文件想要进行数据恢复,不同的文件系统格式需要使用不同的工具,比如:ext4.xfs等.我找遍了我 ...
- CentOS添加并挂载新硬盘
1.查看当前硬盘使用状况: [test@master Desktop]$ df -hFilesystem Size Used Avail Use% Mounted on/dev/sda2 13G 12 ...
- linux下挂载新硬盘
挂载好新硬盘后输入fdisk -l命令看当前磁盘信息 1.创建新硬盘分区 用fdisk + 路径 进行分区 进入磁盘,对磁盘进行分区 #fdisk /dev/sdb Command (m for h ...
- Linux 挂载新硬盘
Linux 的硬盘识别 在 /dev/ 下建立相应的设备文件.如 sda 表示第一块 SCSI 硬盘 hda 表示第一块 IDE 硬盘(即连接在第一个 IDE 接口的 Master 口上) scd0 ...
- linux挂载新硬盘
Linux添加新硬盘自动挂载硬盘的具体步骤 1.插入新硬盘,启动Linux服务器,使用fdisk -l 查看硬盘 #fdisk -l Disk /dev/sdb: 1000.2 GB, 1000204 ...
- Linux下挂载新硬盘方法
Linux的硬盘识别在/dev/下建立相应的设备文件.如 sda 表示第一块SCSI硬盘 hda 表示第一块IDE硬盘(即连接在第一个IDE接口的Master口上) scd0 表示第一个USB光 ...
- linux硬盘挂载-新硬盘挂载和扩容硬盘挂载
这里对当前我实际操作后的两种硬盘挂载进行整理: 第1种是直接添加一块新硬盘,然后进行挂载. 第2种是对硬盘进行扩容后,对扩容后的空间进行分区再进行挂载. [内容为参考网上资料,再加自已实际操作情况进行 ...
随机推荐
- Spring 的@Controller 和@RestController的区别
@RestController Spring 4.0中新增的特性 @RestController 继承自 @Controller,相当于@ResponseBody + @Controller 1. ...
- 【原】NGUI中的UIAnchor脚本功能
UIAnchor的功能是把对象锚定在屏幕的边缘(左上,左中,左下,上,中,下,右上,右中,右下),或缩放物体使其匹配屏幕的尺寸. 在1.90版本后,拉长(缩放)的功能被放到UIStretch中,UIA ...
- Sublime Text3自动保存的功能(失去焦点自动保存)
这是最新版本的Sublime Text3的设置方法 (三部曲); 第一步:preferences 下面的settings:(和老版本的不一样了吧,之前有什么default 和 users,这里只有se ...
- 【转】傅盛:怎样做一个创业公司CEO?
摘要 : 傅盛High聊会,泉灵姐姐给的命题作文.怎样做一个创业公司CEO,核心还是思维模式. 这次傅盛High聊会,泉灵姐姐给我的命题作文.创业要如何开始,本质还是思维模式.首先学会把一个开放式问题 ...
- 浅试WebStorm配置Node.js开发环境
web前端开发IDE一直喜欢用WebStorm,这里简单介绍如何用WebStorm搭建一个Node.js开发环境. 首先,需要在本地安装好node.js,以及npm包管理工具.你也可以吧node.js ...
- Bootstrap--组件之Glyphicons字体图标
Glyphicons 字体图标 所有可用的图标 包括250多个来自 Glyphicon Halflings 的字体图标.Glyphicons Halflings 一般是收费的,但是他们的作者允许 Bo ...
- 2015年校园招聘12家IT公司面试体验
背景 2015年注定是一个不平凡的年头,作为一个应届毕业生,我也算是经历了工作上的大起大落.下面我先简单讲述一下自己的遭遇,然后根据自己亲身的面试经历,从一个学生的角度去谈谈自己对面试过的公司的一些看 ...
- 第一章 认识jQuery
jQuery是一个优秀的JavaScript库,它凭借简洁地语法和跨平台的兼容性,极大地简化了开发人员遍历HTML文档,操作DOM,处理事件,执行动画和开发Ajax操作. jQuery优势:1.轻量级 ...
- JavaScript学习笔记(7)——JavaScript语法之函数
函数就是包裹在花括号中的代码块,前面使用了关键词 function: function functionname() { //这里是要执行的代码 } 当调用该函数时,会执行函数内的代码. 可以在某事件 ...
- Ant 入门
参考: Ant官网 http://ant.apache.org/ 轻量级java ee企业应用实战(李刚) Ant当前版本1.9.6 Ant基于Java 配置环境变 ...