How to reload partition tables on Linux: Difference between revisions

From Leo's Notes
This page was last edited on 30 December 2021, at 04:45.
m Text replacement - "Category:Linux{{Navbox Linux}}" to "{{Navbox Linux}}Category:Linux"
Added more ways to reload partition tables
Line 1: Line 1:
Use {{code|partprobe}} to reload the partition tables on all disks, or {{code|partprobe /dev/sdx}} to reload only a specific device.
After changing partition information on a disk, you might need to tell Linux to reload the partition tables in order for the device partitions (eg. /dev/sda1) to show up. Below are some options to tell Linux to re-read the partition information.


{{Navbox Linux}}[[Category:Linux]]
=== Ways to force Linux to re-read partition tables ===
{| class="wikitable"
!Description
!Example
|-
|Use <code>partprobe</code> to reload partition tables on all disks, or <code>partprobe $device</code> to reload a specific device.
|{{Highlight
| code = # partprobe
# partprobe /dev/sda
| lang = terminal
}}
|-
|Use hdparm. <code>hdparm -z $device</code>.
|{{Highlight
| code = # hdparm -z /dev/sda
| lang = terminal
}}
|-
|Use partx. Alternatively, kpartx might also work, though that's usually used with device mappers.
|{{Highlight
| code = # partx -a /dev/sda
# kpartx -a /dev/sda
| lang = terminal
}}
|-
|Interface with the kernel directly and trigger a rescan of a specific block device.
|{{Highlight
| code = # echo 1 > /sys/block/sda/device/rescan
| lang = terminal
}}
|}
<br />{{Navbox Linux}}
[[Category:Linux]]

Revision as of 04:45, 30 December 2021

After changing partition information on a disk, you might need to tell Linux to reload the partition tables in order for the device partitions (eg. /dev/sda1) to show up. Below are some options to tell Linux to re-read the partition information.

Ways to force Linux to re-read partition tables

Description Example
Use partprobe to reload partition tables on all disks, or partprobe $device to reload a specific device.
# partprobe
# partprobe /dev/sda
Use hdparm. hdparm -z $device.
# hdparm -z /dev/sda
Use partx. Alternatively, kpartx might also work, though that's usually used with device mappers.
# partx -a /dev/sda
# kpartx -a /dev/sda
Interface with the kernel directly and trigger a rescan of a specific block device.
# echo 1 > /sys/block/sda/device/rescan