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

[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. 张超超OC基础回顾03_结构体类型作为成员变量的特殊用法

    直接上例子: 要求: 合理的设计一个”学生“类 学生有* 姓名* 生日两个属性和说出自己姓名生日方法  要求利用设计的学生类创建学生对象,并说出自己的姓名和年龄 描述学生类 事物名称: 学生(Stud ...

  2. Python中__new__与__init__介绍

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

  3. 代理模式 静态代理、JDK动态代理、Cglib动态代理

    1 代理模式 使用代理模式时必须让代理类和被代理类实现相同的接口: 客户端通过代理类对象来调用被代理对象方法时,代理类对象会将所有方法的调用分派到被代理对象上进行反射执行: 在分派的过程中还可以添加前 ...

  4. solr开发之基本操作

    package zr.com.util; import java.io.IOException; import java.util.List; import java.util.Map; import ...

  5. Java设计模式(1)——简单工厂模式

    简单工厂模式属于类的创建型模式,又叫做静态工厂方法模式.通过专门定义一个类来负责创建其他类的实例,被创建的实例通常都具有共同的父类. 一.模式中包含的角色及其职责 1.工厂(Creator)角色 简单 ...

  6. html页面源代码

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  7. Reportng 的测试报告在 Jenkins 中显示不全

    通过Jenkins执行接口测试生成测试报告,用Jenkins的web服务打开html显示不全. 环境: Jenkins版本:1.651.2 Jenkins发布在mac上面 使用的是testng管理测试 ...

  8. HttpUploader7-授权码配置

    1.1. 七牛云存储 配置方式: 1.配置授权码   2.配置云存储   3.配置空间名称   4.配置上传地址   1.2. 阿里云存储 配置方式: 1.填写授权码   2.配置云存储为阿里云   ...

  9. javaweb分页

    package com.aishang.util; //分页 public class Pagemethod { public static int[] getPageArray(int selInd ...

  10. HackFifteen 移除背景以提升Activity启动速度

    1.概要:     移除窗口默认背景是提升应用程序启动速度的一个简单技巧.判断是否需要移除背景的原则很简单:如果应用程序界面需要 占据窗口100%的控件,就需要将windowBackground属性设 ...