if [[ "$osfamily" =~ ^(open|net)bsd$ ]]; then
# OpenBSD DUIDs device naming
if [[ "${entry[1]}" =~ ^[a-f0-9]{16}\.[a-p]$ ]]; then
- duid="$(@scriptsdir@/disklabel.py --print-duid "$device")"
+ duid="$(@scriptsdir@/disklabel.py --get-duid "$device")"
if [[ ! "${entry[1]}" =~ ^$duid ]]; then
warn "fstab refers to unknown DUID: \`$duid'"
parser.add_option("-l", "--list", action="store_true", dest="list",
default=False,
help="list the disklabel on the specified media")
- parser.add_option("--print-last", action="store_true", dest="last_part",
- default=False,
+ parser.add_option("--get-last-partition", action="store_true",
+ dest="last_part", default=False,
help="print the label of the last partition")
- parser.add_option("--print-last-linux", action="store_true",
- dest="last_linux", default=False,
- help="print the linux number for the last partition")
- parser.add_option("--print-duid", action="store_true", dest="duid",
+ parser.add_option("--get-duid", action="store_true", dest="duid",
default=False,
help="print the disklabel unique identifier")
parser.add_option("-d", "--enlarge-disk", type="int", dest="disk_size",
if options.last_part:
print "%c" % chr(ord('a') + disklabel.get_last_partition_id())
- if options.last_linux:
- part_id = disklabel.get_last_partition_id()
- # The linux kernel does not assign a partition for label 'c' that
- # describes the whole disk
- print part_id + (4 if part_id > 2 else 5)
-
if options.disk_size is not None:
disklabel.enlarge_disk(options.disk_size)
fi
if [ "$SNF_IMAGE_PROPERTY_OSFAMILY" = openbsd ]; then
- part="${SNF_IMAGE_DEV}$(@scriptsdir@/disklabel.py --print-last-linux "$SNF_IMAGE_DEV")"
+ bsd_part="$(@scriptsdir@/disklabel.py --get-last-partition "$SNF_IMAGE_DEV")"
+ if [ "$bsd_part" = "b" ]; then
+ warn "Last partition is swap space. Resizing ommited"
+ exit 0
+ fi
+
+ part="${SNF_IMAGE_DEV}$(disklabel2linux "$bsd_part")"
- # If this fails the script will stop
- $DUMPFS_OPENBSD "$part" > /dev/null
+ $DUMPFS_OPENBSD "$part" > /dev/null ||
+ { warn "Filesystem is not UFS. Resizing ommited"; exit 0; }
- $GROWFS_OPENBSD -y "$part"
- exit 0
+ $GROWFS_OPENBSD -y "$part"
+ exit 0
fi
if [ "$SNF_IMAGE_PROPERTY_OSFAMILY" = netbsd ]; then