mirror of
https://git.launchpad.net/livecd-rootfs
synced 2025-05-08 01:11:31 +00:00
Use flock to avoid races with systemd-udevd that cause loop device partitions to briefly disappear. (LP: #2045586)
This commit is contained in:
parent
eb987eae64
commit
11b5162b14
8
debian/changelog
vendored
8
debian/changelog
vendored
@ -1,3 +1,11 @@
|
|||||||
|
livecd-rootfs (2.765.39) UNRELEASED; urgency=medium
|
||||||
|
|
||||||
|
[ dann frazier ]
|
||||||
|
* Use flock to avoid races with systemd-udevd that cause loop device
|
||||||
|
partitions to briefly disappear. (LP: #2045586)
|
||||||
|
|
||||||
|
-- Michael Hudson-Doyle <michael.hudson@ubuntu.com> Thu, 25 Jan 2024 07:45:58 +1300
|
||||||
|
|
||||||
livecd-rootfs (2.765.38) jammy; urgency=medium
|
livecd-rootfs (2.765.38) jammy; urgency=medium
|
||||||
|
|
||||||
* Add a largemem subarch for ubuntu-server that ships a 64k kernel variant
|
* Add a largemem subarch for ubuntu-server that ships a 64k kernel variant
|
||||||
|
@ -67,16 +67,23 @@ mount_image() {
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# As explained in excruciating detail in LP: #2045586, losetup
|
||||||
|
# races with udev in a way that can cause partition device files
|
||||||
|
# to briefly vanish. systemd docs say we can hold udev off by using
|
||||||
|
# flocks: https://systemd.io/BLOCK_DEVICE_LOCKING/
|
||||||
|
# `udevadm lock` isn't yet usable in Ubuntu, so we'll use flock for now
|
||||||
|
|
||||||
# Find the rootfs location
|
# Find the rootfs location
|
||||||
rootfs_dev_mapper="${loop_device}p${rootpart}"
|
rootfs_dev_mapper="${loop_device}p${rootpart}"
|
||||||
if [ ! -b "${rootfs_dev_mapper}" ]; then
|
if flock -x ${loop_device} [ ! -b "${rootfs_dev_mapper}" ]; then
|
||||||
echo "${rootfs_dev_mapper} is not a block device";
|
echo "${rootfs_dev_mapper} is not a block device";
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Add some information to the debug logs
|
# Add some information to the debug logs
|
||||||
echo "Mounted disk image ${backing_img} to ${rootfs_dev_mapper}"
|
echo "Mounted disk image ${backing_img} to ${rootfs_dev_mapper}"
|
||||||
blkid ${rootfs_dev_mapper}
|
flock -x ${loop_device} blkid ${rootfs_dev_mapper} \
|
||||||
|
|| echo "blkid failed; continuing"
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
@ -206,10 +213,14 @@ mount_disk_image() {
|
|||||||
mount_partition "${rootfs_dev_mapper}" $mountpoint
|
mount_partition "${rootfs_dev_mapper}" $mountpoint
|
||||||
|
|
||||||
local uefi_dev="${loop_device}p15"
|
local uefi_dev="${loop_device}p15"
|
||||||
if [ -b ${uefi_dev} -a -e $mountpoint/boot/efi ]; then
|
if flock -x ${loop_device} \
|
||||||
mount "${uefi_dev}" $mountpoint/boot/efi
|
[ -b ${uefi_dev} -a -e $mountpoint/boot/efi ]; then
|
||||||
|
flock -x ${loop_device} mount "${uefi_dev}" $mountpoint/boot/efi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Having one partition mounted should avoid udev-triggered partition
|
||||||
|
# rescans on that device, so we no longer need to flock.
|
||||||
|
|
||||||
# This is needed to allow for certain operations
|
# This is needed to allow for certain operations
|
||||||
# such as updating grub and installing software
|
# such as updating grub and installing software
|
||||||
cat > $mountpoint/usr/sbin/policy-rc.d << EOF
|
cat > $mountpoint/usr/sbin/policy-rc.d << EOF
|
||||||
|
Loading…
x
Reference in New Issue
Block a user