Linux系统磁盘
所有有系统都一样,都是一种软件被安装于某个硬件之上,这个硬件无外非是一种存储设备,通常操作系统都是安装在磁盘中,所以Linux系统也是一样,都是安装在磁盘中,但是它与Windows系统不一样,因为Linux都是需要创建文件系统才可以使用。
1、 磁盘分类
目前市场上的磁盘分类有:IDE磁盘(多用于PC机)、SATA磁盘、SAS磁盘、SSD磁盘等这么几种分类,企业中服务器大多为后面的两种,SATA磁盘多用于企业内部的一些业务、SAS磁盘多用于对外的业务(一些业务平台)。
SATA磁盘目前容量最大为4T、SAS磁盘一般都在300G--600G居多,企业生产环境中使用也最多的是这种容量的,实际生产中磁盘的使用主要是看性能需求,也就是磁盘的读写速度。
2、 磁盘的体系结构
企业级服务器多块磁盘的情况

3、 磁盘容量的计算
磁盘的结构一般包括磁道、盘面、扇区、碰头等
一个磁道的大小=512 字节*扇区数
一个盘面的大小=磁道的大小*磁道数
一个磁盘的大小=盘面大小*磁头数
因此
一个磁盘的容量=512 字节*扇区数*磁道数*磁头数

4、 磁盘分区
所有磁盘的分区信息都是存储在分区表中,Linux系统仅支持4个分区表信息(主分区+扩展分区),一个分区表的大小在64bytes
Linux一般分为三个分区分别是:boot分区、swap分区、/根分区
Linux的分区编号:主分区1-4,逻辑分区从5开始计算
实际生产环境分区要求
1、 最少要有/和swap两个分区
2、 swap(虚拟内存)=1.5*物理内存大小,一般大小于或等于16G的物理内存的服务器,swap分区一般都直接设置为16G大小
3、 建议设置/boot分区,Linux引导分区,如内核文件等,一般所有文件一共才几十M的大小,因此这个分区就设置为100-200M即可
5、 磁盘分区工具fdisk
fdisk是针对磁盘容量小于2T
[root@cairui ~]# fdisk --help
fdisk: invalid option -- '-' fdisk: Usage:
fdisk [options] <disk> change partition table
fdisk [options] -l <disk> list partition table(s)
fdisk -s <partition> give partition size(s) in blocks Options:
-b <size> sector size (, , or )
-c switch off DOS-compatible mode
-h print help
-u <size> give sizes in sectors instead of cylinders
-v print version
-C <number> specify the number of cylinders
-H <number> specify the number of heads
-S <number> specify the number of sectors per track : Success

[root@localhost ~]# fdisk /dev/sda1 #对/dev/sda1进行分区操作
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x02fadd9c.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable. Warning: invalid flag 0x0000 of partition table will be corrected by w(rite) WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u'). 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 #删除一个分区
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 action
e extended
p primary partition (-)
p
Partition number (-):
First cylinder (-, default ): 设置起始柱面
Using default value
Last cylinder, +cylinders or +size{K,M,G} (-, default ):
设置大小或柱面
Using default value
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
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): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
Command (m for help): p 打印分区表信息
Disk /dev/sdb: 21.5 GB, bytes
heads, sectors/track, cylinders
Units = cylinders of * = bytes
Sector size (logical/physical): bytes / bytes
/
I/O size (minimum/optimal): bytes / bytes
Disk identifier: 0xb712cc55
Device Boot Start End Blocks Id System
/dev/sdb1 + Linux
分区完成后执行 partprobe 通知系统分区表发生改变
接下来进行格式化分区
[root@Centos ~]# mkfs.ext3 /dev/sdb1
mke2fs 1.41. (-May-)
Filesystem label=
OS type: Linux
Block size= (log=)
Fragment size= (log=)
Stride= blocks, Stripe width= blocks
inodes, blocks
blocks (5.00%) reserved for the super user
First data block=
Maximum filesystem blocks=
block groups
blocks per group, fragments per group
inodes per group
Superblock backups stored on blocks:
, , , , , , , , , Writing inode tables: done
Creating journal ( blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every mounts or
days, whichever comes first. Use tune2fs -c or -i to override.
[root@Centos ~]# tune2fs -c - /dev/sdb1
tune2fs 1.41. (-May-)
Setting maximal mount count to -
[root@Centos ~]# mount /dev/sdb1 /mnt 挂载分区至/mnt 下
[root@Centos ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root 50G .5G 44G % /
tmpfs 932M 932M % /dev/shm
/dev/sda1 485M 39M 421M % /boot
/
/dev/mapper/VolGroup-lv_home 26G 215M 24G % /home
/dev/sdb1 20G 172M 19G % /mnt
6、 磁盘分区工具parted
由于环境限制无法有2T或者以上大小的磁盘,只能模拟环境来使用parted分区工具来进行分区
[root@Centos ~]# parted /dev/sdb mklabel gpt
将磁盘转换成 gpt 的格式
[root@Centos ~]# parted /dev/sdb mkpart primary (200M)
Warning: The resulting partition is not properly aligned for best
performance.
Ignore/Cancel? Ignore
[root@Centos ~]# parted /dev/sdb p 打印分区表信息
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdb: 1074MB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Number Start End Size File system Name Flags
.4kB 200MB 200MB primary
[root@Centos ~]# parted /dev/sdb mkpart primary
分区并设置大小
Information: You may need to update /etc/fstab.
[root@Centos ~]# parted /dev/sdb p 打印分区表信息
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdb: 1074MB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Number Start End Size File system Name Flags
.4kB 200MB 200MB primary
201MB 1073MB 871MB primary
[root@Centos ~]# mkfs.ext4 /dev/sdb1
mke2fs 1.41. (-May-)
Filesystem label=
OS type: Linux
Block size= (log=)
Fragment size= (log=)
/
Stride= blocks, Stripe width= blocks
inodes, blocks
blocks (5.00%) reserved for the super user
First data block=
Maximum filesystem blocks=
block groups
blocks per group, fragments per group
inodes per group
Superblock backups stored on blocks:
, , , ,
Writing inode tables: done
Creating journal ( blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every mounts or
days, whichever comes first. Use tune2fs -c or -i to override.
[root@Centos ~]# tune2fs -c - /dev/sdb1
tune2fs 1.41. (-May-)
Setting maximal mount count to -
[root@Centos ~]# mount /dev/sdb1 /mnt
[root@Centos ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root 50G .5G 44G % /
tmpfs 932M 932M % /dev/shm
/dev/sda1 485M 39M 421M % /boot
/dev/mapper/VolGroup-lv_home 26G 215M 24G % /home
/dev/sdb1 185M 5.6M 170M % /mnt
[root@cairui ~]# parted --help
Usage: parted [OPTION]... [DEVICE [COMMAND [PARAMETERS]...]...]
Apply COMMANDs with PARAMETERS to DEVICE. If no COMMAND(s) are given, run in
interactive mode. OPTIONs:
-h, --help displays this help message
-l, --list lists partition layout on all block devices
-m, --machine displays machine parseable output
-s, --script never prompts for user intervention
-v, --version displays the version
-a, --align=[none|cyl|min|opt] alignment for new partitions COMMANDs:
align-check TYPE N check partition N for TYPE(min|opt)
alignment
check NUMBER do a simple check on the file system
cp [FROM-DEVICE] FROM-NUMBER TO-NUMBER copy file system to another partition
help [COMMAND] print general help, or help on
COMMAND
mklabel,mktable LABEL-TYPE create a new disklabel (partition
table)
mkfs NUMBER FS-TYPE make a FS-TYPE file system on
partition NUMBER
mkpart PART-TYPE [FS-TYPE] START END make a partition
mkpartfs PART-TYPE FS-TYPE START END make a partition with a file system
move NUMBER START END move partition NUMBER
name NUMBER NAME name partition NUMBER as NAME
print [devices|free|list,all|NUMBER] display the partition table,
available devices, free space, all found partitions, or a particular
partition
quit exit program
rescue START END rescue a lost partition near START
and END
resize NUMBER START END resize partition NUMBER and its file
system
rm NUMBER delete partition NUMBER
select DEVICE choose the device to edit
set NUMBER FLAG STATE change the FLAG on partition NUMBER
toggle [NUMBER [FLAG]] toggle the state of FLAG on partition
NUMBER
unit UNIT set the default unit to UNIT
version display the version number and
copyright information of GNU Parted
Linux系统磁盘的更多相关文章
- linux 系统磁盘管理体系
目录 linux 系统磁盘管理体系 一.磁盘的基本概念 二.磁盘的内部结构 三.磁盘的外部结构 四.磁盘的接口及类型 五.fdisk磁盘分区实践 六.gdisk 分区 七.parted 高级分区工具. ...
- Linux系统磁盘分区、删除分区、格式化、挂载、卸载、开机自动挂载的方法总结
Linux系统按照MBR(Master Boot Record)传统分区模式: 注意:传统的MBR(Master Boot Record)分区方式最大只能分2T容量的硬盘,超过2T的硬盘一般采用GPT ...
- linux 系统磁盘管理(主分区和逻辑分区)
摘要:linux系统磁盘管理主分区和逻辑分区 1.linux系统分区应了解的常识 硬盘分区实质上是对硬盘的一种格式化,然后才能使用硬盘保存各种信息,在创建分区时,就已经设置好了硬盘的各项物理参数,指定 ...
- windows系统c盘占满/linux系统磁盘block、inode占满处理
windows系统 下载c盘清理.bat到服务器,双击bat文件将自动清理 linux系统 先远程ssh登录上服务器,登录教程:http://www.west263.com/faq/list.asp? ...
- Linux系统磁盘与分区管理(7)
Linux最传统的磁盘文件系统(filesystem)使用的是EXT4格式,所以要了解文件系统就得要由认识EXT4开始,而文件系统是创建在硬盘上面的,因此我们得了解硬盘的物理组成才行,下面我们回来详细 ...
- Linux系统——磁盘管理
磁盘结构 (1)硬盘的物理结构 磁头:每面一个磁盘 盘片:硬盘有多个盘片,每个盘片2面 (2)硬盘的数据结构 扇区:盘片被分为多个扇形区域,每个扇形区存放512字节的数据 磁道:统一盘片不同半径的同心 ...
- Linux 系统磁盘空间占满,df 和 du 结果不一致
服务器运行一段时间后df查看磁盘剩余空间不足,通过du统计发现被几个文件占用,遂删除之.过了一段时间磁盘空间再次不足,通过du统计却找不到那么多大文件.搜索后才得知原因:文件删除后空间没有释放,du统 ...
- Linux系统磁盘管理(lvm逻辑卷管理)
linux系统用户常遇到的一个问题就是如何精准的评估分区的大小,已分配合适的磁盘空间:普通的磁盘分区管理方式在逻辑分区划分好之后就无法改变其大小,当一个逻辑分区存放不下某个文件时,这个文件因为受上层文 ...
- Linux系统 磁盘IO过高排查总结
最近做的一个电商网站因为磁盘 I/O 过高导致访问速度奇慢,问题存在两个月有余未得到解决办法.此次排查原因的经验可以作下次问题的参考. 1.会看懂 top 系统命令出来的各项参数.此次是无意中发现 u ...
随机推荐
- mysql存储过程获取sqlstate message_text
群里有人询问,在mysql的proc中如何获取错误信息.错误编号呢?我们知道在oracle.mssql中比较简单: oracle中sqlcode,sqlerrm ;mssql中ERROR_PROCED ...
- [Angularjs-学习笔记]工具篇
因为一开始学习前端知识一直都是在慕课网,所以这次准备学习下angularjs等了好久,终于慕课网出了angularjs的内容,于是准备开始跟着老师的步骤进行学习. 大漠老师关于开发工具的内容讲得比较快 ...
- Oracle user,role,profile常规操作--用户,权限,角色,配置文件
Oracle user,role,profile常规操作--用户,权限,角色,配置文件 1 权限查询 1查看所有用户 SQL> select username,account_status,lo ...
- mjpg-streamer在Ubuntu下编译,运行
1.将USB摄像头插上,查看是否找到设备,输入: wp@ubuntu:/home/$ ls /dev/video* /dev/video0 2.安装必要的软件集: sudo apt-get ...
- Rails的静态资源管理(四)—— 生产环境的 Asset Pipeline
官方文档:http://guides.ruby-china.org/asset_pipeline.html http://guides.rubyonrails.org/asset_pipeline.h ...
- SQL基础(2)
SQL TOP (1)TOP子句 OP 子句用于规定要返回的记录的数目. 对于拥有数千条记录的大型表来说,TOP 子句是非常有用的. 注释:并非所有的数据库系统都支持 TOP 子句. (2)SQL S ...
- Linux 正文处理命令及tar vi 编辑器
root 用户不受权限设置 如果文件有x 就可以执行 对目录的权限 r:可以查看目录下面的文件名 w:可以在该目录下新建,删除,修改文件名 x:可以cd进入目录 对于文件: 可执行的文件来说需要有可读 ...
- Recovery of DISKGROUP in VXVM (ZT)
http://gurkulindia.com/main/2012/03/recovery-of-diskgroup-in-vxvm-veritas-volume-manager/# Since lon ...
- 《Android应用性能优化》 第6章 性能评测和剖析
1.时间测量 System.currentTimeMillis 精读和准确度可能不够:更改系统时间会影响结果:UTC时间1970/1/1 00:00:00到现在的毫秒数 System.nanoTime ...
- lucene、solr中的日期衰减方法-------function query --尚未测试在solr4.8
经常有一种情景是这样的:我们索引了N年的文章,而查询时候无论直接用相关度.或者用时间排序,都是比较鲁莽的:我们想要一种既要相关度比较高,又要时间上比较新的文章. 这时候的解决办法就是,自定义日期衰减的 ...