查看已经挂载的分区和文件系统类型

[root@VM_101_18212122_centos /]# df -T
Filesystem Type 1K-blocks Used Available Use% Mounted on
/dev/vda1 ext3 % /

fdisk -l 可以显示出所有挂载和未挂载的分区,但不显示文件系统类型

[root@VM_101_18212122_centos /]# fdisk -l // 查看磁盘

Disk /dev/vda: 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: 0x00072b28 Device Boot Start End Blocks Id System //设备启动端块ID系统
/dev/vda1 * Linux Disk /dev/vdb: 107.4 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

fdisk 命令进行建立分区

磁盘分区分为:主分区、扩展分区、逻辑分区;主分区至少有1个,最多4个;扩展分区可以没有,最多1个

主分区+扩展分区 最多不得超过4个,如果需要多个分区可以先建立扩展分区,在扩展分区中划分多个逻辑分区

执行分区步骤可以根据 :fdisk 命令   Linux下磁盘挂载  这2篇博客文章操作

自定义当前第几块分区注意:Partition number(1-4) :number  这个数字是指在当前这块硬盘上第几个分区

[root@VM_101_18212122_centos ~]# fdisk /dev/vdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0xf3de3926.
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 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): 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 ): +50G Command (m for help): p Disk /dev/vdb: 107.4 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: 0xf3de3926 Device Boot Start End Blocks Id System
/dev/vdb1 + Linux Command (m for help): n
Command action
e extended
p primary partition (-)
e
Partition number (-): // 这里必须至少从2 开始
Partition is already defined. Delete it before re-adding it. 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): p Disk /dev/vdb: 107.4 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: 0xf3de3926 Device Boot Start End Blocks Id System
/dev/vdb1 + Linux
/dev/vdb2 Extended Command (m for help): p // 打印磁盘情况 Disk /dev/vdb: 107.4 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: 0xf2295fd0 Device Boot Start End Blocks Id System
/dev/vdb1 + Linux
/dev/vdb2 Linux Command (m for help): w // 保存
The partition table has been altered! Calling ioctl() to re-read partition table.
Syncing disks.
[root@VM_101_182121222_centos ~]# fdisk -l Disk /dev/vda: 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: 0x00072b28 Device Boot Start End Blocks Id System
/dev/vda1 * Linux Disk /dev/vdb: 107.4 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: 0xf2295fd0 Device Boot Start End Blocks Id System
/dev/vdb1 + Linux
/dev/vdb2 Linux

如果第一个分区划分为主分区,第二个分区划分为扩展分区,这个地方就至少填 2,如果填写1,会提示 Partition 1 is already defined. Delete it before re-adding it.

lsblk -f 也可以查看未挂载的文件系统类型

[root@VM_101_18212122_centos /]# lsblk -f
NAME FSTYPE LABEL UUID MOUNTPOINT
vda
`-vda1 ext3 dddcd0d3-764f--93f6-2037ab1294f7 / // 已挂载
vdb ext3 0f1a7f8b-cbea-47e8-b19a-84e28c57ad2a   // 未分区挂载

parted -l 可以查看未挂载的文件系统类型,以及哪些分区尚未格式化

[root@VM_101_18212122_centos ~]# parted -l
Model: Virtio Block Device (virtblk)
Disk /dev/vda: 21.5GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos Number Start End Size Type File system Flags
1 1049kB 21.5GB 21.5GB primary ext3 boot Model: Virtio Block Device (virtblk)
Disk /dev/vdb: 107GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos Number Start End Size Type File system Flags
1 32.3kB 53.7GB 53.7GB primary
2 53.7GB 107GB 53.7GB primary

格式化分区   mkfs.文件系统格式   分区名

[root@VM_101_182121222_centos ~]# mkfs.ext3 /dev/vdb2  // 执行格式化命令
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@VM_101_18212122_centos ~]# lsblk -f // 查看磁盘情况
NAME FSTYPE LABEL UUID MOUNTPOINT
vda
`-vda1 ext3 dddcd0d3-764f--93f6-2037ab1294f7 /
vdb ext3 0f1a7f8b-cbea-47e8-b19a-84e28c57ad2a
|-vdb1
`-vdb2 ext3 c064d156-6d83--a20e-ef15e4d084f3

注意:格式化前看一下文件系统类型

格式化分区注意: 不是格式化的硬盘,直接格式化扩展分区是不允许的,只能格式化主分区和逻辑分区

挂载磁盘

[root@VM_101_18212122_centos /]# mount /dev/vdb2 /data  //挂载目录, 有的系统需要通知系统内核分区表的变化,不然内核不知道分区(或重启系统)执行 partprobe 命令
[root@VM_101_182_centos /]# df -TH /data //查看是否挂载成功
Filesystem Type Size Used Avail Use% Mounted on
/dev/vdb2 ext3 53G 189M 50G % /data
[root@VM_101_1821_centos /]# echo '/dev/vdb2 /data ext3 defaults 0 0' >> /etc/fstab // 添加数据盘挂载信息至/etc/fstab,实现开机自动挂载
[root@VM_101_182_centos /]# cat /etc/fstab //查看写入
/dev/vda1 / ext3 noatime,acl,user_xattr
proc /proc proc defaults
sysfs /sys sysfs noauto
debugfs /sys/kernel/debug debugfs noauto
devpts /dev/pts devpts mode=,gid=
/dev/vdb2 /data ext3 defaults

卸载挂载点

[root@VM_101_18212122_centos /]# umount /dev/vdb2  // 通过设备卸载 或者 通挂载点卸载 umount /data
[root@VM_101_18212122_centos /]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/vda1 20G 13G .9G % /

注意:如果设备正忙,卸载即告失败。原因一般是你当前在挂载点的某个目录中;也可以用lsof列出已打开文件,然后搜索列表查找待卸载的挂载点:lsof | grep data  查找 data 分区里打开的文件

删除分区

[root@VM_101_18212122_centos /]# fdisk /dev/vdb

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): d
Partition number (-): 1 // 删除第一个分区 Command (m for help): d
Selected partition 2 // 我这个磁盘一共分了2个区,执行2次 d 就是选择2个分区 Command (m for help): w // 保存退出

记得修改 vim /etc/fstab  文件

Liunx 挂载磁盘的更多相关文章

  1. RHEL5.8配置开机自动挂载磁盘

    Linux环境中可以通过fstab来设置自动挂载磁盘或者共享存储,操作如下: fstab配置文件路径:/etc/fstab 每行代表一个存储位置. [root@appsrv01 ~]# cat /et ...

  2. liunx清理磁盘du -h --max-depth=1 /data/*

    liunx清理磁盘du -h --max-depth=1 /data/*

  3. Linux根据UUID自动挂载磁盘分区

    一般服务器都有多个硬盘分区,在重启后,这些分区的逻辑位置加载时可能会发生变动,如果使用传统的设备名称(例如:/dev/sda)方式挂载磁盘,就可能因为磁盘顺序变化而造成混乱. Linux环境中每个Bl ...

  4. Linux阿里云挂载磁盘,并开机自动挂载

    Linux下磁盘挂载 公司新订购阿里云ECS,需要挂载当前的磁盘.暂时没有运维,自己动手挂载磁盘. 具体步骤如下: 1.查看是否已经分配 [root@iZ2ze1tefvghtbgkdur3xfZ / ...

  5. 如何在linux环境上挂载磁盘

    1.1      fdisk -l 命令 查看可用的磁盘信息(如果没有显示可用的磁盘,可重启一下主机:reboot) 1.2      df –h 命令 可查看已挂的磁盘情况 1.3      pvs ...

  6. Azure CentOS挂载磁盘

    查看新增挂载磁盘 ls -l /dev/sd*  sudo fdisk /dev/sdc 依次输入:n,p,1,w  3.格式化分区 sudo mkfs -t ext4 /dev/sdc1  4 ...

  7. Raid5之后安装系统,挂载磁盘

    配置RAID5 略 2.U盘安装centos系统(我的版本是centos7.0) 这一步骤网上很多,可以参考这篇:http://jingyan.baidu.com/article/359911f571 ...

  8. linux 挂载磁盘

    挂在磁盘操作(还有一个300G的盘没显示出来): [root@iZgo67bo9s3uaijzqrgbaxZ ori]# df -h  Filesystem            Size  Used ...

  9. Window10 Linux子系统挂载磁盘

    默认情况下, Linux子系统将当前winodws磁盘的盘全部挂载到/mnt/<disk_label>, 但一些新增的盘就需要手动做下了.. 官方参考文档 挂载磁盘 -- DrvFs 挂载 ...

随机推荐

  1. Python中__new__与__init__介绍

    在python2.x中,从object继承得来的类称为新式类(如class A(object))不从object继承得来的类称为经典类(如class A()) 新式类跟经典类的差别主要是以下几点: 1 ...

  2. SpringBoot23 分模块开发

    1 开发环境说明 JDK:1.8 MAVEN:3.5 IDEA:2017.2.5 SpringBoot:2.0.3.RELEASE 2 创建SpringBoot项目 2.1 项目信息 2.2 添加项目 ...

  3. keepalived+lvs高可用配置

    global_defs { notification_email { test@qq.com } notification_email_from sns-lvs@gmail.com smtp_serv ...

  4. Entity Framework 6.0 Tutorials(9):Stored Procedure Mapping

    Code First - Insert, Update, Delete Stored Procedure Mapping: Entity Framework 6 Code-First provides ...

  5. hadoop2.2分布式环境搭建

    hadoop2.2的分布式环境需要配置的参数更多.但是需要安装的系统软件和单节点环境是一样的. 运行hadoop在非安全环境 hadoop的配置文件有两类: 1:只读的默认配置文件: core-def ...

  6. 策略与计费控制规则(Policy and Charging Control Rule-PCC Rule)解析及模板样例

    内容 PCC规则定义 PCC规则运行 PCC规则模板 PCC规则定义 参考文档: 3gpp ts 23.203-be0 条款6.3 策略与计费控制规则(PCC Rule),即一系列相关信息与一系列相关 ...

  7. Tomcat与Web.xml配置

    1.编码配置 <Connector acceptCount=”100″ connectionTimeout=”20000″ disableUploadTimeout=”true” enableL ...

  8. 类的 where T : class 泛型类型约束

    where T : struct | T必须是一个结构类型where T : class T必须是一个类(class)类型where T : new() | T必须要有一个无参构造函数where T ...

  9. EasyUI控件combobox重复请求后台,dialog窗口数据异常

    最近在用Easy UI+Dapper+MVC4 开发一个财务收款系统,其中就发现一些小问题,供有需要的人参考. 1.EasyUI控件combobox 数据绑定 出现重复请求后台 上代码: <td ...

  10. C#操作excel打印

    using System; using System.Data; using System.IO; using System.Runtime.InteropServices; using System ...