Linux之磁盘管理
本章重点提示:
1):理解基础命令,df,fdisk.
2):磁盘分区的理论基础。
1:查看当前系统分区与挂载情况:
[root@localhost ~]# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda2 % /
tmpfs % /dev/shm
/dev/sda1 % /boot
2:查看系统所有能识别的分区情况(包括系统已识别,未挂载的分区):
[root@localhost ~]# fdisk -l Disk /dev/sda: 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: 0x00077367 Device Boot Start End Blocks Id System
/dev/sda1 * Linux
Partition does not end on cylinder boundary.
/dev/sda2 Linux
/dev/sda3 Linux swap / Solaris 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: 0x00000000 Disk /dev/sdc: MB, bytes
heads, sectors/track, cylinders
Units = cylinders of * = bytes
Sector size (logical/physical): bytes / bytes
I/O size (minimum/optimal): bytes / bytes
Disk identifier: 0xcb2e3fe7 Device Boot Start End Blocks Id System
其中Disk /dev/sdc: 7776 MB,是外接的8G U盘
3:进入分区(8G U盘):
[root@localhost ~]# fdisk /dev/sdc 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):
4:m,查看帮助命令:
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)
5:n,新增分区:
Command (m for help): n
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 ): + 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.
6:显示分区信息,可以发现刚才新建的分区:
[root@localhost ~]# fdisk -l Disk /dev/sda: 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: 0x00077367 Device Boot Start End Blocks Id System
/dev/sda1 * Linux
Partition does not end on cylinder boundary.
/dev/sda2 Linux
/dev/sda3 Linux swap / Solaris 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: 0x00000000 Disk /dev/sdc: MB, bytes
heads, sectors/track, cylinders
Units = cylinders of * = bytes
Sector size (logical/physical): bytes / bytes
I/O size (minimum/optimal): bytes / bytes
Disk identifier: 0xcb2e3fe7 Device Boot Start End Blocks Id System
/dev/sdc1 Linux
7:重复刚才的操作,先新建一个扩展分区,再新建一个逻辑分区:
[root@localhost ~]# fdisk -l Disk /dev/sda: 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: 0x00077367 Device Boot Start End Blocks Id System
/dev/sda1 * Linux
Partition does not end on cylinder boundary.
/dev/sda2 Linux
/dev/sda3 Linux swap / Solaris 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: 0x00000000 Disk /dev/sdc: MB, bytes
heads, sectors/track, cylinders
Units = cylinders of * = bytes
Sector size (logical/physical): bytes / bytes
I/O size (minimum/optimal): bytes / bytes
Disk identifier: 0xcb2e3fe7 Device Boot Start End Blocks Id System
/dev/sdc1 Linux
[root@localhost ~]# fdisk /dev/sdc 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 (-)
e
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.
[root@localhost ~]# fdisk -l Disk /dev/sda: 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: 0x00077367 Device Boot Start End Blocks Id System
/dev/sda1 * Linux
Partition does not end on cylinder boundary.
/dev/sda2 Linux
/dev/sda3 Linux swap / Solaris 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: 0x00000000 Disk /dev/sdc: MB, bytes
heads, sectors/track, cylinders
Units = cylinders of * = bytes
Sector size (logical/physical): bytes / bytes
I/O size (minimum/optimal): bytes / bytes
Disk identifier: 0xcb2e3fe7 Device Boot Start End Blocks Id System
/dev/sdc1 Linux
/dev/sdc2 Extended
[root@localhost ~]# fdisk /dev/sdc 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
l logical ( or over)
p primary partition (-)
l
First cylinder (-, default ):
Using default value
Last cylinder, +cylinders or +size{K,M,G} (-, default ):
Using default value Command (m for help): w
The partition table has been altered! Calling ioctl() to re-read partition table.
Syncing disks.
[root@localhost ~]# fdisk -l Disk /dev/sda: 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: 0x00077367 Device Boot Start End Blocks Id System
/dev/sda1 * Linux
Partition does not end on cylinder boundary.
/dev/sda2 Linux
/dev/sda3 Linux swap / Solaris 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: 0x00000000 Disk /dev/sdc: MB, bytes
heads, sectors/track, cylinders
Units = cylinders of * = bytes
Sector size (logical/physical): bytes / bytes
I/O size (minimum/optimal): bytes / bytes
Disk identifier: 0xcb2e3fe7 Device Boot Start End Blocks Id System
/dev/sdc1 Linux
/dev/sdc2 Extended
/dev/sdc5 Linux
8:查看当前系统格式:
[root@localhost ~]# df -TH
Filesystem Type Size Used Avail Use% Mounted on
/dev/sda2 ext4 19G .1G 15G % /
tmpfs tmpfs 515M 82k 515M % /dev/shm
/dev/sda1 ext4 297M 30M 252M % /boot
9:格式化分区:
[root@localhost ~]# ]mkfs -t ext3 /dev/sdc1
-bash: ]mkfs: command not found
[root@localhost ~]# mkfs -t ext4 /dev/sdc1
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@localhost ~]# mkfs -t ext4 /dev/sdc5
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.
10:挂载分区:
[root@localhost ~]# mount /dev/sdc1 /mnt/; mount /dev/sdc5 /mnt/
11:查看当前系统挂载分区信息:
[root@localhost ~]# df -TH
Filesystem Type Size Used Avail Use% Mounted on
/dev/sda2 ext4 19G .1G 15G % /
tmpfs tmpfs 515M 82k 515M % /dev/shm
/dev/sda1 ext4 297M 30M 252M % /boot
/dev/sdc1 ext4 .9G 7.8M .7G % /mnt
/dev/sdc5 ext4 .9G 7.8M .7G % /mnt
Linux之磁盘管理的更多相关文章
- LINUX的磁盘管理du命令详解
LINUX的磁盘管理du命令详解 du(disk usage)命令可以计算文件或目录所占的磁盘空间.没有指定任何选项时, 它会测量当前工作目录与其所有子目录,分别显示各个目录所占的快数,最后才显示工作 ...
- Linux命令——磁盘管理
Linux命令--磁盘管理 命令df 作用:查看已挂载磁盘的总容量.使用容量.剩余容量等 参数:-i,查看inodes的使用状况 参数:-h,使用合适的单位显示(推荐) 命令du 作用:查看某个目录或 ...
- centos Linux下磁盘管理 parted,df ,du,fdisk,partprobe,mkfs.ext4,mount,/etc/fstab,fsck,e2fsck,mk2efs,tmpfs ,nr_inodes, LVM,传统方式扩容文件系统 第七节课
centos Linux下磁盘管理 parted,df ,du,fdisk,partprobe,mkfs.ext4,mount,/etc/fstab,fsck,e2fsck,mk2efs,tmpf ...
- Linux下磁盘管理命令df与du
Linux下磁盘管理命令df与du 对磁盘进行查看和控制的两个linux命令,df和du. 一.du命令 首先看一下du的help说明: [root@misdwh opt]# du --help ...
- Linux RAID 磁盘管理
Linux RAID 磁盘管理 RAID工作模式介绍:https://www.cnblogs.com/xiangsikai/p/8441440.html 本章主要讲解 Linux下 RAID5 与 R ...
- Linux命令-磁盘管理(二)
Linux命令-磁盘管理(二) Linux mmount命令 Linux mmount命令用于挂入MS-DOS文件系统. mmount为mtools工具指令,可根据[mount参数]中的设置,将磁盘内 ...
- Linux命令-磁盘管理(一)
Linux命令-磁盘管理(一) Linux cd命令 Linux cd命令用于切换当前工作目录至 dirName(目录参数). 其中 dirName 表示法可为绝对路径或相对路径.若目录名称省略,则变 ...
- linux 系统磁盘管理体系
目录 linux 系统磁盘管理体系 一.磁盘的基本概念 二.磁盘的内部结构 三.磁盘的外部结构 四.磁盘的接口及类型 五.fdisk磁盘分区实践 六.gdisk 分区 七.parted 高级分区工具. ...
- linux 系统磁盘管理(主分区和逻辑分区)
摘要:linux系统磁盘管理主分区和逻辑分区 1.linux系统分区应了解的常识 硬盘分区实质上是对硬盘的一种格式化,然后才能使用硬盘保存各种信息,在创建分区时,就已经设置好了硬盘的各项物理参数,指定 ...
- Linux系统磁盘管理
1 Linux磁盘管理体系简介 Linux磁盘管理分为五个步骤:首先在服务器上添加相应的硬盘(如/dev/sda.sdb.sdc等),对全新的服务器(即没有操作系统)做硬RAID0.RAID1.RAI ...
随机推荐
- DataGridView操作
C# DataGridView控件动态添加新行 DataGridView控件在实际应用中非常实用,特别需要表格显示数据时.可以静态绑定数据源,这样就自动为DataGridView控件添加相应的行.假如 ...
- webview--网络超时
package com.test.js2java; import java.util.Timer; import java.util.TimerTask; import android.app.Act ...
- PHPStorm+XDebug进行调试图文教程以及解析wamp的php.ini设置不生效的原因
这篇文章主要为大家详细介绍了PHPStorm+XDebug进行调试图文教程,内容很丰富,具有一定的参考价值,感兴趣的小伙伴们可以参考一下 笔者的开发环境如下:Windows8.1+Apache+P ...
- java内部类的作用分析
提起Java内部类(Inner Class)可能很多人不太熟悉,实际上类似的概念在C++里也有,那就是嵌套类(Nested Class),关于这两者的区别与联系,在下文中会有对比.内部类从表面上看,就 ...
- centos6.4添加fedora-epel源
1. 去sohu镜像下载epel-release-6包 并安装.#wget http://mirrors.sohu.com/fedora-epel/6/x86_64/epel-release-6-8. ...
- Oracle中常用操作
查看表中的字段名和类型 SELECT column_name,DATA_TYPE FROM cols WHERE TABLE_NAME=upper('tableName') ORDER BY COLU ...
- photoshop CS 调整选择区域的大小
网上看到说:矩形选框不能直接调整大小,如果你不想重新画一个可以利用转换路径,然后再调整.这是不对的,矩形选框是可以调整大小的,使用"变换选区"即可. 对应步骤截图如下: 1.画 ...
- (easy)LeetCode 235.Lowest Common Ancestor of a Binary Search Tree
Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BS ...
- JavaWeb四个域
一.ServletContext对象(Context域)1.服务器启动的时候,会为每一个webapp创建一个对应的ServletContext对象,他代表该webapp,当服务器停止或将webapp从 ...
- Xpath定位大全
selenium使用Xpath定位之完整篇 其中有一片文章提到了xpath元素定位,但是该文章中有些并不能适应一些特殊与个性化的场景.在文本中提供xpath元素的定位终极篇,你一定能在这里找到你需 ...