一、linux磁盘管理
- 命令:fdisk -l
- brwx-rw--- 其中b(占位符)代表block,块设备文件
- sda,sdb... --> 硬盘 其中sda1,sda2..sdb1,sdb2...-->硬盘分区 (s:硬盘接口;d:disk)
- 了解硬盘接口:stata,sas --> 服务器借口
- scsi,ide --> 个人电脑接口
- fdisk -l 后有个 cylinder : 磁柱
- 起始与结束
- 查看硬盘是否分区
- 虚拟机添加新硬盘(单个文件),重新启动,分区
- 概念:主分区(格式化后直接使用),扩展分区(格式化后还要进行逻辑分区才能使用),逻辑分区(与主分区类似,但非系统分区)
- 利用fdisk /dev/sdb来对sdb(新加的硬盘)进行分区
- 分区步骤:分一个10G的主分区,剩下的为扩展分区,再从扩展分区中分出两块逻辑分区,结构为2+1
- 分区保存后,重启使分区文件加载生效
- 格式化:mkfs.文件系统(ext1,ext2,ext3,ext4,centos 7 使用的文件系统xfs) 例:mkfs.ext4 /dev/sdb6
- 格式化完毕,还需要挂载磁盘(mount临时的,用法mount /dev/sdb6 /mnt/(一般挂载点)),才能使用
- 若要永久挂载,需要写入配置文件/etc/fstab
- 取消挂载 umount /mnt/
- 查看挂载信息,容量等信息(df -h)
二、实际操作
[root@hadoop09-linux ~]# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x2859532e.
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 4 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 (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-2610, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-2610, default 2610): +10G Command (m for help): p Disk /dev/sdb: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x2859532e Device Boot Start End Blocks Id System
/dev/sdb1 1 1306 10490413+ 83 Linux Command (m for help): n
Command action
e extended
p primary partition (1-4)
e
Partition number (1-4): 2
First cylinder (1307-2610, default 1307):
Using default value 1307
Last cylinder, +cylinders or +size{K,M,G} (1307-2610, default 2610):
Using default value 2610 Command (m for help): p Disk /dev/sdb: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x2859532e Device Boot Start End Blocks Id System
/dev/sdb1 1 1306 10490413+ 83 Linux
/dev/sdb2 1307 2610 10474380 5 Extended Command (m for help): n
Command action
l logical (5 or over)
p primary partition (1-4)
l
First cylinder (1307-2610, default 1307):
Using default value 1307
Last cylinder, +cylinders or +size{K,M,G} (1307-2610, default 2610): +4G Command (m for help): p Disk /dev/sdb: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x2859532e Device Boot Start End Blocks Id System
/dev/sdb1 1 1306 10490413+ 83 Linux
/dev/sdb2 1307 2610 10474380 5 Extended
/dev/sdb5 1307 1829 4200966 83 Linux Command (m for help): n
Command action
l logical (5 or over)
p primary partition (1-4)
l
First cylinder (1830-2610, default 1830):
Using default value 1830
Last cylinder, +cylinders or +size{K,M,G} (1830-2610, default 2610): +4G Command (m for help): p Disk /dev/sdb: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x2859532e Device Boot Start End Blocks Id System
/dev/sdb1 1 1306 10490413+ 83 Linux
/dev/sdb2 1307 2610 10474380 5 Extended
/dev/sdb5 1307 1829 4200966 83 Linux
/dev/sdb6 1830 2352 4200966 83 Linux 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.
[root@hadoop09-linux ~]# fdisk -l Disk /dev/sda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00062208 Device Boot Start End Blocks Id System
/dev/sda1 * 1 39 307200 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 39 2358 18631680 83 Linux
/dev/sda3 2358 2611 2031616 82 Linux swap / Solaris Disk /dev/sdb: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x2859532e Device Boot Start End Blocks Id System
/dev/sdb1 1 1306 10490413+ 83 Linux
/dev/sdb2 1307 2610 10474380 5 Extended
/dev/sdb5 1307 1829 4200966 83 Linux
/dev/sdb6 1830 2352 4200966 83 Linux
[root@hadoop09-linux ~]# reboot Broadcast message from root@hadoop09-linux.ibeifeng.com
(/dev/pts/0) at 8:51 ... The system is going down for reboot NOW!
[root@hadoop09-linux ~]#
Connection closed by foreign host. Disconnected from remote host(CentOs_64) at 23:52:01. Type `help' to learn how to use Xshell prompt.
[d:\~]$ Connecting to 192.168.0.108:22...
Connection established.
To escape to local shell, press 'Ctrl+Alt+]'. Last login: Wed Sep 7 08:27:29 2016 from 192.168.0.105
[root@hadoop09-linux ~]# fdisk -l Disk /dev/sda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00062208 Device Boot Start End Blocks Id System
/dev/sda1 * 1 39 307200 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 39 2358 18631680 83 Linux
/dev/sda3 2358 2611 2031616 82 Linux swap / Solaris Disk /dev/sdb: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x2859532e Device Boot Start End Blocks Id System
/dev/sdb1 1 1306 10490413+ 83 Linux
/dev/sdb2 1307 2610 10474380 5 Extended
/dev/sdb5 1307 1829 4200966 83 Linux
/dev/sdb6 1830 2352 4200966 83 Linux
[root@hadoop09-linux ~]# mkfs.ext4 /dev/sdb6
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
262944 inodes, 1050241 blocks
52512 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=1077936128
33 block groups
32768 blocks per group, 32768 fragments per group
7968 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 34 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@hadoop09-linux ~]# mount /dev/sdb6 /mnt/
[root@hadoop09-linux ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 18G 2.5G 15G 15% /
tmpfs 495M 72K 495M 1% /dev/shm
/dev/sda1 291M 33M 243M 12% /boot
/dev/sdb6 4.0G 137M 3.7G 4% /mnt
永久挂载
[root@hadoop09-linux ~]# vi /etc/fstab #
# /etc/fstab
# Created by anaconda on Fri Sep 2 08:10:36 2016
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=517d46c1-d4c6-41ba-94f7-b0cac93f178b / ext4 defaults 1 1
UUID=75090abd-0581-411d-863a-73d735fb90df /boot ext4 defaults 1 2
UUID=25865ffd-404c-49c2-afba-374d7a5a81df swap swap defaults 0 0
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
/etc/sdb6 /mnt ext4 defaults 0 0
Linux_磁盘管理的更多相关文章
-
liunx 磁盘管理命令记录
Linux磁盘管理好坏管理直接关系到整个系统的性能问题. Linux磁盘管理常用三个命令为df.du和fdisk. df:列出文件系统的整体磁盘使用量 du:检查磁盘空间使用量 fdisk:用于磁盘分 ...
-
Windows Server 2012 磁盘管理之 简单卷、跨区卷、带区卷、镜像卷和RAID-5卷
今天给客户配置故障转移群集,在Windows Server 2012 R2的系统上,通过iSCSI连接上DELL的SAN存储后,在磁盘管理里面发现可以新建 简单卷.跨区卷.带区卷.镜像卷.RAID-5 ...
-
Linux常用命令学习7---(磁盘管理df du、磁盘的分区和格式化fdisk parted)
1.磁盘管理 在服务器的维护中,我们需要关心服务器的磁盘使用了多少.还有多少的剩余空间.某个文件有多大.某个文件夹内的所有文件在一起一共占用的多少空间……问题.以便我们在合适的时机为服务器添加硬 ...
-
LINUX的磁盘管理du命令详解
LINUX的磁盘管理du命令详解 du(disk usage)命令可以计算文件或目录所占的磁盘空间.没有指定任何选项时, 它会测量当前工作目录与其所有子目录,分别显示各个目录所占的快数,最后才显示工作 ...
-
用Win7自带的磁盘管理工具给硬盘分区
最近新买了一台笔记本,要给硬盘分几个区,心想还是用个工具方便点,于是就上网准备下个“硬盘分区魔术师”,但是看到有一篇文章介绍Win7系统也自带了硬盘分区工具,这我以前倒没听说过,试了一下,还挺方便好用 ...
-
Linux 磁盘管理
Linux磁盘管理好坏管理直接关系到整个系统的性能问题. Linux磁盘管理常用三个命令为df.du和fdisk. df:列出文件系统的整体磁盘使用量 du:检查磁盘空间使用量 fdisk:用于磁盘分 ...
-
Linux_06------Linux的磁盘管理
进制编码 * 3.格式化交换分区 * 4.启用交换分区 * * 1.2. * fdisk /dev/sdb * p * t * 6(分区编号) * L(查看编码列表),找到SWAP交换分区标号 * 8 ...
-
Linux 系统常用命令汇总(五) 磁盘管理
磁盘管理 命令 选项 注解 示例 df [选项] 显示磁盘空间使用情况 显示磁盘空间是员工情况,以M显示: df -m -i 使用inodes显示结果 -k(m) 使用KB(MB)显示结果 du ...
-
Linux命令工具基础04 磁盘管理
Linux命令工具基础04 磁盘管理 日程磁盘管理中,我们最常用的有查看当前磁盘使用情况,查看当前目录所占大小,以及打包压缩与解压缩: 查看磁盘空间 查看磁盘空间利用大小 df -h -h: huma ...
随机推荐
-
js对象详解
js自定义对象 一,概述 在Java语言中,我们可以定义自己的类,并根据这些类创建对象来使用,在Javascript中,我们也可以定义自己的类,例如定义User类.Hashtable类等等. 目前在J ...
-
hdu5269 Chip Factory
地址:http://acm.split.hdu.edu.cn/showproblem.php?pid=5536 题目: Chip Factory Time Limit: 18000/9000 MS ( ...
-
UI框架说明
JQueryEasyUI jQuery EasyUI是一组基于jQuery的UI插件集合,而jQuery EasyUI的目标就是帮助web开发者更轻松的打造出功能丰富并且美观的UI界面.开发者不需要编 ...
-
C++ Primer 笔记——拷贝控制
1.如果构造函数的第一个参数是自身类类型的引用,且任何额外参数都有默认值,则此构造函数是拷贝构造函数.拷贝构造函数的第一个参数必须是引用类型(否则会无限循环的调用拷贝构造函数). 2.如果没有为一个类 ...
-
Tomcat connectionTimeout问题定位处理
问题现象 在某个时刻,后端收到了平时4-6倍的请求(保密起见,略去产品和事件),在10分钟后居然没有请求可以接进来 问题原因 经过分析,首先,是后端服务器的线程池满了,线程池满的原因:1.server ...
-
Solr全文检索框架
概述: 什么是Solr? Solr是Apache下的一个*开源项目,采用Java开发,它是基于Lucene的全文搜索服务.Solr可以独立运行在Jetty.tomcat.webLogic.webSh ...
-
CentOS7 使用ntp设置系统时间,开机自动设置时间,
首先如果没有安装ntp自己装一下: yum install -y ntp 然后,如果开了防火墙,记得打开自己的123端口,该端口是ntp用来同步时间的 firewall-cmd --zone=publ ...
-
微信小程序相关三、css写小黄人
小程序上课第三天,因为今天院里有活动,所以没去上课,第四天上午又因为要召开入党转正大会,又耽误了一上午,下午去上课,要了资料.这两天讲了一些零零碎碎的东西,做的实例有上面这个小黄人 都是用的css,基 ...
-
Java连接redis集群操作存储、删除以及获取值
pom文件添加: <!-- https://mvnrepository.com/artifact/redis.clients/jedis --> <dependency> &l ...
-
【题解】UVA1218 Perfect Service
UVA1218:https://www.luogu.org/problemnew/show/UVA1218 刷紫书DP题ing 思路 参考lrj紫书 不喜勿喷 d(u,0):u是服务器,孩子是不是服务 ...