Linux磁盘分区--MBR分区
今天心情不高兴,做IT不容易被公司重视,一定要速度学会运营,成为一个高逼格的技术男。
今天我要熟练掌握linux系统分区的能力。大家都知道,linux系统分区有两种分区格式:GTP和MBR。
MBR作为传统legacy的bios启动方式被我们经常使用,新老主板bios都支持而且分区简单,操作方便。
1、 MBR特点
① 最多支持4个主分区
② 最大支持2.1tb硬盘
③ 扩展分区一个硬盘只能有一个
2、 mbr结构:
引导占用硬盘开头的512字节,前446字节为引导代码,中间64个字节为4个主分区表信息,最后两个字节为启动标识。
3、 mbr分区实战:
fdisk命令
语法:fdisk [选项] [参数]
选项:-b 指定每个分区大小
-l 列出分区表信息
-v 显示fdisk版本
添加硬盘后,首先使用ll /dev/sd*查看设备是否识别,使用fdisk -l命令列出磁盘信息。
对/dev/sdb进行mbr分区
[root@linux-node2 ~]# fdisk /dev/sdb
Welcome to fdisk (util-linux 2.23.2).
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): p #选择新建主分区
Partition number (1-4, default 1): 1 #主分区表示,会生成/dev/sdb1
First sector (2048-6291455, default 2048): #开始扇区,回车默认从2048
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-6291455, default 6291455): +100M
Partition 1 of type Linux and of size 100 MiB is set
Command (m for help): n #新建分区
Partition type:
p primary (1 primary, 0 extended, 3 free)
e extended
Select (default p): e #选择扩展分区
Partition number (2-4, default 2): 3 #扩展分区编号/dev/sdb3
First sector (206848-6291455, default 206848): #默认回车,从当前扇区开始
Using default value 206848
Last sector, +sectors or +size{K,M,G} (206848-6291455, default 6291455): #默认回车分配所有剩余空间
Using default value 6291455
Partition 3 of type Extended and of size 2.9 GiB is set
Command (m for help): n
Partition type:
p primary (1 primary, 1 extended, 2 free)
l logical (numbered from 5)
Select (default p): l #新建逻辑分区
Adding logical partition 5 #默认逻辑分区编号为5
First sector (208896-6291455, default 208896): #逻辑分区起始位置
Using default value 208896
Last sector, +sectors or +size{K,M,G} (208896-6291455, default 6291455): +500M
Partition 5 of type Linux and of size 500 MiB is set
Command (m for help): n #新建第二个逻辑分区,分配剩余空间
Partition type:
p primary (1 primary, 1 extended, 2 free)
l logical (numbered from 5)
Select (default p): l
Adding logical partition 6
First sector (1234944-6291455, default 1234944):
Using default value 1234944
Last sector, +sectors or +size{K,M,G} (1234944-6291455, default 6291455):
Using default value 6291455
Partition 6 of type Linux and of size 2.4 GiB is set
Command (m for help): w 保存退出
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
查看分区:
[root@linux-node2 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 20G 0 disk
├─sda1 8:1 0 500M 0 part /boot
└─sda2 8:2 0 19.5G 0 part
├─rhel-root 253:0 0 17.5G 0 lvm /
└─rhel-swap 253:1 0 2G 0 lvm [SWAP]
sdb 8:16 0 3G 0 disk
├─sdb1 8:17 0 100M 0 part
├─sdb3 8:19 0 1K 0 part
├─sdb5 8:21 0 500M 0 part
└─sdb6 8:22 0 2.4G 0 part
格式化分区:
[root@linux-node2 ~]# mkfs.ext4 /dev/sdb1
手动挂载:
[root@linux-node2 ~]# mkdir /datasdb1
[root@linux-node2 ~]# mount /dev/sdb1 /datasdb1/
开机自动挂载:
[root@linux-node2 ~]# echo "/dev/sdb1 /datasdb1 ext4 defaults 0 0 " >> /etc/fstab
检查挂载情况:
[root@linux-node2 ~]# df -h
如果磁盘分区为gpt需要转换为mbr,请使用parted命令,再使用fdisk分区
[root@linux-node2 ~]# parted /dev/sdb
GNU Parted 3.1
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mklabel msdos
Warning: The existing disk label on /dev/sdb will be destroyed and all data on this disk will be lost. Do you want to continue?
Yes/No? y
Linux磁盘分区--MBR分区的更多相关文章
- linux磁盘管理与分区 转载
原文:http://zhengjianglong.leanote.com/post/linux%E7%A3%81%E7%9B%98%E5%88%86%E5%8C%BA 一.基础知识 一块磁盘可以分为多 ...
- Linux 磁盘管理及分区
硬盘结构和基础知识 扇区(Sector)为最小的物理储存单位,每个扇区为512 bytes,将扇区组成一个圆就是磁道(track),不同磁盘的相同磁道组成磁柱(Cylinder),磁柱是分区(par ...
- Linux 磁盘管理(分区、创建文件系统、挂载)
Linux设备文件可以分为两类 b : 按块为单位,随机访问设备(块设备文件) 如:硬盘 c : 按字符为单位,线性设备(字符设备文件) 如:键盘 设备文件位于/dev下 主设备号(major n ...
- Linux下的MBR分区
MBR分区 下面讲一讲如何给一块新添加入服务器的硬盘做MBR分区,那么为什么叫做MBR分区呢?后面会讲 做MBR分区,使用系统自带的fdisk工具.先看一看什么是fdisk,在命令行输入“fdisk” ...
- Linux磁盘挂载、分区、扩容操作
本文最早发布于 Rootrl's blog 注:以下操作系统环境为CentOS7 基本概念 在操作前,首先要了解一些基本概念 磁盘 在Linux系统中所有的设备都会以文件的形式存储.设备一般保存在/d ...
- Linux磁盘管理——swap分区
转自:Linux Swap交换分区设置 对swap分区的误解 一种流行的.以讹传讹的说法是,安装Linux系统时,交换分区swap的大小应该是内存的两倍.也就是说,如果内存是2G,那么就应该分出4G的 ...
- 如何快速将磁盘的MBR分区方式改成GPT分区方式
注:修改分区格式时此硬盘不能是在使用状态(简单说就是不能出现在盘符中),如果在使用中先在计算机的磁盘管理中删除卷. 由于MBR分区表模式的硬盘最大只支持2T的硬盘空间,而现在我们的硬盘越来越大,有时候 ...
- 快速将磁盘的MBR分区方式改成GPT分区方式
1.按Shift + F10打开命令提示符. 2.diskpart 3.list disk(列出所有磁盘) 4.select disk 0(选择磁盘) 5.clean(格式化所选的磁盘) 7.conv ...
- Linux磁盘管理——MBR 与 GPT
硬件设备在Linux中文件名 如今IDE 磁盘几乎被淘汰,市面上最常见的磁盘就是SATA和SAS.个人计算机主要是SATA.很多Linux发行版下都将IDE磁盘文件名也都被仿真成 /dev/sd[a- ...
随机推荐
- NOIP2016 DAY2 T1 组合数问题
题目描述 组合数表示的是从n个物品中选出m个物品的方案数.举个例子,从(1,2,3) 三个物品中选择两个物品可以有(1,2),(1,3),(2,3)这三种选择方法.根据组合数的定 义,我们可以给出计算 ...
- OA项目总结3
struts2自定义标签中 使用in 判断当前值 是否在某个集合中 该属性一方面可以获取前端页面传递过来的参数 另外一个作用就是在数据回显时把用户已经拥有的权限id存入该集合中 放在栈顶 ...
- BIO、NIO、AIO
一.基础概念 IO操作分为两步:1.发起IO请求:2.执行具体IO操作: 同步和异步的区别是数据访问时进程是否阻塞或者说在执行真正IO操作时,数据能够立即返回就是异步,否则就是同步,同步和异步发生在I ...
- 工具-vscode使用
1.智能感知 vscode使用DefinitelyTyped进行自动完成所以需要先安装tsd,命令: npm install -g tsd 安装完成后,首先安装node基本语法支持 tsd query ...
- Swift开发教程--怎样自己定义TabBarItem的图片显示
在做项目的时候,假设使用系统的UITabBarController的时候,底部的tab自己定义图片显示是蓝色和灰色的.这不是我们所想要的效果. 假设想显示自己定义的按下和弹起的图片效果.这个时候就须要 ...
- 4418: [Shoi2013]扇形面积并|二分答案|树状数组
为何感觉SHOI的题好水. ..又是一道SB题 从左到右枚举每个区间,遇到一个扇形的左区间就+1.遇到右区间就-1,然后再树状数组上2分答案,还是不会码log的.. SHOI2013似乎另一道题发牌也 ...
- Unity3D中C#和JS的方法互相調用
因为Unity3D中一些腳本的方法仅仅能用在JS中.在C#中是無效的,而C#能够與服務器端通訊,JS本身卻不行.所以勢必會遇到這兩種語言腳本中方法的互相調用,下面是演示样例. 兩個文件 test1.j ...
- Project Euler:Problem 88 Product-sum numbers
A natural number, N, that can be written as the sum and product of a given set of at least two natur ...
- 【MySQL】MySQL删除匿名用户,保证登录安全
博客地址已迁往 www.virtclouds.com 原文地址 http://www.virtclouds.com/538.html 很多MySQL程序都会带有匿名登录的功能. 在刚刚安装完MySQL ...
- SQL的优化技巧
一.一些常见的SQL实践 (1)负向条件查询不能使用索引 select * from order where status!=0 and stauts!=1 not in/not exists都不是好 ...