Amélioration des unmount/unloop
This commit is contained in:
parent
3122435982
commit
c02a9a2a94
@ -309,6 +309,7 @@ function createImageWrap()
|
|||||||
BOOTFS="ext4"
|
BOOTFS="ext4"
|
||||||
fi
|
fi
|
||||||
formatpartitions ${BOOTFS} ext4
|
formatpartitions ${BOOTFS} ext4
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -343,13 +344,11 @@ function createimage()
|
|||||||
info "making partitions"
|
info "making partitions"
|
||||||
echo -e "${FDISK_SCRIPT}" | /sbin/fdisk ${DEVICE}
|
echo -e "${FDISK_SCRIPT}" | /sbin/fdisk ${DEVICE}
|
||||||
|
|
||||||
# Activate loop device
|
#Activate 'pY' : /dev/loopXpY
|
||||||
info "device to detach ${DEVICE}"
|
partx -vu "${DEVICE}"
|
||||||
/sbin/losetup -d "${DEVICE}"
|
#Previous function give us a list of partition. It is easy to get it and define prior this list the partition.
|
||||||
DEVICE=$(/sbin/partx -va "${INSTALL_PATH}/${IMAGE}" | /bin/grep -m 1 -E -o '/dev/loop.?')
|
#But... How to distinguish between the boot p1 and the root p2 if both are empty and ext4 ? ...
|
||||||
info "New attached device ${DEVICE}"
|
|
||||||
info "partitions list:"
|
|
||||||
info "$(/sbin/partx -v "${INSTALL_PATH}/${IMAGE}")"
|
|
||||||
if [ 1 -eq ${SEPARATE_BOOT_PARTITION} ]; then
|
if [ 1 -eq ${SEPARATE_BOOT_PARTITION} ]; then
|
||||||
BOOTP="${DEVICE}p1"
|
BOOTP="${DEVICE}p1"
|
||||||
ROOTP="${DEVICE}p2"
|
ROOTP="${DEVICE}p2"
|
||||||
@ -446,6 +445,7 @@ function copyingsystem()
|
|||||||
|
|
||||||
copyingcommon
|
copyingcommon
|
||||||
|
|
||||||
|
sync
|
||||||
warning "You can now burn the image ( ${INSTALL_PATH}/${IMAGE} ) on SD card"
|
warning "You can now burn the image ( ${INSTALL_PATH}/${IMAGE} ) on SD card"
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
@ -491,24 +491,40 @@ function unmountingPartitions()
|
|||||||
# Syncing devices before unmounting
|
# Syncing devices before unmounting
|
||||||
/usr/bin/sync
|
/usr/bin/sync
|
||||||
|
|
||||||
if [ 1 -eq ${SEPARATE_BOOT_PARTITION} ]; then
|
if [ -z "${BOOTP}" ] && [ -z "${ROOTP}" ] ; then
|
||||||
/usr/bin/umount "${BOOT}"
|
warning "Root partition and Boot partition not defined !"
|
||||||
|
|
||||||
|
for LOOP in $(losetup -l -O NAME,BACK-FILE -n | grep "${IMAGE}" | cut -d ' ' -f 1 ) ; do
|
||||||
|
IFS=$'\n'
|
||||||
|
for PARTITION in $(mount -l | grep ${LOOP}); do
|
||||||
|
MOUNTPOINT=$(echo "$PARTITION" | cut -d ' ' -f 3)
|
||||||
|
PARTITION=$(echo "$PARTITION" | cut -d ' ' -f 1)
|
||||||
|
info "unmount ${PARTITION} and remove ${MOUNTPOINT}"
|
||||||
|
/usr/bin/umount "${PARTITION}"
|
||||||
|
if [ ${?} -eq 0 ]; then
|
||||||
|
/bin/rmdir "${MOUNTPOINT}"
|
||||||
|
else
|
||||||
|
error "line ${LINENO} error unmounting ${BOOT}..."
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
unset IFS
|
||||||
|
done
|
||||||
|
else
|
||||||
|
if [ ! -z "${BOOTP}" ]; then
|
||||||
|
/usr/bin/umount "${BOOTP}"
|
||||||
if [ ${?} -eq 0 ]; then
|
if [ ${?} -eq 0 ]; then
|
||||||
/bin/rmdir "${BOOT}"
|
/bin/rmdir "${BOOT}"
|
||||||
else
|
else
|
||||||
error "line ${LINENO} error unmounting ${BOOT}: exiting"
|
error "line ${LINENO} error unmounting ${BOOT}..."
|
||||||
exit ${ERR_1}
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
/usr/bin/umount "${ROOTP}"
|
||||||
/usr/bin/umount "${ROOT}"
|
|
||||||
if [ ${?} -eq 0 ]; then
|
if [ ${?} -eq 0 ]; then
|
||||||
/bin/rmdir "${ROOT}"
|
/bin/rmdir "${ROOT}"
|
||||||
else
|
else
|
||||||
error "line ${LINENO} error unmounting ${ROOT}: exiting"
|
error "line ${LINENO} error unmounting ${ROOT}..."
|
||||||
# exit ${ERR_1}
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -518,32 +534,17 @@ function unloopingImage(){
|
|||||||
# Syncing devices before unmounting
|
# Syncing devices before unmounting
|
||||||
/usr/bin/sync
|
/usr/bin/sync
|
||||||
|
|
||||||
if [ 1 -eq ${SEPARATE_BOOT_PARTITION} ]; then
|
|
||||||
/usr/sbin/partx -d "${BOOTP}"
|
|
||||||
if [ ${?} -ne 0 ]; then
|
|
||||||
error "line ${LINENO} warning : error unmounting ${BOOTP} "
|
|
||||||
# exit ${ERR_1}
|
|
||||||
fi
|
|
||||||
/usr/sbin/partx -d "${ROOTP}"
|
|
||||||
if [ ${?} -ne 0 ]; then
|
|
||||||
error "line ${LINENO} warning : error unmounting ${ROOTP} "
|
|
||||||
# exit ${ERR_1}
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
/usr/sbin/partx -d "${ROOTP}"
|
|
||||||
if [ ${?} -ne 0 ]; then
|
|
||||||
error "line ${LINENO} warning : error unmounting ${ROOTP} "
|
|
||||||
# exit ${ERR_1}
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# [root@jabztop mageia4arm (master)]# losetup -l -O NAME,BACK-FILE -n
|
# [root@jabztop mageia4arm (master)]# losetup -l -O NAME,BACK-FILE -n
|
||||||
# /dev/loop0 /home/jibz/workspaces/mageia4arm/build/Mageia-7-bananaPro1.img (deleted)
|
# /dev/loop0 /home/jibz/workspaces/mageia4arm/build/Mageia-7-bananaPro1.img (deleted)
|
||||||
info "Looped devices to unmount : $(losetup -l -O NAME,BACK-FILE -n | grep "${IMAGE}" | cut -d ' ' -f 1 ) "
|
info "Looped devices to unmount : $(losetup -l -O NAME,BACK-FILE -n | grep "${IMAGE}" | cut -d ' ' -f 1 ) "
|
||||||
|
|
||||||
for LOOP in $(losetup -l -O NAME,BACK-FILE -n | grep "${IMAGE}" | cut -d ' ' -f 1 ) ; do
|
for LOOP in $(losetup -l -O NAME,BACK-FILE -n | grep "${IMAGE}" | cut -d ' ' -f 1 ) ; do
|
||||||
info "removing ${LOOP}"
|
info "removing ${LOOP}"
|
||||||
losetup -d "${LOOP}"
|
for PARTITION in ${LOOP}p* ; do
|
||||||
|
partx -dv "${PARTITION}"
|
||||||
|
done
|
||||||
|
# losetup -d "${LOOP}"
|
||||||
|
kpartx -d "${INSTALL_PATH}/${IMAGE}"
|
||||||
done
|
done
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
@ -599,19 +600,6 @@ function clean()
|
|||||||
warning "${IMAGE} does not exists"
|
warning "${IMAGE} does not exists"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Removing boot and root directory
|
|
||||||
if [ -d "${BOOT}" ]; then
|
|
||||||
info "Removing ${BOOT}"
|
|
||||||
/bin/rm -rf "${BOOT}"
|
|
||||||
else
|
|
||||||
warning "${BOOT} does not exists"
|
|
||||||
fi
|
|
||||||
if [ -d "${ROOT}" ]; then
|
|
||||||
info "Removing ${ROOT}"
|
|
||||||
/bin/rm -rf "${ROOT}"
|
|
||||||
else
|
|
||||||
warning "${ROOT} does not exists"
|
|
||||||
fi
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user