Liunx 挂载磁盘
查看已经挂载的分区和文件系统类型
[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 挂载磁盘的更多相关文章
- RHEL5.8配置开机自动挂载磁盘
Linux环境中可以通过fstab来设置自动挂载磁盘或者共享存储,操作如下: fstab配置文件路径:/etc/fstab 每行代表一个存储位置. [root@appsrv01 ~]# cat /et ...
- liunx清理磁盘du -h --max-depth=1 /data/*
liunx清理磁盘du -h --max-depth=1 /data/*
- Linux根据UUID自动挂载磁盘分区
一般服务器都有多个硬盘分区,在重启后,这些分区的逻辑位置加载时可能会发生变动,如果使用传统的设备名称(例如:/dev/sda)方式挂载磁盘,就可能因为磁盘顺序变化而造成混乱. Linux环境中每个Bl ...
- Linux阿里云挂载磁盘,并开机自动挂载
Linux下磁盘挂载 公司新订购阿里云ECS,需要挂载当前的磁盘.暂时没有运维,自己动手挂载磁盘. 具体步骤如下: 1.查看是否已经分配 [root@iZ2ze1tefvghtbgkdur3xfZ / ...
- 如何在linux环境上挂载磁盘
1.1 fdisk -l 命令 查看可用的磁盘信息(如果没有显示可用的磁盘,可重启一下主机:reboot) 1.2 df –h 命令 可查看已挂的磁盘情况 1.3 pvs ...
- Azure CentOS挂载磁盘
查看新增挂载磁盘 ls -l /dev/sd*  sudo fdisk /dev/sdc 依次输入:n,p,1,w  3.格式化分区 sudo mkfs -t ext4 /dev/sdc1  4 ...
- Raid5之后安装系统,挂载磁盘
配置RAID5 略 2.U盘安装centos系统(我的版本是centos7.0) 这一步骤网上很多,可以参考这篇:http://jingyan.baidu.com/article/359911f571 ...
- linux 挂载磁盘
挂在磁盘操作(还有一个300G的盘没显示出来): [root@iZgo67bo9s3uaijzqrgbaxZ ori]# df -h Filesystem Size Used ...
- Window10 Linux子系统挂载磁盘
默认情况下, Linux子系统将当前winodws磁盘的盘全部挂载到/mnt/<disk_label>, 但一些新增的盘就需要手动做下了.. 官方参考文档 挂载磁盘 -- DrvFs 挂载 ...
随机推荐
- 客户端级别的渲染分析工具 dynaTrace
dynaTrace Ajax Edition是一款很好的javaScript性能分析工具.目前支持IE和Firefox 2款浏览器. dynaTrace如图所示: 点击Click here to st ...
- 8-python模拟登入(无验证码)
方式: 1.手动登入,获取cookie 2.使用cookielib库 和 HTTPCookieProcessor处理器 #_*_ coding: utf-8 _*_ ''' Created on 20 ...
- python3-递归
# Auther: Aaron Fan """递归特性:1. 必须有一个明确的结束条件2. 每次进入更深一层递归时,问题规模相比上次递归都应有所减少3. 递归效率不高,递 ...
- Django框架 之 logging配置
Django框架 之 logging配置 logging配置文件 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 2 ...
- IIS 身份验证
IIS 支持以下身份验证模式: 匿名.如果不需要对客户端进行身份验证(或者使用自定义身份验证机制,如窗体身份验证),则可将 IIS 配置为允许匿名访问.在该事件中,IIS 创建一个 Windows 令 ...
- HTTP Debugger Pro安装教程
相关链接:HTTP Debugger Pro使用教程 安装步骤: 1.解压压缩包 2.双击运行安装文件 3.根据向导提示点击Next 4.选择接受协议,点击Next 5.选择高级模 ...
- 编写高质量代码改善C#程序的157个建议——建议4: TryParse比Parse好
建议4: TryParse比Parse好 如果注意观察除string外的所有基元类型,会发现它们都有两个将字符串转型为本身的方法:Parse和TryParse.以类型double为例,这两个方法最简单 ...
- Boosting and Its Application in LTR
1 Boosting概述 2 Classification and Regression Tree 3 AdaBoost 3.1 算法框架 3.2 原理:Additive Modeling 4 Gra ...
- Java简单实现AOP,Java通用异常拦截,Java与Lamada
直接看代码不废话.不懂Lamada直接百度... package test; /** * QQ:1448376744 * @author 花间岛 * */ //控制器 public class Con ...
- WinForm中自定义搜索框(水印、清空按钮、加载中图标)
public partial class CustomSearchBar : TextBox { private readonly Label lblwaterText = new Label(); ...