hdparm fails if called to often to fast:

The operation has completed successfully.
+ hdparm -z /dev/sdb

/dev/sdb:
 re-reading partition table
+ /sbin/sgdisk --largest-new=0 --mbrtogpt -- /dev/sdb
Warning: The kernel is still using the old partition table.
The new table will be used at the next reboot or after you
run partprobe(8) or kpartx(8)
The operation has completed successfully.
+ hdparm -z /dev/sdb

/dev/sdb:
 re-reading partition table
 BLKRRPART failed: Device or resource busy
This commit is contained in:
Nico Schottelius 2018-02-18 20:51:02 +01:00
parent 59028e1c4e
commit 32636437b7

View file

@ -43,19 +43,21 @@ dev_block="/dev/disk/by-partuuid/$uuid_block"
--typecode=0:4fbd7e29-9d25-41b8-afd0-062c0ceff05d \ --typecode=0:4fbd7e29-9d25-41b8-afd0-062c0ceff05d \
--mbrtogpt -- $DEV --mbrtogpt -- $DEV
hdparm -z "$DEV" sleep 2 ; hdparm -z "$DEV"
# Using gdisk --largest-new does not change the name or set guid; # Using gdisk --largest-new does not change the name or set guid;
# So use 2 steps instead # So use 2 steps instead
/sbin/sgdisk --largest-new=0 --mbrtogpt -- $DEV /sbin/sgdisk --largest-new=0 --mbrtogpt -- $DEV
hdparm -z "$DEV"
sleep 2 ; hdparm -z "$DEV"
lastpart=$(gdisk -l $DEV | tail -n1 | awk '{ print $1 }') lastpart=$(gdisk -l $DEV | tail -n1 | awk '{ print $1 }')
/sbin/sgdisk --change-name="${lastpart}:ceph block" \ /sbin/sgdisk --change-name="${lastpart}:ceph block" \
--partition-guid="${lastpart}:$uuid_block" \ --partition-guid="${lastpart}:$uuid_block" \
--typecode="${lastpart}:cafecafe-9b03-4f30-b4c6-b4b80ceff106" \ --typecode="${lastpart}:cafecafe-9b03-4f30-b4c6-b4b80ceff106" \
--mbrtogpt -- $DEV --mbrtogpt -- $DEV
hdparm -z "$DEV" sleep 2 ; hdparm -z "$DEV"
/sbin/mkfs -t xfs -f -i size=2048 -- "$dev_metadata" /sbin/mkfs -t xfs -f -i size=2048 -- "$dev_metadata"