IIf you are using hot swappable hard disk and created a new partition using the fdisk, then you need to reboot Linux based system to get partition recognized. Without reboot, you will NOT be able to create a filesystem on your newly created or modified partitions with the mke2fs command.
The kernel still uses the old table. The new table will be utilized at the next reboot or after you run partprobe or kpartx command. Both of these programs informs the operating system kernel of partition table changes, by requesting that the operating system re-read the partition table.
You will seen an error that read as follows:
Re-reading the partition table failed.: Device or resource busy
A sample session:
After the fdisk command session (which makes changes to partition table) just type the following command:
# partprobe /dev/sdXpartprobepartprobe
Replace /dev/sdX or /dev/hdX with actual device name. Now you will able to create filesystem on new partition with the mke2fs command.
Inform the OS of partition table changes
The partprobe command is part of GNU parted software. parted is a disk partitioning and partition resizing program. It allows you to create, destroy, resize, move and copy ext2, ext3, linux-swap, FAT, FAT32, and reiserfs partitions. It can create, resize and move Macintosh HFS partitions, as well as detect jfs, ntfs, ufs, and xfs partitions. It is useful for creating space for new operating systems, reorganising disk usage, and copying data to new hard disks.
To use partprobe command install parted. If you are using Debian / Ubuntu Linux, enter:
$ sudo apt-get install parted
OR if you are using RHEL version <= 4, enter:
# up2date parted
OR if you are using CentOS / RHEL 5/6, enter:
# yum install parted
OR if you are Fedora, enter:
$ sudo dnf install parted
Now you can use the partprobe command.
The kpartx tool, derived from util-linux’ partx, reads partition tables on specified device and create device maps over partitions segments detected. It is called from hotplug upon device maps creation and deletion. To use kpartx command install kpartx. If you are using Debian / Ubuntu Linux, enter:
$ sudo apt install kpartx
To use, type:
# kpartx -u /dev/sdd2
- Man pages – kpartx(8),partprobe(8)
- See official parted home page for download and other information.