由于工作的需要,最近一段时间一直在学习Linux。学习一门新的知识,我是喜欢根据谋一本书或者某一个学习视频系统的学习,这样可以对学习的新知识有一个系统全面的认识和了解。所以学习之前,没了一本鸟哥的私房菜做为参考书,开始系统的学习Linux。

根据鸟哥的建议,安装虚拟机时,预留了一块空的容量用来练习分区使用。所以在虚拟机上安装Linux系统分区时,只划分了一块4G的容量挂载到根目录“/”下,还有就是只划分了一个2G的swap分区。还有14G的容量没有分配。

在学习磁盘管理时,使用fdisk将剩余的容量继续分区。却发现新建完分区后,无法通过partprobe重载分区。

具体操作如下所示:

1、使用fdisk新建分区

(。。。。)分区操作记录没有保存下来,执行w后,出现下列信息

Disk /dev/sda: 21.5 GB, 21474836480 bytes

255 heads, 63 sectors/track, 2610 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x000b604c Device Boot Start End Blocks Id System

/dev/sda1 * 1 523 4194304 83 Linux

Partition 1 does not end on cylinder boundary.

/dev/sda2 523 784 2097152 82 Linux swap / Solaris

Partition 2 does not end on cylinder boundary.

/dev/sda3 784 2610 14672345 5 Extended

/dev/sda5 784 1421 5121671 83 LinuxCommand (m for help): w

The partition table has been altered!Calling ioctl() to re-read partition table.WARNING: Re-reading the partition table failed with error 16: 设备或资源忙.

The kernel still uses the old table. The new table will be used at

the next reboot or after you run partprobe(8) or kpartx(8)

Syncing disks.

保存新建分区,提示“设备或资源忙”,当时就在/dev/sda硬盘上做的操作,以为该提示为正常现象,所以忽略了,继续下一步操作。

2、通过partprobe重载分区表,避免重启系统

[root@stduy /]# partprobe

Warning: WARNING: the kernel failed to re-read the partition table on /dev/sda (设备或资源忙). As a result, it may not reflect all of your changes until after reboot.

Warning: 无法以读写方式打开 /dev/sr0 (只读文件系统)。/dev/sr0 已按照只读方式打开。

Warning: 无法以读写方式打开 /dev/sr0 (只读文件系统)。/dev/sr0 已按照只读方式打开。

Error: 无效的分区表 - /dev/sr0 出现递归分区。

重载分区出现的上述信息中,当时对于警告提示“设备或资源忙,需要重启系统才能使更改生效”直接忽略,以为是正常现象。但是对于错误信息“Error: 无效的分区表 - /dev/sr0 出现递归分区。”就有点茫然了,不过,既然提示“无效的分区表”,那我查下分区信息。

3、使用fdisk -l 命令查看分区信息

[root@stduy /]# fdisk -l

Disk /dev/sda: 21.5 GB, 21474836480 bytes

255 heads, 63 sectors/track, 2610 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x000b604c Device Boot Start End Blocks Id System

/dev/sda1 * 1 523 4194304 83 Linux

Partition 1 does not end on cylinder boundary.

/dev/sda2 523 784 2097152 82 Linux swap / Solaris

Partition 2 does not end on cylinder boundary.

/dev/sda3 784 2610 14672345 5 Extended

/dev/sda5 784 1421 5121671 83 Linux

查看分区信息,正常啊,并且刚才新建的扩展分区/dev/sda3和逻辑分区/dev/sda5都在。于是直接对新建的分区/dev/sda5进行格式化。

4、格式化新建的逻辑分区/dev/sda5

[root@stduy /]# mkfs -t ext3 /dev/sda5

mke2fs 1.41.12 (17-May-2010)

无法对 /dev/sda5 进行 stat 调用 --- 没有那个文件或目录

The device apparently does not exist; did you specify it correctly?

格式化时,提示“没有那个文件或目录”。这就奇怪了,操作是根据参考书上一步一步来的,怎么就不行了呢?于是百度Linux下新建分区的一些信息,希望可以的找到类似的错误,借鉴解决办法。找了一圈下来,倒是有个类似的错误,但是没有给出解决办法。

重新分析新建分区并重载分区表的过程,对于“设备或资源忙”的提示,因为当时就是在/dev/sda这块硬盘上操作的,提示“设备或资源忙”应该是正常的,重启下应该就可以了。但是重启后,还是找不到/dev/sda5,但是fdisk -l 查看是有的。于是怀疑是不是重载分区表时的“Error: 无效的分区表 - /dev/sr0 出现递归分区。”错误信息导致的呢?

查看了下/dev下的sr0

[root@stduy dev]# ls -lh | grep sr0

lrwxrwxrwx. 1 root root           3 8月   5 00:12 cdrom -> sr0

lrwxrwxrwx. 1 root root           3 8月   5 00:12 cdrw -> sr0

lrwxrwxrwx. 1 root root           3 8月   5 00:12 dvd -> sr0

lrwxrwxrwx. 1 root root           3 8月   5 00:12 dvdrw -> sr0

lrwxrwxrwx. 1 root root           3 8月   5 00:12 scd0 -> sr0

brw-rw----. 1 root cdrom    11,   0 8月   5 00:12 sr0

从上面的结果看,sr0是光驱设备,百度了下/dev/sr0这个设备,也所是光驱。于是管它重载分区表失败是不是由于“Error: 无效的分区表 - /dev/sr0 出现递归分区。”引起的,先把光驱移除了再说,反正是虚拟机上。

把虚拟机上的光驱设备移除后,重新启动系统,再重新新建分区,并重新执行partprobe命令重载分区表,错误信息“Error: 无效的分区表 - /dev/sr0 出现递归分区。”没有了,只是警告提示“设备或资源忙”还在。这时直接格式化新建的逻辑分区/dev/sda5还是提示“没有那个文件或目录”。于是重启系统,再格式化/dev/sda5,这回成功了。

也就是,之前新建分区格式化失败,是由于虚拟机的光驱/dev/sr0设备导致了分区表递归。另外由于是在同一块硬盘上操作,所以必须要重启系统才能使新建的分区写入分区表生效。

那鸟哥的私房菜中,说的预留一块容量用于分区练习,鸟哥是怎么成功的呢?

于是又找了一些Linux磁盘管理相关的视频和资料,发现,他们使用fdisk新建分区都是使用的多块硬盘实现的。再重新回去看鸟哥的私房菜,发现鸟哥预留的硬盘是/dev/hdc,那么鸟哥的环境中肯定还有/dev/hda和/dev/hdb,那么鸟哥试验也是在多快硬盘的基础上完成的。

那我再给虚拟机分配一块硬盘试试。于是关闭系统,在虚拟机上又给系统分配了一块5G的虚拟磁盘空间。再开机进入系统重新对新加的磁盘空间进行分区、格式化等操作。

步骤还是和上面一样,分区、重载分区表、查看分区、格式化,这里不再按步骤,直接给出完成的操作记录。

[root@stduy ~]# fdisk -l

Disk /dev/sda: 21.5 GB, 21474836480 bytes

255 heads, 63 sectors/track, 2610 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x000b604c

Device Boot Start End Blocks Id System

/dev/sda1 * 1 523 4194304 83 Linux

Partition 1 does not end on cylinder boundary.

/dev/sda2 523 784 2097152 82 Linux swap / Solaris

Partition 2 does not end on cylinder boundary.

/dev/sda3 784 2610 14672345 5 Extended

/dev/sda5 784 2610 14672313+ 83 Linux

Disk /dev/sdb: 5368 MB, 5368709120 bytes

255 heads, 63 sectors/track, 652 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x00000000

[root@stduy ~]# fdisk /dev/sdb

Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel

Building a new DOS disklabel with disk identifier 0x851e79cc.

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 4 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): p

Disk /dev/sdb: 5368 MB, 5368709120 bytes

255 heads, 63 sectors/track, 652 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x851e79cc

Device Boot Start End Blocks Id System

Command (m for help): n

Command action

e extended

p primary partition (1-4)

p

Partition number (1-4): 1

First cylinder (1-652, default 1):

Using default value 1

Last cylinder, +cylinders or +size{K,M,G} (1-652, default 652):

Using default value 652

Command (m for help): p

Disk /dev/sdb: 5368 MB, 5368709120 bytes

255 heads, 63 sectors/track, 652 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x851e79cc

Device Boot Start End Blocks Id System

/dev/sdb1 1 652 5237158+ 83 Linux

Command (m for help): w

The partition table has been altered!

Calling ioctl() to re-read partition table.

Syncing disks.

[root@stduy ~]# partprobe /dev/sdb

[root@stduy ~]# mkfs -t ext4 /dev/sdb1

mke2fs 1.41.12 (17-May-2010)

文件系统标签=操作系统:Linux块大小=4096 (log=2)分块大小=4096 (log=2)Stride=0 blocks, Stripe width=0 blocks327680 inodes, 1309289 blocks65464 blocks (5.00%) reserved for the super user

第一个数据块=0Maximum filesystem blocks=134217728040 block groups32768 blocks per group, 32768 fragments per group8192 inodes per groupSuperblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736

正在写入inode表: 完成

Creating journal (32768 blocks): 完成

Writing superblocks and filesystem accounting information: 完成

This filesystem will be automatically checked every 36 mounts or180 days, whichever comes first.

Use tune2fs -c or -i to override.

这回不管是新建分区,还是重载分区表都没有警告或错误提示了。成功实现在不重启系统的情况下添加硬盘并对新增硬盘进行分区、格式化等操作。

partprobe使用方法_Linux下使用fdisk命令和partprobe命令 在不重启系统的情况下新建分区并格式化...相关推荐

  1. linux格式化时设备或资源忙,Linux下用fdisk命令和partprobe命令不重启系统新建分区并格式化...

    由于工作的需要,最近一段时间一直在学习Linux.学习一门新的知识,我是喜欢根据谋一本书或者某一个学习视频系统的学习,这样可以对学习的新知识有一个系统全面的认识和了解.所以学习之前,买了一本鸟哥的私房 ...

  2. 【Nacos】生产上需要不重启服务的情况下刷新配置,这个方法可以试试

    [Nacos]生产上需要不重启服务的情况下刷新配置,这个方法可以试试 配置 Demo搭建 RefreshScope 原理 假设Nacos服务已经搭建完成 配置 新建service-config配置文件 ...

  3. 不重启容器的情况下添加或者删除端口

    通常对已经启动的容器添加端口需要先停止容器,然后修改启动脚本,再重新restart. 但是有一种方法可以利用iptable在不重启容器的情况下,增加端口. 查看容器的IP iptables -t na ...

  4. vmware linux添加新磁盘后刷新--重新扫描 SCSI 总线,在不重启虚拟机的情况下添加 SCSI 设备

    [root@centos4 scsi_host]# ls host0  host1  host2 有几个host就刷几次 [root@centos4 scsi_host]# echo "- ...

  5. 秒杀系统并发情况下解决超卖问题

    非分布式秒杀系统 并发情况下解决超卖问题 乐观锁防止超卖 / 令牌桶限流/ redis缓存 /接口限流/接口加盐/单用户限制访问频率/消息队列异步处理订单 #数据库表drop table if exi ...

  6. react-native实现不重启App的情况下更新分包

    目录 前言 需求 理论基石 脚本 打包配置文件 问题 参考链接 前言 本文是基于RN的拆包机制,建议优先研究明白react-native-multibundler,下面介绍下react_native_ ...

  7. linux格式化时设备或资源忙,Linux下使用fdisk命令和partprobe命令,在不重启系统的状况下新建分区并格式化...

    因为工做的须要,最近一段时间一直在学习Linux.学习一门新的知识,我是喜欢根据谋一本书或者某一个学习视频系统的学习,这样能够对学习的新知识有一个系统全面的认识和了解.因此学习以前,没了一本鸟哥的私房 ...

  8. 组装机装系统,在另一个电脑只有ubuntu系统的情况下用ventoy制作Windows启动盘并且成功安装,后续如何安装win+ubuntu双系统(安装ubuntu后可能出现的wifi不能用的解决方法)

    第一步 下载ventoy 1.下载linux版本的ventoy 2.安装Windows镜像,自己找 3.下载得到的是压缩包ventoy-1.0.76-linux.tar.gz 下载得到的压缩包所在的位 ...

  9. wincc服务器系统,什么情况下用wincc服务器与客户端

    什么情况下用wincc服务器与客户端 内容精选 换一换 当创建文件系统后,您需要使用云服务器来挂载该文件系统,以实现多个云服务器共享使用文件系统的目的.CIFS类型的文件系统不支持使用Linux操作系 ...

最新文章

  1. php实现人工神经网络算法,BP人工神经网络实现
  2. 多径传播matlab仿真·信号分析处理
  3. 一个程序员的水平能差到什么程度?
  4. CSDN之人人code,整数取反
  5. php include的路径问题,php7中include有相对路径无法打开
  6. 重设域控还原模式密码
  7. 简述开发Android2D图形,2D图形开发(一)(高级).pdf
  8. Week2-09-Rabbit 类数组实现具体方法
  9. Helm — Chart介绍
  10. **time_limited.sof文件
  11. 回眸 2020,展望 2021
  12. nodejs之简单的爬数据
  13. Redis - increment 递增方法 | 处理防重复和并发问题
  14. 华为又走在美国芯片企业前面,将率先发布5nm工艺芯片
  15. Outlook邮件创建的规则失效,可能的原因
  16. Java语言实现杨辉三角
  17. 【设计模式】模板模式实现报表模板
  18. AVB源码学习(七):AVB2.0-Super动态分区介绍
  19. 一个3D视频播放器的演示APK
  20. 该如何使用MySQL的存储过程?

热门文章

  1. .net coer IQueryable类型的执行逻辑(延迟执行),认真看,你会有收获的。
  2. 大周建议新手看完收藏,修改昵称会影响推荐量?都是避坑点
  3. GreenDao的使用以及断点续传
  4. Vue——组合式函数
  5. ubuntu-firefox有网但是打不开网页的解决办法
  6. 【Java】等差数列
  7. js IntersectionObserver监听元素的显示与隐藏,图片懒加载
  8. java文件读取与写入
  9. linux java相对路径和绝对路径_Linux绝对路径和相对路径详解
  10. pcl加载并显示pcd、ply点云数据文件