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 ...
随机推荐
- HDU 4005 The war Tarjan+dp
The war Problem Description In the war, the intelligence about the enemy is very important. Now, o ...
- 以管理身份运行cmd
搜索出cmd程序,然后右键-以管理员身份运行
- 【MongoDB】3.详细命令集合
[注意:MongoDB自动将_id字段设置为主键] -------------------------------------------------------------------------- ...
- 解决mysql shell执行中文表名报command not found错误
mysql -h 192.168.22.201 -uusername -ppassword --default-character-set=utf8 rom3 -e "DELETE FROM ...
- BurpSuite抓App数据包的方法
软件准备: 1.猎豹wifi 2.BurpSuite或者fillder都可以 查看电脑IP地址: 网卡ip: 确保无线网卡的IP和手机的代理IP保持一致即可
- Laravel错误与日志处理
App\Exceptions\Handler class is where all exceptions triggered by your application are logged and th ...
- CentOS VMware 配置IP小结 静态 配置 桥接 NAT
系统启动后可先ping下外网或局域网内其它机器. 如果配置虚拟机时选择的NAT上网方式,后面需要配置固定IP,请先参见VMware NAT方式下设置静态IP获得可用的IP范围和网关等信息. 先将ifc ...
- Angular跨域
Angular 跨域很简单,记住格式就好,有一些细节的东西需要跟后台商量的 比如地址栏的callback前面是&还是?跨域的原理请参考<jsonp跨域> Angular 跨域代码 ...
- java,我准备好了
1.你对自己的未来有什么规划?做了哪些准备? 长期上学好公务员和本专业知识,将来能找一份好工作,并能在职务上履行好相称的工作.短期上在下一学期拿一等奖学金,尽快入党,考出英语四级和二级c语言.任何成就 ...
- Node.js -- Router模块中有一个param方法
这段时间一直有在看Express框架的API,最近刚看到Router,以下是我认为需要注意的地方: Router模块中有一个param方法,刚开始看得有点模糊,官网大概是这么描述的: 1 Map lo ...