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

[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. 【原创】5. MYSQL++ mysql_type_info类型

    该类型是SQLBuffer的灵魂,它用来表示从SQL TYPE到C++ TYPE的相互转变.该类型被定义在type_info.h中.在这个头文件中,其实定义了三个类型,其中前两个都是在mysql_ty ...

  2. dataTable写入数据库(大数据写入)

    例1: connectionStr,链接字符串dataTableName, 数据库中对应表名sourceDataTable DataTable 要写入数据库的DataTable字段要和表一致 publ ...

  3. wdcp挂载数据盘为WWW以及之后出现的各种问题解决方法

    昨天晚上突然有客户反映服务器访问不了,经检查后是因为磁盘满了! 购买阿里云的ECS选择linux系统的时候会赠送20G的系统盘,通常来讲自己用的话基本够了,但是我们作为网络公司,安装了一个WDCP后给 ...

  4. IFC文件解析

    什么是IFC? EXPRESS语言与IFC体系 一.IFC 1.IFC简介 IFC是一个数据交换标准, 用于不同系统交换和共享数据.当需要多个软件协同完成任务时, 不同系统之间就会出现数据交换和共享的 ...

  5. wamp安装两个,数据库丢了,怎么办

    wampserver3.*下载了好几天一直没有安装,今天发现必须安装,已升级自己的php版本,不过也饿可以自己手动配置PHP版本,既然有安装包就算了吧,当安装完后,发现忘记备份自己的数据库了,幸好之前 ...

  6. _AppStart.cshtml 和 _PageStart.cshtml的妙用

    Customizing Site-Wide Behavior for ASP.NET Web Pages (Razor) Sites By Tom FitzMacken|February 17, 20 ...

  7. ios PNG Crush error (PNG图片错误)

    我是这么解决的: I had the same problem. How to fix : Open up image with Preview -> File > Export > ...

  8. Haar-like feature和Haar wavelet

    Haar-like features are digital image features used in object recognition. They owe their name to the ...

  9. 关于hibernate的查询

    为什么建议hibernate查询全部字段 一般而言,要查询什么字段就查询什么字段,不要select * from表,但是在hibernate,我们其实可以不遵循这个规则,建议我们把所有属性都查询出来( ...

  10. c#字符相似度对比

    字符串相似度算法使用 Levenshtein Distance算法(中文翻译:编辑距离算法) 这算法是由俄国科学家Levenshtein提出的. 下面使用C#实现 public class Leven ...