Revision 83d0c566 snf-image-helper/tasks/30MountImage.in

b/snf-image-helper/tasks/30MountImage.in
50 50
        os=${SNF_IMAGE_PROPERTY_OSFAMILY^^[bsd]}
51 51
        log_error "For ${os^?} images only UFS root partitions are supported."
52 52
    fi
53

  
53 54
    ufstype="$(get_ufstype "$rootdev")"
54 55
    if [ "x$ufstype" = "x" ]; then
55
        exit 1
56
        log_error "Unable to recognize the UFS type in the root partition."
56 57
    fi
58

  
57 59
    $MOUNT -t ufs -o ufstype="$ufstype,rw" "$rootdev" "$SNF_IMAGE_TARGET"
58 60

  
59
    # In many cases when you try to mount a UFS file system read-write,
60
    # the mount command returns SUCCESS and a message like this gets printed:
61
    #
62
    #   mount: warning: /mnt seems to be mounted read-only.
63
    #
64
    # remounting does the trick
61
    # See mount_all() for a reason why we do this
65 62
    $MOUNT -o remount,rw "$SNF_IMAGE_TARGET"
66 63
else
67 64
    $MOUNT -o rw "$rootdev" "$SNF_IMAGE_TARGET"
68 65
fi
69 66

  
70
if [ "$SNF_IMAGE_PROPERTY_OSFAMILY" != "linux" ]; then
67
if [ "$SNF_IMAGE_PROPERTY_OSFAMILY" = "windows" ]; then
71 68
    exit 0
72 69
fi
73 70

  
74
if [ ! -f "${SNF_IMAGE_TARGET}/etc/fstab" ]; then
75
    log_error "/etc/fstab is missing from the root file system"
76
fi
77

  
78
# Read the local partitions from fstab and get a sorted list:
79
#<mount_point> <device> <options>
80
fstab="$(grep -v ^\# "${SNF_IMAGE_TARGET}/etc/fstab" | awk '{ if (match($3, "ext[234]")) { print $2,$1,$4 } }' | sort -bd)"
81

  
82
# Mount non-root filesystems
83
while read line; do
84
    read -ra entry <<< "$line"
85
    # Skip root. It is already mounted
86
    if [ "${entry[0]}" = "/" ]; then
87
        continue
88
    fi
89

  
90
    if [[ ${entry[1]} =~ ^(LABEL|UUID)= ]]; then
91
        entry[1]=$(findfs "${entry[1]}")
92
    fi
93

  
94
    # I'm in doupt. Sould I mount the filesystems with the mount options
95
    # found in the image's /etc/fstab or not?
96
    $MOUNT "${entry[1]}" "${SNF_IMAGE_TARGET}${entry[0]}" # -o "${entry[2]}"
97

  
98
done <<< "$fstab"
71
mount_all "$SNF_IMAGE_PROPERTY_OSFAMILY" "$SNF_IMAGE_DEV" "$SNF_IMAGE_TARGET"
99 72

  
100 73
exit 0
101 74

  

Also available in: Unified diff