赞助商广告

linux操作系统 partprobe命令手册

partprobe

不重启的情况下重读分区

补充说明

partprobe命令 用于重读分区表,当出现删除文件后,出现仍然占用空间。可以partprobe在不重启的情况下重读分区。

语法

partprobe(选项)(参数)

选项

-d:不更新内核;
-s:显示摘要和分区;
-h:显示帮助信息;
-v:显示版本信息。

参数

设备:指定需要确认分区表改变的硬盘对应的设备文件。

实例

使用partprobe不重启系统添加新的磁盘分区,主机自带硬盘超过300GB,目前只划分使用了3个主分区,不到70GB,如下:

[root@localhost ~]# df -h 
Filesystem Size Used Avail Use% Mounted on 
/dev/sda1 29G 3.7G  24G 14% / 
/dev/sda2 29G  22G 5.2G 81% /oracle 
tmpfs    2.0G    0 2.0G  0% /dev/shm
[root@localhost ~]# cat /proc/partitions
major minor  #blocks  name

   8     0  311427072 sda
   8     1   30716248 sda1
   8     2   30716280 sda2
   8     3    8193150 sda3
   8    16     976896 sdb
   8    32     976896 sdc

…省略其他

现在需要给系统添加1个100GB的空间存放数据文件,而又不影响现有系统上业务的运行,使用fdisk结合partprobe命令不重启系统添加一块新的磁盘分区。操作步骤如下:

第1步 添加新的磁盘分区

[root@localhost ~]# fdisk /dev/sda
The number of cylinders for this disk is set to 38770.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of lilo)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)

command (m for help): p

Disk /dev/sda: 318.9 GB, 318901321728 bytes
255 heads, 63 sectors/track, 38770 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   id  System
/dev/sda1   *           1        3824    30716248+  83  Linux
/dev/sda2            3825        7648    30716280   83  Linux
/dev/sda3            7649        8668     8193150   82  Linux swap / Solaris

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Selected partition 4
First cylinder (8669-38770, default 8669):
Using default value 8669
last cylinder or +size or +sizeM or +sizeK (8669-38770, default 38770): +100G   
Command (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: 

Device or resource busy.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.

第2步 使用工具partprobe让kernel读取分区信息:

[root@localhost ~]# partprobe

使用fdisk工具只是将分区信息写到磁盘,如果需要mkfs磁盘分区则需要重启系统,而使用partprobe则可以使kernel重新读取分区信息,从而避免重启系统。

第3步 格式化文件系统:

[root@localhost ~]# mkfs.ext3 /dev/sda4
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
12222464 inodes, 24416791 blocks
1220839 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
746 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 
    2654208, 4096000, 7962624, 11239424, 20480000, 23887872

Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information:

done

This filesystem will be automatically checked every 26 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
[root@localhost ~]#

第4步 mount新的分区/dev/sda4

[root@localhost ~]# e2label  /dev/sda4 /data
[root@localhost ~]# mkdir /data
[root@localhost ~]# mount /dev/sda4 /data
[root@localhost ~]# df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/sda1             29753556   3810844  24406900  14% /
/dev/sda2             29753588  11304616  16913160  41% /oracle
tmpfs                  2023936         0   2023936   0% /dev/shm
/dev/sda4             96132968    192312  91057300   1% /data

使用partprobe可以不用重启系统即可配合fdisk工具创建新的分区。

linux命令手册

btrfs subvolume 管理 btrfs 子卷和快照。
aurvote 为 AUR 中的包投票。
apt-add-repository 管理 apt 仓库。
cpuid 显示有关所有 CPU 的详细信息。
blkdiscard 丢弃存储设备上的设备扇区。对 SSD 有用。
adduser 添加用户的工具。
i3 一款动态平铺窗口管理器。
chage 更改用户账户和密码到期信息。
unix2mac 将 Unix 样式的行尾更改为 macOS 样式。
btrfs 一种基于写时复制(COW)原理的 Linux 文件系统。
anbox 在任何 GNU/Linux 操作系统上运行安卓应用。
asterisk 电话和交换(手机)服务器。
ul 执行文本的下划线。
grub-install 安装 GRUB 到设备。
sacctmgr 查看、配置、管理 Slurm 账户。
cp 复制文件和目录。
ubuntu-bug 这是 `apport-bug` 命令的一个别名。
acpi 显示电池状态或热量信息。
apt-cache Debian 和 Ubuntu 的包查询工具。
konsole Konsole: KDE 终端模拟器。
ascii 显示 ASCII 字符的别名。
cal 打印日历信息,高亮显示当前日期。
avahi-browse 显示通过 mDNS/DNS-SD 暴露在本地网络的服务和主机。
readelf 显示 EFI 文件信息。
archlinux-java 提供 Java 环境设置功能的一个帮助脚本。
mac2unix 将 macOS 样式的行尾更改为 Unix 样式。
a2disconf 在基于 Debian 的操作系统上禁用 Apache 配置文件。
archinstall Arch Linux 引导安装程序。
amixer ALSA 声卡驱动程序的混合器。
addr2line 将二进制文件地址转换成文件名和行数。
bluetoothd 管理蓝牙设备的守护进程。
arithmetic 测试见到你的算术问题。
a2ensite 在基于 Debian 的操作系统上启用 Apache 虚拟主机。
btrfs filesystem 管理 btrfs 文件系统。
openvpn3 OpenVPN 3 Linux 客户端。
ark KDE 归档工具。
apport-bug 在 Ubuntu 上提交错误报告。
poweroff 关闭系统。
betterlockscreen 简洁的锁屏程序。
grub-mkconfig 生成GRUB配置文件。
apt-mark 修改已安装软件包状态的工具。
bluetoothctl 从命令行管理蓝牙设备。
lvs 显示逻辑卷信息。
bpftrace Linux eBPF 的高级跟踪语言。
dmesg 显示或控制内核环形缓冲区。
aura Aura 包管理器:一个安全且支持多语言的 Arch Linux 和 AUR 的包管理器。
unix2dos 将 Unix 样式的行尾更改为 DOS 样式。
bitwise 支持动态基数转换和位操作的多基数交互式计算器。
apache2ctl Apache HTTP web 服务器命令行管理工具。
archey 一个可以以新颖的方式显示系统信息的简单工具。
batcat 这是 `bat` 命令的一个别名。
a2dismod 在基于 Debian 的操作系统上禁用 Apache 模块。
line 读取单行输入。
a2query 在基于 Debian 的操作系统上查看 Apache 运行配置。
aptitude Debian 和 Ubuntu 上的软件包管理工具。
btrfs device 管理 btrfs 文件系统中的设备。
at 在指定时间执行命令。
arecored ALSA 声卡驱动的声音录制器。
megadl 这是 `megatools-dl` 命令的一个别名。
pacman Arch Linux 的软件包管理器工具。
as 一个可移植的 GUN 汇编器。
boltctl 控制雷电(thunderbolt)设备。
apt-file 在 apt 软件包中查找文件,其中也包括未安装的软件。
w 显示登录者及其进程。
yay Yet Another Yogurt: 一个用于 Arch Linux 的工具,用于从 Arch User Repository 中构建和安装软件包。
apt-get Debian 和 Ubuntu 的软件包管理工具。
flatpak 构建、安装和运行 Flatpak 应用和运行时。
arch-chroot 辅助 Arch Linux 安装流程的更强 `chroot` 命令。
reboot 重新启动系统。
alpine 一个电子邮件客户端和 usenet 新闻组程序,具有 pico/nano 风格的界面。
aurman 用来构建和安装 AUR 包的 Arch Linux 实用工具。
autorandr 自动调节屏幕布局。
ac 打印用户连接时长数据。
ip-route-list 这是 `ip-route-show` 命令的一个别名。
iptables 可用于配置 Linux 内核防火墙提供的过滤表、规则链和规则的程序。
aplay ALSA 声卡驱动程序的命令行声音播放器。
dos2unix 将 DOS 样式的行尾更改为 Unix 样式。
xcowsay 在您的 Linux 桌面上显示一头可爱的牛和指定的消息。
asciiart 将图像转换为 ASCII.
apt-key Debian 和 Ubuntu 上的 APT 软件包管理器的密钥管理工具。
abbr 管理 fish shell 的缩写。
lsattr 列出 Linux 系统下的文件属性。
add-apt-repository apt 仓库管理。
a2enmod 在基于 Debian 的操作系统上启用 Apache 模块。
balooctl KDE Plasma 的文件索引和搜索框架。
diff3 逐行比较三个文件。
debuild 从源代码构建 `Debian` 软件包的工具。
dmenu 动态菜单。
ncal 这是 `cal` 命令的一个别名。
cc 这是 `gcc` 命令的一个别名。
yaourt Arch Linux 中用于从 Arch User Repository 中构建软件包的工具。
apt 基于 Debian 的发行版上的软件包管理工具。
zypper SUSE & openSUSE 的软件包管理工具。
auracle 用来和 Arch Linux 用户仓库交互的命令行工具,这个仓库通常被称作 AUR.
brctl 以太网桥管理。
a2dissite 在基于 Debian 的操作系统上禁用 Apache 虚拟主机。
aspell 交互式拼写检查工具。
authconfig 用于设置系统认证资源的命令行界面。
btrfs scrub 清理 btrfs 文件系统以验证数据完整性。
bmon 监控带宽并捕获网络相关统计信息。
beep 让电脑扬声器发出哔哔声的实用程序。
brightnessctl GUN/Linux 操作系统上用来读取和控制设备亮度的实用工具。
addpart 将特定分区的存在告知 Linux 内核。
debootstrap 创建一个基本的 `Debian` 系统。
alternatives 这是 `update-alternatives` 命令的一个别名。
bpytop 用图形显示有关正在运行的进程的动态实时信息。类似于 `gtop` 和 `htop`.
flameshot 带有 GUI 界面的 Screenshot 工具。
bspwm 这是 `bspc` 命令的一个别名。
cgroups 这是 `cgclassify` 命令的一个别名。
logsave 将一个命令的输出保存在日志文件中。
a2enconf 在基于 Debian 的操作系统上启用 Apache 配置文件。
apk Alpine Linux 的包管理工具。
blkid 列出所有已识别的分区及其通用唯一标识符 (UUID)。