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 挂载 ...
随机推荐
- 【原创】7. MYSQL++中的查询结果获取(各种Result类型)
在本节中,我将首先介绍MYSQL++中的查询的几个简单例子用法,然后看一下mysqlpp::Query中的几个与查询相关的方法原型(重点关注返回值),最后对几个关键类型进行解释. 1. MYSQL++ ...
- codeforce453DIV2——D. GCD of Polynomials
题意 给出n(1–150). 输出两个多项式A,B从常数到最高次的系数,使得对两个多项式求gcd时,恰好经过n步得到结果. 多项式的gcd一步是指(A(x),B(x))变成(B,A mod B)的过程 ...
- 【bzoj3942】[Usaco2015 Feb]Censoring
[题目大意] 有一个S串和一个T串,长度均小于1,000,000,设当前串为U串,然后从前往后枚举S串一个字符一个字符往U串里添加,若U串后缀为T,则去掉这个后缀继续流程. [样例输入] whatth ...
- Nginx 下配置Laravel 错误404
宝塔的访问路径改一下 在站点的配置文件下面server里面加上 location / { try_files $uri $uri/ /index.php?$query_string; } 然后重启Ng ...
- Linux 程序和进程的关系
查看进程命令 ps ps -elf|grep init|grep -v grep 查看init进程ID号:ps aux |grep init |grep -v grep; ps aux 会把系统所有 ...
- jmap, jhat命令
jmap命令有下面几种常用的用法 jmap [pid] jmap -histo:live [pid] >a.log jmap -dump:live,format=b,file=xxx.xxx [ ...
- CMD指令大全
命令提示符(CMD)是在OS / 2 , Windows CE与Windows NT平台为基础的操作系统(包括Windows 2000和XP中, Vista中,和Server 2003 )下的“MS- ...
- 【转载】Python BeautifulSoup匹配字符串
作者:鸡仔说链接:https://www.jianshu.com/p/ceb99aed4b2e來源:简书 BeautifulSoup中可以通过name和attrs去定位名称和属性,以找到特定的html ...
- k阶原点距和k阶中心距各是说明什么数字特征
k阶原点距和k阶中心距各是说明什么数字特征 二阶中心距,也叫作方差,它告诉我们一个随机变量在它均值附近波动的大小,方差越大,波动性越大.方差也相当于机械运动中以重心为转轴的转动惯量.(The mome ...
- Django--form基础
一.Django--form功能 用户提交数据验证 生成html标签 二.基础实例 需求 利用Django的form功能,接收用户注册信息. urls.py 1 2 3 4 5 from app01 ...