您的位置:首页 > 运维架构 > Linux

Linux 磁盘认识

2017-11-16 17:30 274 查看
硬盘结构:

查看磁盘空间使用了多少?接近100%就是枯竭了

[root@admin ~]# df-h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 9.4G 3.5G 5.4G 40% /
tmpfs 491M 76K 491M 1% /dev/shm
/dev/sda1 190M 36M 145M 20% /boot

查看sda1 分区里block大小

[root@admin ~]#tune2fs -l /dev/sda1 | grep --color size
Filesystemfeatures: has_journal ext_attrresize_inode dir_index filetype needs_recovery extent flex_bg sparse_superhuge_file uninit_bg dir_nlink extra_isize
Block size: 1024
Fragmentsize: 1024
Flex block groupsize: 16
Inode size: 128

SAS和SATA接口对比




硬盘结构

查看sda1分区有block大小
[root@admin ~]#tune2fs -l /dev/sda1 | grep --color size
查看磁盘空间使用了多少?接近100%就是枯竭了
[root@admin ~]# df-h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 9.4G 3.5G 5.4G 40% /
tmpfs 491M 76K 491M 1% /dev/shm
/dev/sda1 190M 36M 145M 20% /boot
查看sda1 分区里block大小
[root@admin ~]#tune2fs -l /dev/sda1 | grep --color size
Filesystemfeatures: has_journal ext_attrresize_inode dir_index filetype needs_recovery extent flex_bg sparse_superhuge_file uninit_bg dir_nlink extra_isize
Block size: 1024
Fragmentsize: 1024
Flex block groupsize: 16
Inode size: 128



分区:
留了8G左右空间
fdisk
#fdisk –l #查看磁盘信息
#fdisk /dev/sdb #创建/管理分区
m 获得帮助
p 打印分区表
n 新建
p 主分区 ,e 扩展 #在MBR这样分区表中,只有一个扩展分区,最多4个主分区
q 退出
d 删除
w 保存

给磁盘分区实例:
[root@MK~]# fdisk /dev/sda

WARNING:DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') andchange display units to
sectors (command 'u').

Command(m for help): p

Disk /dev/sda:10.7 GB, 10737418240 bytes
255 heads, 63sectors/track, 1305 cylinders
Units = cylindersof 16065 * 512 = 8225280 bytes
Sector size(logical/physical): 512 bytes / 512 bytes
I/O size(minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000dadb8

Device Boot Start End Blocks Id System
/dev/sda1 * 1 26 204800 83 Linux
Partition 1 doesnot end on cylinder boundary.
/dev/sda2 26 287 2097152 83 Linux
Partition 2 doesnot end on cylinder boundary.
/dev/sda3 287 385 786432 82 Linux swap / Solaris
Partition 3 doesnot end on cylinder boundary.

Command(m for help): n
Command action
e extended
p primary partition (1-4)
e
Selected partition4
First cylinder(385-1305, default 385):
Using defaultvalue 385
Lastcylinder, +cylinders or +size{K,M,G} (385-1305, default 1305): +6G

Command(m for help): P

Disk /dev/sda:10.7 GB, 10737418240 bytes
255 heads, 63sectors/track, 1305 cylinders
Units = cylindersof 16065 * 512 = 8225280 bytes
Sector size(logical/physical): 512 bytes / 512 bytes
I/O size(minimum/optimal): 512 bytes / 512 bytes
Disk identifier:0x000dadb8

Device Boot Start End Blocks Id System
/dev/sda1 * 1 26 204800 83 Linux
Partition 1 doesnot end on cylinder boundary.
/dev/sda2 26 287 2097152 83 Linux
Partition 2 doesnot end on cylinder boundary.
/dev/sda3 287 385 786432 82 Linux swap / Solaris
Partition 3 doesnot end on cylinder boundary.
/dev/sda4 385 1168 6292552 5 Extended

Command(m for help): n
First cylinder(385-1168, default 385):
Using defaultvalue 385
Lastcylinder, +cylinders or +size{K,M,G} (385-1168, default 1168): +2G

Command(m for help): p

Disk /dev/sda:10.7 GB, 10737418240 bytes
255 heads, 63sectors/track, 1305 cylinders
Units = cylindersof 16065 * 512 = 8225280 bytes
Sector size(logical/physical): 512 bytes / 512 bytes
I/O size(minimum/optimal): 512 bytes / 512 bytes
Disk identifier:0x000dadb8

Device Boot Start End Blocks Id System
/dev/sda1 * 1 26 204800 83 Linux
Partition 1 doesnot end on cylinder boundary.
/dev/sda2 26 287 2097152 83 Linux
Partition 2 doesnot end on cylinder boundary.
/dev/sda3 287 385 786432 82 Linux swap / Solaris
Partition 3 doesnot end on cylinder boundary.
/dev/sda4 385 1168 6292552 5 Extended
/dev/sda5 385 646 2099555+ 83 Linux

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

Calling ioctl() tore-read partition table.

WARNING:Re-reading the partition table failed with error 16: Device or resource busy.
The kernel stilluses the old table. The new table will be used at
the next reboot orafter you run partprobe(8) or kpartx(8)
Syncing disks.
[root@MK~]# partprobe /dev/sda
Warning: WARNING:the kernel failed to re-read the partition table on /dev/sda (Device orresource busy). As a result, it may notreflect all of your changes until after reboot.
[root@MK ~]#
重启电脑生效
重启完之后创建挂在点
[root@MK~]# mkfs.ext4 /dev/sda5 (必须要格式化/dev/sda5后才能使用…这时候mount/dev/sda5 /sda5/才会生效)
[root@MK ~]# mkdir/sda5
[root@MK ~]# mount/dev/sda5 /sda5/
[root@MK ~]# ls/sda5/
lost+found
[root@MK ~]# df -h(查看有没有挂载上?出现sda5了就是挂载上了)
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 2.0G 1.4G 470M 75% /
tmpfs 491M 0 491M 0% /dev/shm
/dev/sda1 190M 36M 145M 20% /boot
/dev/sda5 2.0G 3.1M 1.9G 1% /sda5
[root@MK ~]#
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  磁盘 Linux