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种是对硬盘进行扩容后,对扩容后的空间进行分区再进行挂载. [内容为参考网上资料,再加自已实际操作情况进行 ...
随机推荐
- [转]windows下安装Object-C开发环境
本文转自:http://hi.baidu.com/jeremylai/item/f40b9116cb3c5d582b3e22f5 在Windows下搭建Objective C开发环境,需要到GNUst ...
- centos 7 下modelsim10.2c安装教程
step1: chmod +x ./install.linux(但是没有任何反应,原因是install.linux是32位程序,系统是64位的,所以要安装相应的库){ yum install glib ...
- jQuery+php实现ajax文件即时上传
很多项目中需要用到即时上传功能,比如,选择本地图片后,立即上传并显示图像.本文结合实例讲解如何使用jQuery和PHP实现Ajax即时上传文件的功能,用户只需选择本地图片确定后即实现上传,并显示上传进 ...
- Jquery 获取checkbox的checked问题
这个郁闷了,今天写这个功能的时候发现了问题,上网找了好多资料对照,更加纠结... 事实证明一切,自己测试了N遍,发现网上的说法和自己以前的理解都是错的,不知道大家有没发现. 下面来看看网上大多资料的说 ...
- PHP输入流php://input介绍
在使用xml-rpc的时候,server端获取client数据,主要是通过php输入流input,而不是$_POST数组.所以,这里主要探讨php输入流php://input 对一php://inpu ...
- Spark:用Scala和Java实现WordCount
http://www.cnblogs.com/byrhuangqiang/p/4017725.html 为了在IDEA中编写scala,今天安装配置学习了IDEA集成开发环境.IDEA确实很优秀,学会 ...
- 简单测试IIS下的UrlRewrite技术
UrlRewrite即地址变换.它可以实现静态功能方便搜索引擎收录,比如http://***/news.asp?corangeid=11它可以变为htt://***/news-11.html.这样还实 ...
- leetcode之Rectangle Area
Find the total area covered by two rectilinear rectangles in a 2D plane. Each rectangle is defined b ...
- C# 高精度求幂 poj1001
高精度求幂 public static char[] exponentiation(string a,int r) { ]; string b = ""; string c = a ...
- Poj/OpenJudge 1042 Gone Fishing
1.链接地址: http://bailian.openjudge.cn/practice/1042/ http://poj.org/problem?id=1042 2.题目: Gone Fishing ...