centos7 添加硬盘和分区
2016-05-05 15:17
573 查看
首先查看系统中的硬盘
[root@svnhost ~]# fdisk -l
Disk /dev/sda: 120.0 GB, 120034123776 bytes, 234441648 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x00033922
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 1026047 512000 83 Linux
/dev/sda2 1026048 234440703 116707328 8e Linux LVM
Disk /dev/mapper/centos-root: 53.7 GB, 53687091200 bytes, 104857600 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/mapper/centos-swap: 12.0 GB, 12004098048 bytes, 23445504 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/sdb: 1999.8 GB, 1999844147200 bytes, 3905945600 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/mapper/centos-home: 53.8 GB, 53750005760 bytes, 104980480 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
系统中有2块盘/dev/sda和/dev/sdb. /dev/sda已经做好分区。下面对/dev/sdb做分区
[root@svnhost ~]# fdisk /dev/sdb
Welcome to fdisk (util-linux 2.23.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0x8626c507.
Command (m for help): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
g create a new empty GPT partition table
G create an IRIX (SGI) partition table
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)
Command (m for help): n //新建主分区
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p):
Using default response p
Partition number (1-4, default 1):
First sector (2048-3905945599, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-3905945599, default 3905945599): +500G //输入分区大小
Partition 1 of type Linux and of size 500 GiB is set
Command (m for help): p //打印分区
Disk /dev/sdb: 1999.8 GB, 1999844147200 bytes, 3905945600 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x8626c507
Device Boot Start End Blocks Id System
/dev/sdb1 2048 1048578047 524288000 83 Linux
Command (m for help): n
Partition type:
p primary (1 primary, 0 extended, 3 free)
e extended
Select (default p):
Using default response p
Partition number (2-4, default 2):
First sector (1048578048-3905945599, default 1048578048):
Using default value 1048578048
Last sector, +sectors or +size{K,M,G} (1048578048-3905945599, default 3905945599): +500G
Partition 2 of type Linux and of size 500 GiB is set
Command (m for help): p
Disk /dev/sdb: 1999.8 GB, 1999844147200 bytes, 3905945600 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x8626c507
Device Boot Start End Blocks Id System
/dev/sdb1 2048 1048578047 524288000 83 Linux
/dev/sdb2 1048578048 2097154047 524288000 83 Linux
Command (m for help): n //新建扩展分区
Partition type:
p primary (2 primary, 0 extended, 2 free)
e extended
Select (default p): e
Partition number (3,4, default 3):
First sector (2097154048-3905945599, default 2097154048):
Using default value 2097154048
Last sector, +sectors or +size{K,M,G} (2097154048-3905945599, default 3905945599):
Using default value 3905945599
Partition 3 of type Extended and of size 862.5 GiB is set
Command (m for help): p
Disk /dev/sdb: 1999.8 GB, 1999844147200 bytes, 3905945600 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x8626c507
Device Boot Start End Blocks Id System
/dev/sdb1 2048 1048578047 524288000 83 Linux
/dev/sdb2 1048578048 2097154047 524288000 83 Linux
/dev/sdb3 2097154048 3905945599 904395776 5 Extended
Command (m for help): n //新建逻辑分区
Partition type:
p primary (2 primary, 1 extended, 1 free)
l logical (numbered from 5)
Select (default p): l
Adding logical partition 5
First sector (2097156096-3905945599, default 2097156096):
Using default value 2097156096
Last sector, +sectors or +size{K,M,G} (2097156096-3905945599, default 3905945599):
Using default value 3905945599
Partition 5 of type Linux and of size 862.5 GiB is set
Command (m for help): p
Disk /dev/sdb: 1999.8 GB, 1999844147200 bytes, 3905945600 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x8626c507
Device Boot Start End Blocks Id System
/dev/sdb1 2048 1048578047 524288000 83 Linux
/dev/sdb2 1048578048 2097154047 524288000 83 Linux
/dev/sdb3 2097154048 3905945599 904395776 5 Extended
/dev/sdb5 2097156096 3905945599 904394752 83 Linux
Command (m for help): w //写入新的分区表
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
创建文件系统
[root@svnhost ~]# mkfs -t ext3 /dev/sdb1
[root@svnhost /]# mkfs -t ext3 /dev/sdb2
[root@svnhost /]# mkfs -t ext3 /dev/sdb5
编辑系统文件
[root@svnhost /]#vi /etc/fstab
添加:
/dev/sdb1 /u01 ext3 defaults 0 0
/dev/sdb2 /u02 ext3 defaults 0 0
/dev/sdb5 /u03 ext3 defaults 0 0
至此,新建的硬盘分区在系统重启时就会自动挂载。
首先查看系统中的硬盘
[root@svnhost ~]# fdisk -l
Disk /dev/sda: 120.0 GB, 120034123776 bytes, 234441648 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x00033922
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 1026047 512000 83 Linux
/dev/sda2 1026048 234440703 116707328 8e Linux LVM
Disk /dev/mapper/centos-root: 53.7 GB, 53687091200 bytes, 104857600 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/mapper/centos-swap: 12.0 GB, 12004098048 bytes, 23445504 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/sdb: 1999.8 GB, 1999844147200 bytes, 3905945600 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/mapper/centos-home: 53.8 GB, 53750005760 bytes, 104980480 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
系统中有2块盘/dev/sda和/dev/sdb. /dev/sda已经做好分区。下面对/dev/sdb做分区
[root@svnhost ~]# fdisk /dev/sdb
Welcome to fdisk (util-linux 2.23.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0x8626c507.
Command (m for help): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
g create a new empty GPT partition table
G create an IRIX (SGI) partition table
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)
Command (m for help): n //新建主分区
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p):
Using default response p
Partition number (1-4, default 1):
First sector (2048-3905945599, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-3905945599, default 3905945599): +500G //输入分区大小
Partition 1 of type Linux and of size 500 GiB is set
Command (m for help): p //打印分区
Disk /dev/sdb: 1999.8 GB, 1999844147200 bytes, 3905945600 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x8626c507
Device Boot Start End Blocks Id System
/dev/sdb1 2048 1048578047 524288000 83 Linux
Command (m for help): n
Partition type:
p primary (1 primary, 0 extended, 3 free)
e extended
Select (default p):
Using default response p
Partition number (2-4, default 2):
First sector (1048578048-3905945599, default 1048578048):
Using default value 1048578048
Last sector, +sectors or +size{K,M,G} (1048578048-3905945599, default 3905945599): +500G
Partition 2 of type Linux and of size 500 GiB is set
Command (m for help): p
Disk /dev/sdb: 1999.8 GB, 1999844147200 bytes, 3905945600 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x8626c507
Device Boot Start End Blocks Id System
/dev/sdb1 2048 1048578047 524288000 83 Linux
/dev/sdb2 1048578048 2097154047 524288000 83 Linux
Command (m for help): n //新建扩展分区
Partition type:
p primary (2 primary, 0 extended, 2 free)
e extended
Select (default p): e
Partition number (3,4, default 3):
First sector (2097154048-3905945599, default 2097154048):
Using default value 2097154048
Last sector, +sectors or +size{K,M,G} (2097154048-3905945599, default 3905945599):
Using default value 3905945599
Partition 3 of type Extended and of size 862.5 GiB is set
Command (m for help): p
Disk /dev/sdb: 1999.8 GB, 1999844147200 bytes, 3905945600 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x8626c507
Device Boot Start End Blocks Id System
/dev/sdb1 2048 1048578047 524288000 83 Linux
/dev/sdb2 1048578048 2097154047 524288000 83 Linux
/dev/sdb3 2097154048 3905945599 904395776 5 Extended
Command (m for help): n //新建逻辑分区
Partition type:
p primary (2 primary, 1 extended, 1 free)
l logical (numbered from 5)
Select (default p): l
Adding logical partition 5
First sector (2097156096-3905945599, default 2097156096):
Using default value 2097156096
Last sector, +sectors or +size{K,M,G} (2097156096-3905945599, default 3905945599):
Using default value 3905945599
Partition 5 of type Linux and of size 862.5 GiB is set
Command (m for help): p
Disk /dev/sdb: 1999.8 GB, 1999844147200 bytes, 3905945600 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x8626c507
Device Boot Start End Blocks Id System
/dev/sdb1 2048 1048578047 524288000 83 Linux
/dev/sdb2 1048578048 2097154047 524288000 83 Linux
/dev/sdb3 2097154048 3905945599 904395776 5 Extended
/dev/sdb5 2097156096 3905945599 904394752 83 Linux
Command (m for help): w //写入新的分区表
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
创建文件系统
[root@svnhost ~]# mkfs -t ext3 /dev/sdb1
[root@svnhost /]# mkfs -t ext3 /dev/sdb2
[root@svnhost /]# mkfs -t ext3 /dev/sdb5
编辑系统文件
[root@svnhost /]#vi /etc/fstab
添加:
/dev/sdb1 /u01 ext3 defaults 0 0
/dev/sdb2 /u02 ext3 defaults 0 0
/dev/sdb5 /u03 ext3 defaults 0 0
至此,新建的硬盘分区在系统重启时就会自动挂载。
相关文章推荐
- linux 用 rsync 快速删除大量小文件
- CentOS 6.5 x64下Hadoop安装
- Linux常用命令―egrep及扩展正则表达式
- Linux学习7之linux下使用alias设置指令别名并使其永远生效
- 2016年LinuxMint将带来更多有趣更新
- CentOS 7.0 systemd代替service
- 让Linux终端中执行的程序在后台运行
- ADB不识别device not found
- Centos7上使用官方YUM源安装Mysql
- Linux主机被入侵后的处理案例
- 我一条腿跨进了linux大门
- linux下 svn co命令 store-plaintext-passwords 问题
- linux安装nagios客户端
- CentOS7安装iptables防火墙
- linux系统yum方式安装htop命令[转]
- CentOS6下yum升级Zabbix2.2/2.4到Zabbix3.0
- linux内核printk调试
- linux下实现svn自动拉取代码并发布
- CentOS重置root密码
- 深入理解Linux内核day09--系统调用