]> CyberLeo.Net >> Repos - FreeBSD/releng/9.0.git/blob - usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh
Copy stable/9 to releng/9.0 as part of the FreeBSD 9.0-RELEASE release
[FreeBSD/releng/9.0.git] / usr.sbin / pc-sysinstall / backend / functions-bsdlabel.sh
1 #!/bin/sh
2 #-
3 # Copyright (c) 2010 iXsystems, Inc.  All rights reserved.
4 #
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions
7 # are met:
8 # 1. Redistributions of source code must retain the above copyright
9 #    notice, this list of conditions and the following disclaimer.
10 # 2. Redistributions in binary form must reproduce the above copyright
11 #    notice, this list of conditions and the following disclaimer in the
12 #    documentation and/or other materials provided with the distribution.
13 #
14 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 # ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 # SUCH DAMAGE.
25 #
26 # $FreeBSD$
27
28 # Functions related to disk operations using bsdlabel
29
30 # Check if we are are provided a geli password on the nextline of the config
31 check_for_enc_pass()
32 {
33   CURLINE="${1}"
34  
35   get_next_cfg_line "${CFGF}" "${CURLINE}" 
36   echo ${VAL} | grep -q "^encpass=" 2>/dev/null
37   if [ $? -eq 0 ] ; then
38     # Found a password, return it
39     get_value_from_string "${VAL}"
40     return
41   fi
42
43   export VAL=""
44   return
45 };
46
47 # On check on the disk-label line if we have any extra vars for this device
48 get_fs_line_xvars()
49 {
50   ACTIVEDEV="${1}"
51   LINE="${2}"
52
53   echo $LINE | grep -q ' (' 2>/dev/null
54   if [ $? -eq 0 ] ; then
55
56     # See if we are looking for ZFS specific options
57     echo $LINE | grep -q '^ZFS' 2>/dev/null
58     if [ $? -eq 0 ] ; then
59       ZTYPE="NONE"
60       ZFSVARS="`echo $LINE | cut -d '(' -f 2- | cut -d ')' -f 1 | xargs`"
61
62       echo $ZFSVARS | grep -qE "^(disk|file|mirror|raidz(1|2)?|spare|log|cache):" 2>/dev/null
63           if [ $? -eq 0 ] ; then
64        ZTYPE=`echo $ZFSVARS | cut -f1 -d:`
65        ZFSVARS=`echo $ZFSVARS | sed "s|$ZTYPE: ||g" | sed "s|$ZTYPE:||g"`
66           fi
67
68       # Return the ZFS options
69       if [ "${ZTYPE}" = "NONE" ] ; then
70         VAR="${ACTIVEDEV} ${ZFSVARS}"
71       else
72         VAR="${ZTYPE} ${ACTIVEDEV} ${ZFSVARS}"
73       fi
74       export VAR
75       return
76     fi # End of ZFS block
77
78     # See if we are looking for UFS specific newfs options
79     echo $LINE | grep -q '^UFS' 2>/dev/null
80     if [ $? -eq 0 ] ; then
81       FSVARS="`echo $LINE | cut -d '(' -f 2- | cut -d ')' -f 1 | xargs`"
82       VAR="${FSVARS}"
83       export VAR
84       return
85     fi
86
87   fi # End of xtra-options block
88
89   # If we got here, set VAR to empty and export
90   export VAR=""
91   return
92 };
93
94 # Init each zfs mirror disk with a boot sector so we can failover
95 setup_zfs_mirror_parts()
96 {
97   _nZFS=""
98
99   # Using mirroring, setup boot partitions on each disk
100   _mirrline="`echo ${1} | sed 's|mirror ||g'`"
101   for _zvars in $_mirrline
102   do
103     echo "Looping through _zvars: $_zvars" >>${LOGOUT}
104     echo "$_zvars" | grep -q "${2}" 2>/dev/null
105     if [ $? -eq 0 ] ; then continue ; fi
106     if [ -z "$_zvars" ] ; then continue ; fi
107
108     is_disk "$_zvars" >/dev/null 2>/dev/null
109     if [ $? -eq 0 ] ; then
110       echo "Setting up ZFS mirror disk $_zvars" >>${LOGOUT}
111       init_gpt_full_disk "$_zvars" >/dev/null 2>/dev/null
112       rc_halt "gpart add -t freebsd-zfs ${_zvars}" >/dev/null 2>/dev/null
113       _nZFS="$_nZFS ${_zvars}p2"        
114     else
115       _nZFS="$_nZFS ${_zvars}"  
116     fi  
117   done
118   echo "mirror $2 `echo $_nZFS | tr -s ' '`"
119 } ;
120
121 # Function which creates a unique label name for the specified mount
122 gen_glabel_name()
123 {
124   MOUNT="$1"
125   TYPE="$2"
126   NUM="0"
127   MAXNUM="20"
128
129   # Check if we are doing /, and rename it
130   if [ "$MOUNT" = "/" ]
131   then
132     NAME="rootfs"
133   else
134     # If doing a swap partition, also rename it
135     if [ "${TYPE}" = "SWAP" ]
136     then
137       NAME="swap"
138     else
139       NAME="`echo $MOUNT | sed 's|/||g' | sed 's| ||g'`"
140     fi
141   fi
142
143   # Loop through and break when we find our first available label
144   while
145   Z=1
146   do
147     glabel status | grep -q "${NAME}${NUM}" 2>/dev/null
148     if [ $? -ne 0 ]
149     then
150       break
151     else
152         NUM=$((NUM+1))
153     fi
154
155     if [ $NUM -gt $MAXNUM ]
156     then
157       exit_err "Cannot allocate additional glabel name for $NAME"
158       break
159     fi
160   done 
161    
162
163   export VAL="${NAME}${NUM}" 
164 };
165
166 # Function to setup partitions using gpart
167 setup_gpart_partitions()
168 {
169   local _dTag="$1"
170   local _pDisk="$2"
171   local _wSlice="$3"
172   local _sNum="$4"
173   local _pType="$5"
174   FOUNDPARTS="1"
175
176   # Lets read in the config file now and setup our partitions
177   if [ "${_pType}" = "gpt" ] ; then
178     CURPART="2"
179   else
180     PARTLETTER="a"
181     CURPART="1"
182     rc_halt "gpart create -s BSD ${_wSlice}"
183   fi
184
185   while read line
186   do
187     # Check for data on this slice
188     echo $line | grep -q "^${_dTag}-part=" 2>/dev/null
189     if [ $? -eq 0 ]
190     then
191       FOUNDPARTS="0"
192       # Found a slice- entry, lets get the slice info
193       get_value_from_string "${line}"
194       STRING="$VAL"
195
196       # We need to split up the string now, and pick out the variables
197       FS=`echo $STRING | tr -s '\t' ' ' | cut -d ' ' -f 1` 
198       SIZE=`echo $STRING | tr -s '\t' ' ' | cut -d ' ' -f 2` 
199       MNT=`echo $STRING | tr -s '\t' ' ' | cut -d ' ' -f 3` 
200
201       # Check if we have a .eli extension on this FS
202       echo ${FS} | grep -q ".eli" 2>/dev/null
203       if [ $? -eq 0 ]
204       then
205         FS="`echo ${FS} | cut -d '.' -f 1`"
206         ENC="ON"
207         check_for_enc_pass "${line}"
208         if [ "${VAL}" != "" ] ; then
209           # We have a user supplied password, save it for later
210           ENCPASS="${VAL}" 
211         fi
212       else
213         ENC="OFF"
214       fi
215
216       # Check if the user tried to setup / as an encrypted partition
217       check_for_mount "${MNT}" "/"
218       if [ $? -eq 0 -a "${ENC}" = "ON" ]
219       then
220         export USINGENCROOT="0"
221       fi
222           
223       # Now check that these values are sane
224       case $FS in
225         UFS|UFS+S|UFS+J|UFS+SUJ|ZFS|SWAP) ;;
226        *) exit_err "ERROR: Invalid file system specified on $line" ;;
227       esac
228
229       # Check that we have a valid size number
230       expr $SIZE + 1 >/dev/null 2>/dev/null
231       if [ $? -ne 0 ]; then
232         exit_err "ERROR: The size specified on $line is invalid"
233       fi
234
235       # Check that the mount-point starts with /
236       echo "$MNT" | grep -qe "^/" -e "^none" 2>/dev/null
237       if [ $? -ne 0 ]; then
238         exit_err "ERROR: The mount-point specified on $line is invalid"
239       fi
240
241       if [ "$SIZE" = "0" ]
242       then
243         SOUT=""
244       else
245         SOUT="-s ${SIZE}M"
246       fi
247
248       # Check if we found a valid root partition
249       check_for_mount "${MNT}" "/"
250       if [ $? -eq 0 ] ; then
251         export FOUNDROOT="1"
252         if [ "${CURPART}" = "2" -a "$_pType" = "gpt" ] ; then
253           export FOUNDROOT="0"
254         fi
255         if [ "${CURPART}" = "1" -a "$_pType" = "mbr" ] ; then
256           export FOUNDROOT="0"
257         fi
258       fi
259
260       check_for_mount "${MNT}" "/boot"
261       if [ $? -eq 0 ] ; then
262         export USINGBOOTPART="0"
263         if [ "${CURPART}" != "2" -a "${_pType}" = "gpt" ] ; then
264             exit_err "/boot partition must be first partition"
265         fi
266         if [ "${CURPART}" != "1" -a "${_pType}" = "mbr" ] ; then
267             exit_err "/boot partition must be first partition"
268         fi
269
270         if [ "${FS}" != "UFS" -a "${FS}" != "UFS+S" -a "${FS}" != "UFS+J" -a "${FS}" != "UFS+SUJ" ] ; then
271           exit_err "/boot partition must be formatted with UFS"
272         fi
273       fi
274
275       # Generate a unique label name for this mount
276       gen_glabel_name "${MNT}" "${FS}"
277       PLABEL="${VAL}"
278
279       # Get any extra options for this fs / line
280       if [ "${_pType}" = "gpt" ] ; then
281         get_fs_line_xvars "${_pDisk}p${CURPART}" "${STRING}"
282       else
283         get_fs_line_xvars "${_wSlice}${PARTLETTER}" "${STRING}"
284       fi
285       XTRAOPTS="${VAR}"
286
287       # Check if using zfs mirror
288       echo ${XTRAOPTS} | grep -q "mirror" 2>/dev/null
289       if [ $? -eq 0 -a "$FS" = "ZFS" ] ; then
290         if [ "${_pType}" = "gpt" ] ; then
291           XTRAOPTS=$(setup_zfs_mirror_parts "$XTRAOPTS" "${_pDisk}p${CURPART}")
292         else
293           XTRAOPTS=$(setup_zfs_mirror_parts "$XTRAOPTS" "${_wSlice}")
294         fi
295       fi
296
297       # Figure out the gpart type to use
298       case ${FS} in
299         ZFS) PARTYPE="freebsd-zfs" ;;
300         SWAP) PARTYPE="freebsd-swap" ;;
301         *) PARTYPE="freebsd-ufs" ;;
302       esac
303
304       # Create the partition
305       if [ "${_pType}" = "gpt" ] ; then
306         if [ "$CURPART" = "2" ] ; then
307           # If this is GPT, make sure first partition is aligned to 4k
308           rc_halt "gpart add -b 2016 ${SOUT} -t ${PARTYPE} ${_pDisk}"
309         else
310           rc_halt "gpart add ${SOUT} -t ${PARTYPE} ${_pDisk}"
311         fi
312       else
313         rc_halt "gpart add ${SOUT} -t ${PARTYPE} -i ${CURPART} ${_wSlice}"
314       fi
315
316       # Check if this is a root / boot partition, and stamp the right loader
317       for TESTMNT in `echo ${MNT} | sed 's|,| |g'`
318       do
319         if [ "${TESTMNT}" = "/" -a -z "${BOOTTYPE}" ] ; then
320            BOOTTYPE="${PARTYPE}" 
321         fi 
322         if [ "${TESTMNT}" = "/boot" ]  ; then
323            BOOTTYPE="${PARTYPE}" 
324         fi 
325       done 
326
327       # Save this data to our partition config dir
328       if [ "${_pType}" = "gpt" ] ; then
329         _dFile="`echo $_pDisk | sed 's|/|-|g'`"
330         echo "${FS}:${MNT}:${ENC}:${PLABEL}:GPT:${XTRAOPTS}" >${PARTDIR}/${_dFile}p${CURPART}
331
332         # Clear out any headers
333         sleep 2
334         dd if=/dev/zero of=${_pDisk}p${CURPART} count=2048 2>/dev/null
335
336         # If we have a enc password, save it as well
337         if [ -n "${ENCPASS}" ] ; then
338           echo "${ENCPASS}" >${PARTDIR}-enc/${_dFile}p${CURPART}-encpass
339         fi
340       else
341         # MBR Partition
342         _dFile="`echo $_wSlice | sed 's|/|-|g'`"
343         echo "${FS}:${MNT}:${ENC}:${PLABEL}:MBR:${XTRAOPTS}:${IMAGE}" >${PARTDIR}/${_dFile}${PARTLETTER}
344         # Clear out any headers
345         sleep 2
346         dd if=/dev/zero of=${_wSlice}${PARTLETTER} count=2048 2>/dev/null
347
348         # If we have a enc password, save it as well
349         if [ -n "${ENCPASS}" ] ; then
350           echo "${ENCPASS}" >${PARTDIR}-enc/${_dFile}${PARTLETTER}-encpass
351         fi
352       fi
353
354
355       # Increment our parts counter
356       if [ "$_pType" = "gpt" ] ; then 
357           CURPART=$((CURPART+1))
358         # If this is a gpt partition, we can continue and skip the MBR part letter stuff
359         continue
360       else
361           CURPART=$((CURPART+1))
362         if [ "$CURPART" = "3" ] ; then CURPART="4" ; fi
363       fi
364
365
366       # This partition letter is used, get the next one
367       case ${PARTLETTER} in
368         a) PARTLETTER="b" ;;
369         b) PARTLETTER="d" ;;
370         d) PARTLETTER="e" ;;
371         e) PARTLETTER="f" ;;
372         f) PARTLETTER="g" ;;
373         g) PARTLETTER="h" ;;
374         h) PARTLETTER="ERR" ;;
375         *) exit_err "ERROR: bsdlabel only supports up to letter h for partitions." ;;
376       esac
377
378     fi # End of subsection locating a slice in config
379
380     echo $line | grep -q "^commitDiskLabel" 2>/dev/null
381     if [ $? -eq 0 -a "${FOUNDPARTS}" = "0" ]
382     then
383
384       # If this is the boot disk, stamp the right gptboot
385       if [ ! -z "${BOOTTYPE}" -a "$_pType" = "gpt" ] ; then
386         case ${BOOTTYPE} in
387           freebsd-ufs) rc_halt "gpart bootcode -p /boot/gptboot -i 1 ${_pDisk}" ;;
388           freebsd-zfs) rc_halt "gpart bootcode -p /boot/gptzfsboot -i 1 ${_pDisk}" ;;
389         esac 
390       fi
391
392       # Make sure to stamp the MBR loader
393       if [ "$_pType" = "mbr" ] ; then
394         rc_halt "gpart bootcode -b /boot/boot ${_wSlice}"
395       fi
396
397       # Found our flag to commit this label setup, check that we found at least 1 partition
398       if [ "${CURPART}" = "2" ] ; then
399         exit_err "ERROR: commitDiskLabel was called without any partition entries for it!"
400       fi
401
402       break
403     fi
404   done <${CFGF}
405 };
406
407 # Reads through the config and sets up a BSDLabel for the given slice
408 populate_disk_label()
409 {
410   if [ -z "${1}" ]
411   then
412     exit_err "ERROR: populate_disk_label() called without argument!"
413   fi
414
415   # Set some vars from the given working slice
416   diskid="`echo $1 | cut -d ':' -f 1`" 
417   disk="`echo $1 | cut -d ':' -f 1 | sed 's|-|/|g'`" 
418   slicenum="`echo $1 | cut -d ':' -f 2`" 
419   type="`echo $1 | cut -d ':' -f 3`" 
420   
421   # Set WRKSLICE based upon format we are using
422   if [ "$type" = "mbr" ] ; then
423     wrkslice="${diskid}s${slicenum}"
424   fi
425   if [ "$type" = "gpt" ] ; then
426     wrkslice="${diskid}p${slicenum}"
427   fi
428
429   if [ ! -e "${SLICECFGDIR}/${wrkslice}" ] ; then
430     exit_err "ERROR: Missing SLICETAG data. This shouldn't happen - please let the developers know"
431   fi
432
433   disktag="`cat ${SLICECFGDIR}/${wrkslice}`"
434   slicedev="`echo $wrkslice | sed 's|-|/|g'`"
435   
436   # Setup the partitions with gpart
437   setup_gpart_partitions "${disktag}" "${disk}" "${slicedev}" "${slicenum}" "${type}"
438
439 };
440
441 # Function which reads in the disk slice config, and performs it
442 setup_disk_label()
443 {
444   # We are ready to start setting up the label, lets read the config and do the actions
445   # First confirm that we have a valid WORKINGSLICES
446   if [ -z "${WORKINGSLICES}" ]; then
447     exit_err "ERROR: No slices were setup! Please report this to the maintainers"
448   fi
449
450   # Check that the slices we have did indeed get setup and gpart worked
451   for i in $WORKINGSLICES
452   do
453     disk="`echo $i | cut -d '-' -f 1`" 
454     pnum="`echo $i | cut -d '-' -f 2`" 
455     type="`echo $i | cut -d '-' -f 3`" 
456     if [ "$type" = "mbr" -a ! -e "${disk}s${pnum}" ] ; then
457       exit_err "ERROR: The partition ${i} doesn't exist! gpart failure!"
458     fi
459     if [ "$type" = "gpt" -a ! -e "${disk}p${pnum}" ] ; then
460       exit_err "ERROR: The partition ${i} doesn't exist! gpart failure!"
461     fi
462   done
463
464   # Setup some files which we'll be referring to
465   export LABELLIST="${TMPDIR}/workingLabels"
466   rm $LABELLIST >/dev/null 2>/dev/null
467
468   # Set our flag to determine if we've got a valid root partition in this setup
469   export FOUNDROOT="-1"
470
471   # Check if we are using a /boot partition
472   export USINGBOOTPART="1"
473  
474   # Set encryption on root check
475   export USINGENCROOT="1"
476   
477   # Make the tmp directory where we'll store FS info & mount-points
478   rm -rf ${PARTDIR} >/dev/null 2>/dev/null
479   mkdir -p ${PARTDIR} >/dev/null 2>/dev/null
480   rm -rf ${PARTDIR}-enc >/dev/null 2>/dev/null
481   mkdir -p ${PARTDIR}-enc >/dev/null 2>/dev/null
482
483   for i in $WORKINGSLICES
484   do
485     populate_disk_label "${i}"
486   done
487
488   # Check if we made a root partition
489   if [ "$FOUNDROOT" = "-1" ]
490   then
491     exit_err "ERROR: No root (/) partition specified!!"
492   fi
493
494   # Check if we made a root partition
495   if [ "$FOUNDROOT" = "1" -a "${USINGBOOTPART}" != "0" ]
496   then
497     exit_err "ERROR: (/) partition isn't first partition on disk!"
498   fi
499
500   if [ "${USINGENCROOT}" = "0" -a "${USINGBOOTPART}" != "0" ]
501   then
502     exit_err "ERROR: Can't encrypt (/) with no (/boot) partition!"
503   fi
504 };
505
506 check_fstab_mbr()
507 {
508   local SLICE
509   local FSTAB
510
511   if [ -z "$2" ]
512   then
513         return 1
514   fi
515
516   SLICE="$1"
517   FSTAB="$2/etc/fstab"
518
519   if [ -f "${FSTAB}" ]
520   then
521     PARTLETTER=`echo "$SLICE" | sed -E 's|^.+([a-h])$|\1|'`
522
523     cat "${FSTAB}" | awk '{ print $2 }' | grep -qE '^/$' 2>&1
524     if [ $? -eq 0 ]
525     then
526       if [ "${PARTLETTER}" = "a" ]
527       then
528         FOUNDROOT="0"
529       else
530         FOUNDROOT="1"
531       fi
532
533       ROOTIMAGE="1"
534
535       export FOUNDROOT
536       export ROOTIMAGE
537     fi
538
539     cat "${FSTAB}" | awk '{ print $2 }' | grep -qE '^/boot$' 2>&1
540     if [ $? -eq 0 ]
541     then
542       if [ "${PARTLETTER}" = "a" ]
543       then
544         USINGBOOTPART="0"
545       else 
546         exit_err "/boot partition must be first partition"
547       fi 
548       export USINGBOOTPART
549     fi
550
551     return 0
552   fi
553
554   return 1
555 };
556
557 check_fstab_gpt()
558 {
559   local SLICE
560   local FSTAB
561
562   if [ -z "$2" ]
563   then
564         return 1
565   fi
566
567   SLICE="$1"
568   FSTAB="$2/etc/fstab"
569
570   if [ -f "${FSTAB}" ]
571   then
572     PARTNUMBER=`echo "${SLICE}" | sed -E 's|^.+p([0-9]*)$|\1|'`
573
574     cat "${FSTAB}" | awk '{ print $2 }' | grep -qE '^/$' 2>&1
575     if [ $? -eq 0 ]
576     then
577       if [ "${PARTNUMBER}" = "2" ]
578       then
579         FOUNDROOT="0"
580       else
581         FOUNDROOT="1"
582       fi
583
584       ROOTIMAGE="1"
585
586       export FOUNDROOT
587       export ROOTIMAGE
588     fi
589
590     cat "${FSTAB}" | awk '{ print $2 }' | grep -qE '^/boot$' 2>&1
591     if [ $? -eq 0 ]
592     then
593       if [ "${PARTNUMBER}" = "2" ]
594       then
595         USINGBOOTPART="0"
596       else 
597         exit_err "/boot partition must be first partition"
598       fi 
599       export USINGBOOTPART
600     fi
601
602     return 0
603   fi
604
605
606   return 1
607 };
608
609 check_disk_layout()
610 {
611   local SLICES
612   local TYPE
613   local DISK
614   local RES
615   local F
616
617   DISK="$1"
618   TYPE="MBR"
619
620   if [ -z "${DISK}" ]
621   then
622         return 1
623   fi
624
625   SLICES_MBR=`ls /dev/${DISK}s[1-4]*[a-h]* 2>/dev/null`
626   SLICES_GPT=`ls /dev/${DISK}p[0-9]* 2>/dev/null`
627   SLICES_SLICE=`ls /dev/${DISK}[a-h]* 2>/dev/null`
628
629   if [ -n "${SLICES_MBR}" ]
630   then
631     SLICES="${SLICES_MBR}"
632     TYPE="MBR"
633     RES=0
634   fi
635   if [ -n "${SLICES_GPT}" ]
636   then
637     SLICES="${SLICES_GPT}"
638     TYPE="GPT"
639     RES=0
640   fi
641   if [ -n "${SLICES_SLICE}" ]
642   then
643     SLICES="${SLICES_SLICE}"
644     TYPE="MBR"
645     RES=0
646   fi
647   
648   for slice in ${SLICES}
649   do
650     F=1
651     mount ${slice} /mnt 2>/dev/null
652     if [ $? -ne 0 ]
653     then
654       continue
655     fi 
656
657     if [ "${TYPE}" = "MBR" ]
658     then
659           check_fstab_mbr "${slice}" "/mnt"
660       F="$?"
661
662     elif [ "${TYPE}" = "GPT" ]
663     then
664           check_fstab_gpt "${slice}" "/mnt"
665       F="$?"
666     fi 
667
668     if [ ${F} -eq 0 ]
669     then
670       umount /mnt
671       break 
672     fi
673
674     umount /mnt
675   done
676
677   return ${RES}
678 };