mirror of
https://github.com/linuxkit/linuxkit.git
synced 2026-01-14 00:57:01 +00:00
format: blkid content check, format argument, and verbose argument
- Added new argument -force to the format utility. This will force formatting of the specified single device if it exists and is a block device - By default, the format package will no longer format the specified single device if content exists on that device - Added new blkid-based check for content, in addition to the existing check for partitions on autoformat candidate devices. - Cleanup of old unused code. - Refactoring of block device verification. - Added test/cases/040_packages/006_format_mount/005_by_device_force - Added document of new arguments to /docs/external-disk.md. Also sorted the arguments in the doc alphabetically and added them as bullets so they do not run together on the page. Signed-off-by: Isaac Rodman <isaac@eyz.us>
This commit is contained in:
committed by
Isaac Rodman
parent
367c7e2c88
commit
3de78f2109
54
test/cases/040_packages/006_format_mount/005_by_device_force/check.sh
Executable file
54
test/cases/040_packages/006_format_mount/005_by_device_force/check.sh
Executable file
@@ -0,0 +1,54 @@
|
||||
#!/bin/sh
|
||||
|
||||
function failed {
|
||||
printf "format_force test suite FAILED\n" >&1
|
||||
exit 1
|
||||
}
|
||||
|
||||
# sda should have been partitioned and sda1 formatted as ext4
|
||||
# command: ["/usr/bin/format", "-verbose", "-type", "ext4", "/dev/sda"]
|
||||
|
||||
# sdb should have been partitioned and sdb1 formatted as ext4
|
||||
# command: ["/usr/bin/format", "-verbose", "-type", "ext4", "/dev/sdb"]
|
||||
|
||||
# sda1 should remain ext4, as the format was not re-forced
|
||||
# command: ["/usr/bin/format", "-verbose", "-type", "xfs", "/dev/sda"]
|
||||
|
||||
# sdb should have been re-partitioned, with sdb1 now formatted as xfs due to -force flag
|
||||
# command: ["/usr/bin/format", "-verbose", "-force", "-type", "xfs", "/dev/sdb"]
|
||||
|
||||
ATTEMPT=0
|
||||
|
||||
while true; do
|
||||
ATTEMPT=$((ATTEMPT+1))
|
||||
|
||||
echo "=== forcing device discovery (attempt ${ATTEMPT}) ==="
|
||||
mdev -s
|
||||
|
||||
echo "=== /dev list (attempt ${ATTEMPT}) ==="
|
||||
ls -al /dev
|
||||
|
||||
if [ -b /dev/sda1 ] && [ -b /dev/sdb1 ]; then
|
||||
echo 'Found /dev/sda1 and /dev/sdb1 block devices'
|
||||
break
|
||||
fi
|
||||
|
||||
if [ $ATTEMPT -ge 10 ]; then
|
||||
echo "Did not detect /dev/sda1 nor /dev/sdb1 in ${ATTEMPT} attempts"
|
||||
failed
|
||||
fi
|
||||
|
||||
sleep 1
|
||||
done
|
||||
|
||||
echo "=== /dev/sda1 ==="
|
||||
blkid -o export /dev/sda1
|
||||
echo "=== /dev/sdb1 ==="
|
||||
blkid -o export /dev/sdb1
|
||||
|
||||
echo "=== /dev/sda1 test ==="
|
||||
blkid -o export /dev/sda1 | grep -Fq 'TYPE=ext4' || failed
|
||||
echo "=== /dev/sdb1 test ==="
|
||||
blkid -o export /dev/sdb1 | grep -Fq 'TYPE=xfs' || failed
|
||||
|
||||
printf "format_force test suite PASSED\n" >&1
|
||||
26
test/cases/040_packages/006_format_mount/005_by_device_force/test.sh
Executable file
26
test/cases/040_packages/006_format_mount/005_by_device_force/test.sh
Executable file
@@ -0,0 +1,26 @@
|
||||
#!/bin/sh
|
||||
# SUMMARY: Check that the format and mount packages work
|
||||
# LABELS:
|
||||
# REPEAT:
|
||||
|
||||
set -e
|
||||
|
||||
# Source libraries. Uncomment if needed/defined
|
||||
#. "${RT_LIB}"
|
||||
. "${RT_PROJECT_ROOT}/_lib/lib.sh"
|
||||
|
||||
NAME=test-format
|
||||
DISK1=disk1.img
|
||||
DISK2=disk2.img
|
||||
|
||||
clean_up() {
|
||||
rm -rf ${NAME}-* ${DISK1} ${DISK2}
|
||||
}
|
||||
trap clean_up EXIT
|
||||
|
||||
moby build -format kernel+initrd -name ${NAME} test.yml
|
||||
RESULT="$(linuxkit run -disk file=${DISK1},size=512M -disk file=${DISK2},size=512M ${NAME})"
|
||||
echo "${RESULT}"
|
||||
echo "${RESULT}" | grep -q "suite PASSED"
|
||||
|
||||
exit 0
|
||||
@@ -0,0 +1,37 @@
|
||||
kernel:
|
||||
image: linuxkit/kernel:4.9.51
|
||||
cmdline: "console=ttyS0"
|
||||
init:
|
||||
- linuxkit/init:6fe9d31a53bbd200183bb31edd795305e868d5a7
|
||||
- linuxkit/runc:a1b564248a0d0b118c11e61db9f84ecf41dd2d2a
|
||||
onboot:
|
||||
- name: format
|
||||
image: linuxkit/format:test
|
||||
command: ["/usr/bin/format", "-verbose", "-type", "ext4", "/dev/sda"]
|
||||
- name: format
|
||||
image: linuxkit/format:test
|
||||
command: ["/usr/bin/format", "-verbose", "-type", "ext4", "/dev/sdb"]
|
||||
- name: format
|
||||
image: linuxkit/format:test
|
||||
command: ["/usr/bin/format", "-verbose", "-type", "xfs", "/dev/sda"]
|
||||
- name: format
|
||||
image: linuxkit/format:test
|
||||
command: ["/usr/bin/format", "-verbose", "-force", "-type", "xfs", "/dev/sdb"]
|
||||
- name: test
|
||||
image: linuxkit/format:test
|
||||
binds:
|
||||
- /check.sh:/check.sh
|
||||
command: ["sh", "./check.sh"]
|
||||
capabilities:
|
||||
- CAP_SYS_ADMIN
|
||||
- CAP_MKNOD
|
||||
- name: poweroff
|
||||
image: linuxkit/poweroff:1e9876c682c74d0602b7647c628bb0875fb13998
|
||||
command: ["/bin/sh", "/poweroff.sh", "10"]
|
||||
files:
|
||||
- path: check.sh
|
||||
source: ./check.sh
|
||||
trust:
|
||||
org:
|
||||
- linuxkit
|
||||
- library
|
||||
Reference in New Issue
Block a user