我们在Linux操作过程中,可能会遇到磁盘分区的问题。这篇文章是对/dev/sdb 这块磁盘进行分区。
linux分区不同于windows,linux下硬盘设备名为(IDE硬盘为hdx(x为从a—d)因为IDE硬盘最多四个,SCSI,SATA,USB硬盘为sdx(x为a—z)),硬盘主分区最多为4个,不用说大家也知道…..所以主分区从sdb1开始到sdb4,逻辑分区从sdb5开始,(逻辑分区永远从sdb5开始…)
主分区(最多创建4个):第一个分区主要存放磁盘的启动信息。
扩展分区(Linux中最多创建1个):扩展分区属于逻辑架构,不能再创建文件系统,只能在下面创建逻辑分区。
逻辑分区:在扩展分区下面创建,不同的操作系统对逻辑分区个数限制也不同。
分区步骤:
1.fdisk 分区;
2.mkfs 格式化分区;
3.创建挂载点;
4.挂载磁盘或者编辑/etc/fstab文件设置开机自动挂载

1.查看当前操作系统的所有磁盘

[root@lgr ~]# fdisk -l

Disk /dev/sda: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14         535     4192965   82  Linux swap / Solaris
/dev/sda3             536        5221    37640295   83  Linux

Disk /dev/sdb: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdb doesn't contain a valid partition table

2.fdisk命令把sdb分成1个主分区,一个扩展分区

[root@lgr ~]# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.

The number of cylinders for this disk is set to 1305.
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)
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-1305, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-1305, default 1305): +5G

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
e
Partition number (1-4): 2
First cylinder (610-1305, default 610):
Using default value 610
Last cylinder or +size or +sizeM or +sizeK (610-1305, default 1305):
Using default value 1305

Command (m for help): n
Command action
   l   logical (5 or over)
   p   primary partition (1-4)
l
First cylinder (610-1305, default 610):
Using default value 610
Last cylinder or +size or +sizeM or +sizeK (610-1305, default 1305): +3G

Command (m for help):
Command (m for help): n
Command action
   l   logical (5 or over)
   p   primary partition (1-4)
l
First cylinder (976-1305, default 976):
Using default value 976
Last cylinder or +size or +sizeM or +sizeK (976-1305, default 1305): +2G

Command (m for help): p

Disk /dev/sdb: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1         609     4891761   83  Linux
/dev/sdb2             610        1305     5590620    5  Extended
/dev/sdb5             610         975     2939863+  83  Linux
/dev/sdb6             976        1219     1959898+  83  Linux

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.

3.mkfs命令对分区进行格式化

[root@lgr ~]# mkfs.ext3 /dev/sdb1
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
611648 inodes, 1222940 blocks
61147 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=1254096896
38 block groups
32768 blocks per group, 32768 fragments per group
16096 inodes per group
Superblock backups stored on blocks:
    32768, 98304, 163840, 229376, 294912, 819200, 884736

Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 30 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
[root@lgr ~]#
[root@lgr ~]# mkfs.ext3 /dev/sdb5
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
368000 inodes, 734965 blocks
36748 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=754974720
23 block groups
32768 blocks per group, 32768 fragments per group
16000 inodes per group
Superblock backups stored on blocks:
    32768, 98304, 163840, 229376, 294912

Writing inode tables: done                            
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 37 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
[root@lgr ~]# mkfs.ext3 /dev/sdb6
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
245280 inodes, 489974 blocks
24498 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=503316480
15 block groups
32768 blocks per group, 32768 fragments per group
16352 inodes per group
Superblock backups stored on blocks:
    32768, 98304, 163840, 229376, 294912

Writing inode tables: done                            
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 30 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

4.创建挂载点

[root@lgr ~]# mkdir /dsk1 /dsk5 /dsk6

5.mount命令做一次临时挂载,编辑/etc/fstab 可以设置开机自动挂载。

①临时挂载
mount /dev/sdb1 /dsk1
mount /dev/sdb5 /dsk5
mount /dev/sdb6 /dsk6

②编辑文件设置自动挂载
[root@lgr ~]# vi /etc/fstab
追加如下信息
/dev/sdb1               /dsk1                   ext3    defaults        0 0
/dev/sdb5               /dsk5                   ext3    defaults        0 0
/dev/sdb6               /dsk6                   ext3    defaults        0 0
说明:第一行:磁盘目录;第二行:挂载点;第三行:文件系统格式;第四行:启动磁盘方式;第五行:开机是否检测(0 不检测,1 检测);第六行:出错是否转储(0,不转储,1 转储)

6.重启系统,fdisk-l /dev/sdb 查看分区情况。

【Linux】磁盘分区相关推荐

  1. linux最常用的目录表示,Linux磁盘分区的命名方式和常用目录?【每日一个知识点第84期-Linux】...

    磁盘分区对于入门的linux来说,是非常入门的技能,也是日常管理中常用技能之一,今天我们来做一个回顾,帮助大家提升磁盘分区的技能. [84期主题]Linux磁盘分区的命名方式和常用目录? Linux分 ...

  2. Linux磁盘分区了解多少?Linux入门必看

    磁盘分区,顾名思义就是对电脑中的硬盘进行空间划分,这样不仅有利于备份,还可以对文件进行分门别类.那么你对Linux磁盘分区了解多少呢?我们通过这篇文章来学习一下. Linux磁盘分区主要分为基本分区和 ...

  3. linux磁盘 分区 物理卷 卷组 逻辑卷 文件系统加载点操作案例

    转自:truemylife.linux磁盘 分区 物理卷 卷组 逻辑卷 文件系统加载点操作案例 基本概念: 磁盘.分区.物理卷[物理部分] 卷组[中间部分] 逻辑卷.文件系统[虚拟化后可控制部分] 磁 ...

  4. Linux 磁盘分区 Fdisk

    linux磁盘分区:fdisk(小于2T的分区工具) [root@zyl ~]# fdisk -l            #####查看磁盘空间 Disk /dev/sda: 16.1 GB, 161 ...

  5. linux磁盘第一个扇区分析,Linux磁盘分区

    一.磁盘连接方式与设备文件名的关系 计算机常见的磁盘接口有两种,分别是IDE与SATA接口,目前主流接口已经是SATA接口了. 一个IDE扁平电缆可以连接两个IDE设备,通常主机又都会提供两个IDE接 ...

  6. linux中fdisk的参数,Linux fdisk命令参数及用法详解--Linux磁盘分区管理命令fdisk

    fdisk 命令 linux磁盘分区管理 用途:观察硬盘之实体使用情形与分割硬盘用. 使用方法: 一.在 console 上输入 fdisk -l /dev/sda ,观察硬盘之实体使用情形. 二.在 ...

  7. linux 磁盘监控,9个在Linux中监视Linux磁盘分区和用法的工具

    在这篇文章中,我们将回顾一些Linux的命令行工具 ,你可以使用它来检查磁盘分区在Linux中. 监控存储设备空间使用情况是SysAdmin的最重要的任务之一,这有助于确保存储设备上有足够的可用空间, ...

  8. linux 磁盘分区,格式化,挂载

    在操作系统中,磁盘管理属于设备管理的范畴,一块硬盘安装到主机之后称为裸设备,若要能够linux系统中使用必须对其进行如下步骤: 分区 --> 格式化 --> 挂载 1. linux 系统中 ...

  9. 实训|第七天横扫Linux磁盘分区、软件安装障碍附制作软件仓库

    期待已久的linux运维.oracle"培训班"终于开班了,我从已经开始长期四个半月的linux运维.oracle培训,每天白天我会好好学习,晚上回来我会努力更新教程,包括今天学到 ...

  10. LINUX磁盘分区挂载笔记

    目录 一.Linux磁盘分区 ① 基本分区与扩充分区 ② 对比windows磁盘分区 二.管理Linux主分区(基本分区) ① 新增一个主分区 ② 删除一个主分区 三.管理Linux扩充分区 ① 新增 ...

最新文章

  1. 蓝桥杯国赛知识点汇总
  2. 年终盘点篇:2018年开源市场5大发展趋势
  3. Java开源Web Service(转)
  4. golang值为nil的channel
  5. 使用Nginx反向代理部署laravel和history模式的Vue项目[更新]
  6. electron项目中使用jquery不生效的解决方法
  7. android 文件选择器_Android 开发 打开系统文件、图片、视频等 实现单选多选功能...
  8. 一次堆外OOM问题的排查过程
  9. CNCC2017中的深度学习与跨媒体智能
  10. 将自己写的脚本添加至开机自启动服务和chkconfig的原理
  11. UI初学者必备知识|最好的Sketch App 素材资源都在一流设计导航
  12. linux 2.6 内核的移植
  13. 进入地图后分别进行放大缩小操作
  14. 本地远程连接服务器调试
  15. apesv100数据库_生物信息学相关数据库资源介绍..ppt
  16. MenuetOS, FreeDOS 有了新的发行
  17. latex编辑器的选择、texlive的安装及学位模板的使用
  18. CCF201809-3
  19. 如何解决万能地图下载器下载的地图和选择范围不一致
  20. java数据结构--TreeSet

热门文章

  1. Android仿人人客户端(v5.7.1)——对从服务器端(网络)获取的图片进行本地双缓存处理(流程图或活动图)...
  2. android 中如何监听耳机键消息
  3. Ubuntu16.04下基于opencv--实现图像SIFT特征与全景图片的生成
  4. TeeChart Pro VCL/FMX教程(六):使用系列(二)
  5. 全图化引擎(AI·OS)中的编译技术
  6. swift中_的用法,忽略默认参数名。
  7. innodb_file_per_table 理解
  8. UVa11988 Broken Keyboard (a.k.a. Beiju Text)
  9. 22号大更新网站大面积降权的原因分析
  10. REMIX与LOCALHOST相连