在linux下新增一块硬盘的操作。(包含大于2T的硬盘在linux下挂载操作)
2015-11-03 16:06
471 查看
一、安装硬盘到物理机上。(略)
二、查看硬盘是否正确安装。
使用“fdisk -l”命令查看硬盘代号。
[plain] view
plaincopy
root@greatms-All-Series:/home/share# fdisk -l
Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders, total 976773168 sectors
Units = 扇区 of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x000aab9b
设备 启动 起点 终点 块数 Id 系统
/dev/sda1 * 2048 488282111 244140032 83 Linux
/dev/sda2 488284158 976771071 244243457 5 扩展
Partition 2 does not start on physical sector boundary.
/dev/sda5 488284160 820314111 166014976 83 Linux
/dev/sda6 820316160 976771071 78227456 82 Linux 交换 / Solaris
WARNING: GPT (GUID Partition Table) detected on '/dev/sdb'! The util fdisk doesn't support GPT. Use GNU Parted.
Disk /dev/sdb: 3000.6 GB, 3000592982016 bytes
255 heads, 63 sectors/track, 364801 cylinders, total 5860533168 sectors
Units = 扇区 of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x00000000
设备 启动 起点 终点 块数 Id 系统
/dev/sdb1 1 4294967295 2147483647+ ee GPT
Partition 1 does not start on physical sector boundary.
可以看到我新增了的硬盘标识为sdb。
三、将硬盘分区。
1、当硬盘小于等于2T时,可以用fdisk。
[plain] view
plaincopy
fdisk /dev/sdb
1、查看帮助。
输入:m
2、新建分区。
输入:n
3、创建逻辑分区
输入:p
4、输入分区号以及指定分区大小
依照提示,回车表示默认。
5、检查分区情况(此时还未执行分区操作)
Command(m for help):p
6、保存退出
Command(m for help):w
2、当硬盘大于2T时,用parted命令。
[plain] view
plaincopy
parted /dev/sdb (用part命令对3T硬盘进行分区处理)
mklabel gpt (用gpt格式可以将3TB弄在一个分区里)
unit TB (设置单位为TB)
mkpart primary 0 3 (设置为一个主分区,大小为3TB,开始是0,结束是3)
print (显示设置的分区大小)
quit (退出parted程序)
四、格式化分区。
mkfs.ext4 /dev/sdb1
五、将硬盘挂载到文件夹下。
1、手动挂载。
新建一个文件夹:mkdir /home/sdb1
挂载:mount /dev/sdb1 /home/sdb1
2、开机自动挂载。
输入:vi /etc/fstab
在最后加入:
[cpp] view
plaincopy
/dev/sdb1 /home/sdb1 ext4 defaults 1 1
扩展后执行fdisk -l查看是否成功
[root@localhost ~ ]# fdisk - l
Disk / dev / sda: 16.1 GB, 16106127360 bytes
255 heads, 63 sectors / track, 1958 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/ dev / sda1 * 1 6 48163 + 83 Linux
/ dev / sda2 7 515 4088542 + 83 Linux
/ dev / sda3 516 1239 5815530 83 Linux
/ dev / sda4 1240 1305 530145 5 Extended
/ dev / sda5 1240 1305 530113 + 82 Linux swap / Solaris
可见sda已经扩展成为16G,但是没分配给文件系统
继续执行fdisk /dev/sda进行新建磁盘
[root@localhost ~ ]# fdisk / dev / sda
The number of cylinders for this disk is set to 1958 .
There is nothing wrong with that, but this is larger than 1024 ,
and could in certain setups cause problems with:
1 ) software that runs at boot time (e.g., old versions of LILO)
2 ) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS / 2 FDISK)
Command (m for help): n
No free sectors available
前面执行fdisk -l的时候明明最后才是1305柱面,而且应该有1958柱面,为什么说没有空闲的扇区。
再看看fdisk -l执行结果,原来是/dev/sda5分配了作为swap分区,找到原因了就容易解决。
1.关闭swap分区 # swapoff /dev/sda5
2.删除sda4和sda5.
[root@localhost ~ ]# fdisk / dev / sda
The number of cylinders for this disk is set to 1958 .
There is nothing wrong with that, but this is larger than 1024 ,
and could in certain setups cause problems with:
1 ) software that runs at boot time (e.g., old versions of LILO)
2 ) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS / 2 FDISK)
Command (m for help): d
Partition number ( 1 - 5 ): 5
Command (m for help): d
Partition number ( 1 - 5 ): 4
3.建立扩展分区4,建立分区sda5,写入
Command (m for help): n
Command action
e extended
p primary partition ( 1 - 4 )
e
Selected partition 4
First cylinder ( 1240 - 1958 , default 1240 ):
Using default value 1240
Last cylinder or + size or + sizeM or + sizeK ( 1240 - 1958 , default 1958 ):
Using default value 1958
Command (m for help): n
First cylinder ( 1240 - 1958 , default 1240 ):
Using default value 1240
Last cylinder or + size or + sizeM or + sizeK ( 1240 - 1958 , default 1958 ):
Using default value 1958
Command (m for help): w
The partition table has been
文章来自:
1. http://blog.csdn.net/season_hangzhou/article/details/36423223
2. http://hchmsguo.iteye.com/blog/1226666
二、查看硬盘是否正确安装。
使用“fdisk -l”命令查看硬盘代号。
[plain] view
plaincopy
root@greatms-All-Series:/home/share# fdisk -l
Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders, total 976773168 sectors
Units = 扇区 of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x000aab9b
设备 启动 起点 终点 块数 Id 系统
/dev/sda1 * 2048 488282111 244140032 83 Linux
/dev/sda2 488284158 976771071 244243457 5 扩展
Partition 2 does not start on physical sector boundary.
/dev/sda5 488284160 820314111 166014976 83 Linux
/dev/sda6 820316160 976771071 78227456 82 Linux 交换 / Solaris
WARNING: GPT (GUID Partition Table) detected on '/dev/sdb'! The util fdisk doesn't support GPT. Use GNU Parted.
Disk /dev/sdb: 3000.6 GB, 3000592982016 bytes
255 heads, 63 sectors/track, 364801 cylinders, total 5860533168 sectors
Units = 扇区 of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x00000000
设备 启动 起点 终点 块数 Id 系统
/dev/sdb1 1 4294967295 2147483647+ ee GPT
Partition 1 does not start on physical sector boundary.
可以看到我新增了的硬盘标识为sdb。
三、将硬盘分区。
1、当硬盘小于等于2T时,可以用fdisk。
[plain] view
plaincopy
fdisk /dev/sdb
1、查看帮助。
输入:m
2、新建分区。
输入:n
3、创建逻辑分区
输入:p
4、输入分区号以及指定分区大小
依照提示,回车表示默认。
5、检查分区情况(此时还未执行分区操作)
Command(m for help):p
6、保存退出
Command(m for help):w
2、当硬盘大于2T时,用parted命令。
[plain] view
plaincopy
parted /dev/sdb (用part命令对3T硬盘进行分区处理)
mklabel gpt (用gpt格式可以将3TB弄在一个分区里)
unit TB (设置单位为TB)
mkpart primary 0 3 (设置为一个主分区,大小为3TB,开始是0,结束是3)
print (显示设置的分区大小)
quit (退出parted程序)
四、格式化分区。
mkfs.ext4 /dev/sdb1
五、将硬盘挂载到文件夹下。
1、手动挂载。
新建一个文件夹:mkdir /home/sdb1
挂载:mount /dev/sdb1 /home/sdb1
2、开机自动挂载。
输入:vi /etc/fstab
在最后加入:
[cpp] view
plaincopy
/dev/sdb1 /home/sdb1 ext4 defaults 1 1
Linux扩容时新建分区报错No free sectors available
扩展后执行fdisk -l查看是否成功[root@localhost ~ ]# fdisk - l
Disk / dev / sda: 16.1 GB, 16106127360 bytes
255 heads, 63 sectors / track, 1958 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/ dev / sda1 * 1 6 48163 + 83 Linux
/ dev / sda2 7 515 4088542 + 83 Linux
/ dev / sda3 516 1239 5815530 83 Linux
/ dev / sda4 1240 1305 530145 5 Extended
/ dev / sda5 1240 1305 530113 + 82 Linux swap / Solaris
可见sda已经扩展成为16G,但是没分配给文件系统
继续执行fdisk /dev/sda进行新建磁盘
[root@localhost ~ ]# fdisk / dev / sda
The number of cylinders for this disk is set to 1958 .
There is nothing wrong with that, but this is larger than 1024 ,
and could in certain setups cause problems with:
1 ) software that runs at boot time (e.g., old versions of LILO)
2 ) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS / 2 FDISK)
Command (m for help): n
No free sectors available
前面执行fdisk -l的时候明明最后才是1305柱面,而且应该有1958柱面,为什么说没有空闲的扇区。
再看看fdisk -l执行结果,原来是/dev/sda5分配了作为swap分区,找到原因了就容易解决。
1.关闭swap分区 # swapoff /dev/sda5
2.删除sda4和sda5.
[root@localhost ~ ]# fdisk / dev / sda
The number of cylinders for this disk is set to 1958 .
There is nothing wrong with that, but this is larger than 1024 ,
and could in certain setups cause problems with:
1 ) software that runs at boot time (e.g., old versions of LILO)
2 ) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS / 2 FDISK)
Command (m for help): d
Partition number ( 1 - 5 ): 5
Command (m for help): d
Partition number ( 1 - 5 ): 4
3.建立扩展分区4,建立分区sda5,写入
Command (m for help): n
Command action
e extended
p primary partition ( 1 - 4 )
e
Selected partition 4
First cylinder ( 1240 - 1958 , default 1240 ):
Using default value 1240
Last cylinder or + size or + sizeM or + sizeK ( 1240 - 1958 , default 1958 ):
Using default value 1958
Command (m for help): n
First cylinder ( 1240 - 1958 , default 1240 ):
Using default value 1240
Last cylinder or + size or + sizeM or + sizeK ( 1240 - 1958 , default 1958 ):
Using default value 1958
Command (m for help): w
The partition table has been
文章来自:
1. http://blog.csdn.net/season_hangzhou/article/details/36423223
2. http://hchmsguo.iteye.com/blog/1226666
相关文章推荐
- CentOS中操作Psql
- linux中的文件锁flock
- linux查看java jdk安装路径和设置环境变量
- linux ftp上传文件用java代码实现
- Centos6.5使用Siege压力测试
- Linux 主机root登陆以后远程SSH才能访问
- linux---------远程debug
- windows和Linux系统使用java keytool工具生成cas单点登录数字证书
- pl-------------linux执行.pl文件
- RedHat Enterprise Linux 4(32) matlab(32)的安装与c++混合编程
- linux下使用读写锁
- 脚本安装zabbix2.4.7,基于centos6.6 basic server
- Linux进程同步机制Futex
- linux忘记root密码 单用户重置密码
- 1.Linux编程学习开篇
- 初学Linux(2)
- linux基础 --- grep
- Linux基本命令(三)——文件管理
- Linux下安装PHP
- Linux查看CPU和内存使用情况