centos7 添加硬盘和分区
首先查看系统中的硬盘
[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
至此,新建的硬盘分区在系统重启时就会自动挂载。
主分区,扩展分区和逻辑分区
主分区,也称为主磁盘分区,和扩展分区、逻辑分区一样,是一种分区类型。主分区中不能再划分其他类型的分区,因此每个主分区都相当于一个逻辑磁盘(在这一点上主分区和逻辑分区很相似,但主分区是直接在硬盘上划分的,逻辑分区则必须建立于扩展分区中)。
1. 一个硬盘可以有1到3个主分区和1个扩展分区,也可以只有主分区而没有扩展分区,但主分区必须至少有1个,扩展分区则最多只有1个,且主分区+扩展分区总共不能超过4个。逻辑分区可以有若干个。
(硬盘的第一个扇区最重要,其上面有硬盘主引导记录(占用446bytes)和分区表(占用64 bytes),之所以只能有四个主分区就是因为分区表只有64B,只能装下4条记录)
所以只能有四个主分区的硬盘的限制,并不是操作系统的限制,而最多只能有一个拓展分区则是操作系统的限制
2. 分出主分区后,其余的部分可以分成扩展分区,一般是剩下的部分全部分成扩展分区,也可以不全分,剩下的部分就浪费了。
3. 扩展分区不能直接使用,必须分成若干逻辑分区。所有的逻辑分区都是扩展分区的一部分。 硬盘的容量=主分区的容量+扩展分区的容量; 扩展分区的容量=各个逻辑分区的容量之和。
4. 由主分区和逻辑分区构成的逻辑磁盘称为驱动器(Drive)或卷(Volume)。
5. 激活的主分区会成为“引导分区”(或称为“启动分区”),引导分区会被操作系统和主板认定为第一个逻辑磁盘(在DOS/Windows中会被识别为“驱动器C:”或“本地磁盘C:”,即通称的C盘)。有关DOS/Windows启动的重要文件,如引导记录、boot.ini、ntldr、ntdetect.com等,必须放在引导分区中。

低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。
持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。
转载内容版权归作者及来源网站所有,本站原创内容转载请注明来源。
- 上一篇
在CentOS 7上利用systemctl添加自定义系统服务
CentOS7继承了RHEL 7的新的特性,例如强大的systemctl,而systemctl的使用也使得以往系统服务的/etc/init.d的启动脚本的方式就此改变,也大幅提高了系统服务的运行效率。但服务的配置和以往也发生了极大的不同,说实在的,变的简单而易用了许多。 下面我们以利用forever来实现Node.js项目自启动为例,初探CentOS 7的systemctl。 前提:Node.js环境已配置成功,forever包安装成功,有一个能跑的Node.js程序。 CentOS 7的服务systemctl脚本存放在:/usr/lib/systemd/,有系统(system)和用户(user)之分,像需要开机不登陆就能运行的程序,还是存在系统服务里吧,即:/usr/lib/systemd/system目录下 每一个服务以.service结尾,一般会分为3部分:[Unit]、[Service]和[Install],我写的这个服务用于开机运行Node.js项目,具体内容如下: [plain]view plain copy print? <spanstyle="font-fam...
- 下一篇
Linux系统下开发常用命令
文件目录中查找函数和文件 find . | xargs grep func_name find -name "*.mk" | xargs grep file_name.c 持续显示某个文件内容,在当前操作窗口持续更新 tail -f boot_info.log 打开某个文件并查找关键字 less ./frame/fei/fe_nse/nse_fsm.c grep FEI_FEVFP_HEARTBEAT_SendPktProc.c ./ -r 从so中找是否编进去某个函数 nm libfeife.so | grep FE588X_HODP_TXPKT_Buf2HwBuf 1."-A" 列出符号名的时候同时显示来自哪个文件 2."-a" 列出所有符号,这将会把调试符号也列出来,默认情况下不会被列出; 3."-l",列出符号在源代码中的行号; 4."-n",根据符号的地址来排序,默认是按符号名称的字母顺序来排序的; 5."-u",只列出未定义符号; 列出so中所有函数 nm -D XXX.so objdump -tT XXX.so 查看命令使用历史记录...
相关文章
文章评论
共有0条评论来说两句吧...
文章二维码
点击排行
推荐阅读
最新文章
- Docker使用Oracle官方镜像安装(12C,18C,19C)
- Linux系统CentOS6、CentOS7手动修改IP地址
- CentOS7安装Docker,走上虚拟化容器引擎之路
- CentOS7编译安装Cmake3.16.3,解决mysql等软件编译问题
- CentOS6,7,8上安装Nginx,支持https2.0的开启
- CentOS8安装MyCat,轻松搞定数据库的读写分离、垂直分库、水平分库
- Windows10,CentOS7,CentOS8安装Nodejs环境
- CentOS7设置SWAP分区,小内存服务器的救世主
- CentOS关闭SELinux安全模块
- Docker安装Oracle12C,快速搭建Oracle学习环境