Jephe Wu - http://linuxtechres.blogspot.com
Objective: update partition table without Linux OS reboot
Environment: RHEL 6.X
Tools: partprobe, partx -a , kpartx -a, blockdev --rereadpt /dev/sdX, sfdisk -R /dev/sdX, hdparm -z /dev/sdX
Concepts: create/update partition for a block device while Linux is running
Explanation:
partprobe
In RHEL 6, it will only trigger the OS to update the partitions on a disk that none of its partitions are in use (e.g. mounted). If any partition on a disk is in use, partprobe will not trigger the OS to update partitions in the system because it is considered unsafe in some situations.
Partx
# partx -v -a /dev/sdb
# partx -l /dev/sdb
kpartx
kpartx -a /file/path/system.img
mount /dev/loop0p1 /mnt/somewhere
Some raw images contains multiple partitions (e.g. full HD image). In this case, it's necessary to specify a starting offset for each partition
Some raw images contains multiple partitions (e.g. full HD image). In this case, it's necessary to specify a starting offset for each partition. offset is the bytes which is the starting sectors*512.
# mount -t vfat -o loop,offset=$((210944*512),ro,noexec img.dd /mnt/tmp_2
# kpartx -v -a rawimage.dd
creates these mappings
/dev/mapper/loop0p1
/dev/mapper/loop0p2
/dev/mapper/loop0p5
The partitions can be mounted with these commands:
# mount /dev/mapper/loop0p1 /media/suspectHD_01/ -o ro
# mount /dev/mapper/loop0p5 /media/suspectHD_02/ -o ro
partx -va /dev/sdX
kpartx -va /dev/sdX
hdparm -z /dev/sdX
sfdisk -R /dev/sdX
No comments:
Post a Comment