Magellan Linux

Annotation of /trunk/installer/include/prepare_disks.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1020 - (hide annotations) (download) (as text)
Sun May 30 17:37:33 2010 UTC (13 years, 11 months ago) by niro
File MIME type: application/x-sh
File size: 2121 byte(s)
-fixed header
-fixed status pipeline
1 niro 773 #!/bin/sh
2 niro 1020 # $Id$
3 niro 773
4     : ${INSTALL_ROOT="/mnt/magellan"}
5     KNOWN_DISKS="ROOT BOOT SWAP HOME TMP USER VAR SVR OPT"
6    
7     format_disks()
8     {
9     local disk
10     local disk_part
11     local disk_fs
12     local opts
13     local progress
14    
15     declare -i progress=0
16    
17     # disk format
18     for disk in ${KNOWN_DISKS}
19     do
20     disk_part=$(eval echo \$PARTITION_DISK_${disk})
21     disk_fs=$(eval echo \$PARTITION_FS_${disk})
22    
23     if [[ ! -z ${disk_part} ]]
24     then
25     if [[ ! -z ${disk_fs} ]]
26     then
27     case ${disk_fs} in
28 niro 1020 #swap) mkswap ${disk_part} >&2;;
29     #reiserfs) mkfs.${disk_fs} -f ${disk_part} >&2;;
30     #keep-as-is) echo "keeping as-is." ;;
31     #*) mkfs.${disk_fs} ${disk_part} >&2;;
32     swap) mkswap ${disk_part} &> /dev/null;;
33     reiserfs) mkfs.${disk_fs} -f ${disk_part} &> /dev/null;;
34     keep-as-is) echo "keeping as-is." ;;
35     *) mkfs.${disk_fs} ${disk_part} &> /dev/null;;
36 niro 773 esac
37     fi
38     fi
39    
40     (( progress++ ))
41     echo ${progress} 9 | awk '{print ($1 / $2 * 100) - 1}'
42     done
43    
44     echo "100"
45     }
46    
47     mount_disks()
48     {
49     local disk
50     local disk_part
51     local dest
52    
53     # activate swap
54     swapon ${PARTITION_DISK_SWAP}
55    
56     # first mount rootfs
57     mount ${PARTITION_DISK_ROOT} ${INSTALL_ROOT}
58    
59     # than all other
60     for disk in ${KNOWN_DISKS}
61     do
62     case ${disk} in
63     BOOT) dest=boot ;;
64     HOME) dest=home ;;
65     TMP) dest=tmp ;;
66     USER) dest=usr ;;
67     VAR) dest=var ;;
68     SVR) dest=svr ;;
69     OPT) dest=opt ;;
70     *) continue ;;
71     esac
72    
73     disk_part=$(eval echo \$PARTITION_DISK_${disk})
74     if [[ ! -z ${disk_part} ]]
75     then
76     install -d ${INSTALL_ROOT}/${dest}
77     mount ${disk_part} ${INSTALL_ROOT}/${dest}
78     fi
79     done
80     }
81    
82     umount_disks()
83     {
84     local disk
85     local disk_part
86     local dest
87    
88     # first umount all other
89     for disk in ${KNOWN_DISKS}
90     do
91     # excludes
92     case ${disk} in
93     ROOT) continue ;;
94     SWAP) continue ;;
95     esac
96    
97     disk_part=$(eval echo \$PARTITION_DISK_${disk})
98     [[ ! -z ${disk_part} ]] && umount ${disk_part}
99     done
100    
101     # then umount rootfs
102     umount ${PARTITION_DISK_ROOT}
103    
104     # de-activate swap
105     swapoff ${PARTITION_DISK_SWAP}
106     }
107    
108     case $1 in
109     --format | -f) format_disks ;;
110     --mount | -m ) mount_disks ;;
111     --umount | -u ) umount_disks ;;
112 niro 1020 *) echo "unknown option '$1'." ;;
113 niro 773 esac

Properties

Name Value
svn:executable *