一、linux磁盘管理

  1. 命令:fdisk -l
  2. brwx-rw--- 其中b(占位符)代表block,块设备文件
  3. sda,sdb... --> 硬盘 其中sda1,sda2..sdb1,sdb2...-->硬盘分区 (s:硬盘接口;d:disk)
    • 了解硬盘接口:stata,sas --> 服务器借口
    •          scsi,ide   --> 个人电脑接口
    • fdisk -l 后有个  cylinder     : 磁柱
      • 起始与结束
      • 查看硬盘是否分区
  4. 虚拟机添加新硬盘(单个文件),重新启动,分区
    1. 概念:主分区(格式化后直接使用),扩展分区(格式化后还要进行逻辑分区才能使用),逻辑分区(与主分区类似,但非系统分区)
    2. 利用fdisk /dev/sdb来对sdb(新加的硬盘)进行分区
    3. 分区步骤:分一个10G的主分区,剩下的为扩展分区,再从扩展分区中分出两块逻辑分区,结构为2+1
    4. 分区保存后,重启使分区文件加载生效
    5. 格式化:mkfs.文件系统(ext1,ext2,ext3,ext4,centos 7 使用的文件系统xfs) 例:mkfs.ext4 /dev/sdb6
    6. 格式化完毕,还需要挂载磁盘(mount临时的,用法mount /dev/sdb6 /mnt/(一般挂载点)),才能使用
    7. 若要永久挂载,需要写入配置文件/etc/fstab
    8. 取消挂载 umount /mnt/
    9. 查看挂载信息,容量等信息(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_磁盘管理的更多相关文章

  1. liunx 磁盘管理命令记录

    Linux磁盘管理好坏管理直接关系到整个系统的性能问题. Linux磁盘管理常用三个命令为df.du和fdisk. df:列出文件系统的整体磁盘使用量 du:检查磁盘空间使用量 fdisk:用于磁盘分 ...

  2. Windows Server 2012 磁盘管理之 简单卷、跨区卷、带区卷、镜像卷和RAID-5卷

    今天给客户配置故障转移群集,在Windows Server 2012 R2的系统上,通过iSCSI连接上DELL的SAN存储后,在磁盘管理里面发现可以新建 简单卷.跨区卷.带区卷.镜像卷.RAID-5 ...

  3. Linux常用命令学习7---(磁盘管理df du、磁盘的分区和格式化fdisk parted)

    1.磁盘管理    在服务器的维护中,我们需要关心服务器的磁盘使用了多少.还有多少的剩余空间.某个文件有多大.某个文件夹内的所有文件在一起一共占用的多少空间……问题.以便我们在合适的时机为服务器添加硬 ...

  4. LINUX的磁盘管理du命令详解

    LINUX的磁盘管理du命令详解 du(disk usage)命令可以计算文件或目录所占的磁盘空间.没有指定任何选项时, 它会测量当前工作目录与其所有子目录,分别显示各个目录所占的快数,最后才显示工作 ...

  5. 用Win7自带的磁盘管理工具给硬盘分区

    最近新买了一台笔记本,要给硬盘分几个区,心想还是用个工具方便点,于是就上网准备下个“硬盘分区魔术师”,但是看到有一篇文章介绍Win7系统也自带了硬盘分区工具,这我以前倒没听说过,试了一下,还挺方便好用 ...

  6. Linux 磁盘管理

    Linux磁盘管理好坏管理直接关系到整个系统的性能问题. Linux磁盘管理常用三个命令为df.du和fdisk. df:列出文件系统的整体磁盘使用量 du:检查磁盘空间使用量 fdisk:用于磁盘分 ...

  7. Linux_06------Linux的磁盘管理

    进制编码 * 3.格式化交换分区 * 4.启用交换分区 * * 1.2. * fdisk /dev/sdb * p * t * 6(分区编号) * L(查看编码列表),找到SWAP交换分区标号 * 8 ...

  8. Linux 系统常用命令汇总(五) 磁盘管理

    磁盘管理 命令 选项 注解 示例 df [选项] 显示磁盘空间使用情况 显示磁盘空间是员工情况,以M显示:    df -m -i 使用inodes显示结果 -k(m) 使用KB(MB)显示结果 du ...

  9. Linux命令工具基础04 磁盘管理

    Linux命令工具基础04 磁盘管理 日程磁盘管理中,我们最常用的有查看当前磁盘使用情况,查看当前目录所占大小,以及打包压缩与解压缩: 查看磁盘空间 查看磁盘空间利用大小 df -h -h: huma ...

随机推荐

  1. 设定自动获得DNS服务器地址

    情况说明:操作系统是Win7 64位, 网络是有线 1 2 3 4 5

  2. Reading and Writing CSV Files in C#

    Introduction A common requirement is to have applications share data with other programs. Although t ...

  3. 汇编学习(三)——汇编语言程序入门

    一.寻址方式 1.概念: 一条指令由操作码和操作数构成,操作码是系统定义好的符号,执行指定的操作,操作数即是指令的对象,而寻址方式就是操作数的指定方式 操作码 目的操作数,源操作数 2.寻址方式的三种 ...

  4. 偷师--先留着。。ssh,nginx,防火墙相关命令

  5. LoadRunner 脚本学习 -- 读取文件内容

    随便创建个txt文档  输入点内容,例如 读取文件内前N个字符: Action() { long myfile; ; ]; char *filename = "E:\\kkk.txt&quo ...

  6. 【转】Kylin中的cube构建

    http://blog.csdn.net/yu616568/article/details/50365240 前言   在使用Kylin的时候,最重要的一步就是创建cube的模型定义,即指定度量和维度 ...

  7. 关于main函数传参数的问题

    argc是命令行总的参数个数      argv[]是argc个参数,其中第0个参数是程序的全名,以后的参数      命令行后面跟的用户输入的参数,比如:      int   main(int   ...

  8. Swift3.0语言教程获取C字符串

    Swift3.0语言教程获取C字符串 Swift3.0语言教程获取C字符串,为了让Swift和C语言可以实现很好的交互,开发者可以使用NSString的cString(using:)方法在指定编码格式 ...

  9. Visual Studio工具栏中无法选择调试设备

    Visual Studio工具栏中无法选择调试设备 在Visual Studio工具栏中,默认显示已经识别的设备.用户可以从中选择对应的设备,进行调试和部署App.但是由于误操作,可能导致该选项丢失. ...

  10. 一个简单的dos脚本, svn 获取代码 - Tomcat 备份 - Maven 编译 - 停止/启动Tomcat - Tomcat站点 发布

    获取最新代码 svn update --username %SVN_USER% --password %SVN_PASSWORD% >> "../%LOG_FILE%" ...