Linux_磁盘管理
一、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 ...
随机推荐
- sidt十六进制代码
00121453 0F010D 40441200 sidt fword ptr ds:[gliu]0012145A 0F014D B0 sidt fword ptr ss:[ebp-0x50]0012 ...
- html5 head头标签
桌面端开发中,meta标签通常用来为搜索引擎优化(SEO)及 robots定义页面主题,或者是定义用户浏览器上的cookie:它可以用于鉴别作者,设定页面格式,标注内容提要和关键字:还可以设置页面使其 ...
- for循环嵌套
今天复习了分支语句以及for循环,新内容主要讲解了for循环的嵌套: 外循环控制行,内循环控制列 下面几个实例: 五行五列的矩阵 左下角是直角的三角形: 左上角是直角的三角形: 右上角为直角的三角形: ...
- SSH无密码登录配置小结
ssh-keygen -t rsa //-t指定算法 将公钥复制到被管理机器上面 ssh-copy-id -i ~/.ssh/id_rsa.pub 172.29.0.89 ssh-copy-id -i ...
- hdu1003 dp
题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=1003 #include<cstdio> #include<algorit ...
- 2016.8.21 JavaScript 入门
1.JavaScript的数据类型: ①undefined ②null ③boolean ④string ⑤symbol ⑥number, object 2.在JavaScript中所有的变量和 ...
- poj 2774 Long Long Message 后缀数组基础题
Time Limit: 4000MS Memory Limit: 131072K Total Submissions: 24756 Accepted: 10130 Case Time Limi ...
- 使用Spring的JAVA Mail支持简化邮件发送
http://www.cnblogs.com/codeplus/archive/2011/11/03/2232893.html
- Android客户端性能测试(一):使用APT测试Android应用性能
一.APT介绍: APT:Android Performance Testing Tools,适用于开发自测和定位性能瓶颈,帮助测试人员完成[性能基准测试.竞品测试]. APT提供了CPU利用率实时曲 ...
- html5大纲
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...