今天心情不高兴,做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分区的更多相关文章

  1. linux磁盘管理与分区 转载

    原文:http://zhengjianglong.leanote.com/post/linux%E7%A3%81%E7%9B%98%E5%88%86%E5%8C%BA 一.基础知识 一块磁盘可以分为多 ...

  2. Linux 磁盘管理及分区

    硬盘结构和基础知识  扇区(Sector)为最小的物理储存单位,每个扇区为512 bytes,将扇区组成一个圆就是磁道(track),不同磁盘的相同磁道组成磁柱(Cylinder),磁柱是分区(par ...

  3. Linux 磁盘管理(分区、创建文件系统、挂载)

    Linux设备文件可以分为两类 b : 按块为单位,随机访问设备(块设备文件)  如:硬盘 c : 按字符为单位,线性设备(字符设备文件)  如:键盘 设备文件位于/dev下 主设备号(major n ...

  4. Linux下的MBR分区

    MBR分区 下面讲一讲如何给一块新添加入服务器的硬盘做MBR分区,那么为什么叫做MBR分区呢?后面会讲 做MBR分区,使用系统自带的fdisk工具.先看一看什么是fdisk,在命令行输入“fdisk” ...

  5. Linux磁盘挂载、分区、扩容操作

    本文最早发布于 Rootrl's blog 注:以下操作系统环境为CentOS7 基本概念 在操作前,首先要了解一些基本概念 磁盘 在Linux系统中所有的设备都会以文件的形式存储.设备一般保存在/d ...

  6. Linux磁盘管理——swap分区

    转自:Linux Swap交换分区设置 对swap分区的误解 一种流行的.以讹传讹的说法是,安装Linux系统时,交换分区swap的大小应该是内存的两倍.也就是说,如果内存是2G,那么就应该分出4G的 ...

  7. 如何快速将磁盘的MBR分区方式改成GPT分区方式

    注:修改分区格式时此硬盘不能是在使用状态(简单说就是不能出现在盘符中),如果在使用中先在计算机的磁盘管理中删除卷. 由于MBR分区表模式的硬盘最大只支持2T的硬盘空间,而现在我们的硬盘越来越大,有时候 ...

  8. 快速将磁盘的MBR分区方式改成GPT分区方式

    1.按Shift + F10打开命令提示符. 2.diskpart 3.list disk(列出所有磁盘) 4.select disk 0(选择磁盘) 5.clean(格式化所选的磁盘) 7.conv ...

  9. Linux磁盘管理——MBR 与 GPT

    硬件设备在Linux中文件名 如今IDE 磁盘几乎被淘汰,市面上最常见的磁盘就是SATA和SAS.个人计算机主要是SATA.很多Linux发行版下都将IDE磁盘文件名也都被仿真成 /dev/sd[a- ...

随机推荐

  1. [luogu4310] 绝世好题 (递推)

    传送门 题目描述 给定一个长度为n的数列ai,求ai的子序列bi的最长长度,满足bi&bi-1!=0(2<=i<=len). 输入输出格式 输入格式: 输入文件共2行. 第一行包括 ...

  2. Ubuntu安装Docker 适合Ubuntu17.04版本

    Docker介绍 Docker是一个开源的容器引擎,它有助于更快地交付产品.Docker可将应用程序和基础设施层隔离,并且将基础设施当作程序一样进行管理.使用Docker,可以更快地打包,测试以及部署 ...

  3. oracle 创建自增主键

    1.创建表 create table Test_Increase( userid number(10) NOT NULL primary key, /*主键,自动增加*/ username varch ...

  4. 使用jekyll配置一个自己的blog

    使用coding.net上提供的pages服务来配置一个自己的站点 提示:下载这些软件,最好能FQ,有些链接是国外的,淘宝的ruby镜像已经不提供服务了 1. 安装Ruby 2. 安装Rubygems ...

  5. C# try-catch-return

    正常执行try后才能执行finally,catch中的语句可能会影响finally的执行 使用 finally 块,可以清理在 Try 中分配的任何资源,而且,即使在 try 块中发生异常,您也可以运 ...

  6. HorizontalDragLayout-模仿QQclient的Item滑动删除

    首先感谢http://blog.csdn.net/lmj623565791/article/details/46858663hongyang的文章.之前看过ViewDragHelper类也读过一些de ...

  7. Hdu oj 1017 A Mathematical Curiosity

    题目:pid=1017">点击打开链接 #include<stdio.h> int main() { int t; scanf("%d",&t) ...

  8. 例说Linux内核链表(三)

    经常使用的linux内核双向链表API介绍 linux link list结构图例如以下: 内核双向链表的在linux内核中的位置:/include/linux/list.h 使用双向链表的过程,主要 ...

  9. linux下安装redis3.2

    这部分来自网络: http://blog.csdn.net/cuibruce/article/details/53501532 1.下载 下载地址:http://www.redis.io/downlo ...

  10. 13.ubuntu下Qt5无法使用中文的问题解决

    1.首先安装fcitx-frontend-qt5 sudo apt-get install fcitx-frontend-qt5 这个应该是默认安装的,然后查看fcitx-frontend-qt5 的 ...