home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / ROOTDSKS.144 / COLOR144 / usr / lib / setup / SeTpartitions < prev    next >
Encoding:
Text File  |  1995-02-27  |  10.6 KB  |  264 lines

  1. #!/bin/sh
  2. T_PX=/mnt
  3. if [ ! -r /tmp/SeTplist ]; then
  4.  # Give warning?
  5.  exit
  6. else
  7.  PARTLIST="`cat /tmp/SeTplist`"
  8. fi
  9. #ROOT_DEVICE="`cat /tmp/SeTrootdev`"
  10. while [ 0 ]; do 
  11.  if [ ! "`echo "$PARTLIST" | sed -n '2 p'`" = "" ]; then # more than one:
  12.   ONLY_ONE="false"
  13.  else
  14.   ONLY_ONE="true"
  15.  fi
  16.  echo > /tmp/tmpmsg
  17.  echo "   Device Boot  Begin   Start     End  Blocks   Id  System" >> /tmp/tmpmsg
  18.  echo "$PARTLIST" >> /tmp/tmpmsg
  19.  if [ "$ONLY_ONE" = "false" ]; then
  20.   echo >> /tmp/tmpmsg
  21.   echo "Which device would you like to use for your root Linux partition?" >> /tmp/tmpmsg
  22.   dialog --title "The following partitions are available for Linux:" \
  23.   --inputbox "`cat /tmp/tmpmsg`" 20 72 2> /tmp/rootdev
  24.   if [ $? = 1 -o $? = 255 ]; then
  25.    rm -f /tmp/tmpmsg
  26.    exit
  27.   fi
  28.   ROOT_DEVICE="`cat /tmp/rootdev`"
  29.   rm -f /tmp/rootdev
  30.  else
  31.   dialog --title "Using this partition for Linux:" \
  32. --msgbox "`cat /tmp/tmpmsg`" 8 72
  33.   if [ $? = 255 ]; then
  34.    rm -f /tmp/tmpmsg
  35.    exit
  36.   fi
  37.   ROOT_DEVICE="`echo "$PARTLIST" | cut -b1-10`"
  38.  fi
  39.  rm -f /tmp/tmpmsg
  40.  if [ ! -b $ROOT_DEVICE ]; then
  41.   dialog --msgbox "Invalid device. Try again. Use a format such as: \
  42. /dev/hda3 or whatever the device name is." 7 50
  43.   if [ $? = 255 ]; then
  44.    exit
  45.   fi
  46.   continue;
  47.  fi
  48.  if fdisk -l | fgrep "Linux native" | fgrep $ROOT_DEVICE 1> /dev/null 2> /dev/null ; then
  49.   echo "$ROOT_DEVICE" > /tmp/SeTrootdev
  50.   ROOT_SIZE="`fdisk -l | fgrep "$ROOT_DEVICE" | cut -b38-45 2> /dev/null`"
  51. #  dialog --title "CHOOSE LINUX FILESYSTEM" --menu "\
  52. #There are two main filesystem types that are used for Linux. These are \
  53. #the xiafs filesystem, and the second extended filesystem (ext2). \
  54. #Ext2 seems to be the current standard. Xiafs hasn't really been changed \
  55. #in quite some time. Ext2 has one really nice feature that xiafs doesn't have: \
  56. #as an ext2 partition is unmounted, a clean bit is written to it. When the \
  57. #machine is rebooted, checking is skipped for any partitions that have the \
  58. #clean bit on them. Xiafs may be a better choice for machines with low memory, \
  59. #however, so it's still supported. \
  60. #What filesystem do you plan to use on your root partition \
  61. #($ROOT_DEVICE), ext2fs or xiafs? " 20 65 2 \
  62. #"ext2" "Linux Second Extended Filesystem" \
  63. #"xiafs" "Linux Xiafs" 2> /tmp/filesys
  64. #  if [ $? = 1 -o $? = 255 ]; then
  65. #   exit
  66. #  fi
  67. #  ROOT_SYS_TYPE="`cat /tmp/filesys`"
  68. #  rm -f /tmp/filesys
  69. ROOT_SYS_TYPE=ext2
  70.   dialog --title "FORMAT PARTITION" --menu "If this partition has not been formatted, you should \
  71. format it. NOTE: This will erase all data on it. If you are trying to upgrade an \
  72. existing Linux partition, you should use setup from your hard drive, not from \
  73. the boot/root disk. (The versions of setup supplied on the hard drive and the \
  74. boot/root disk differ) Would you like to format this partition?" 15 70 3 \
  75. "Format" "Quick format with no bad block checking" \
  76. "Check" "Slow format that checks for bad blocks" \
  77. "No" "No, do not format this partition" 2> /tmp/format
  78.   if [ $? = 1 -o $? = 255 ]; then
  79.    exit
  80.   fi
  81.   DOFORMAT="`cat /tmp/format`"
  82.   rm -f /tmp/format
  83.   if [ "$DOFORMAT" = "Format" -o "$DOFORMAT" = "Check" ]; then
  84.    if [ "$ROOT_SYS_TYPE" = "ext2" ]; then
  85.     dialog --title "SELECT INODE DENSITY" --menu "Ext2fs defaults to one \
  86. inode per 4096 bytes of drive space. If you're going to have many small files \
  87. on your drive, then you may need more inodes (one is used for each file \
  88. entry). You can change the density to one inode per 2048 bytes, or even per \
  89. 1024 bytes.  Select '2048' or '1024', or just hit enter to accept the default \
  90. of 4096 bytes.  NOTE: If you are going to run from CD using a small (<60MB) \
  91. partition, use 1024 to be safe.  Each link uses an inode and it's easy to \
  92. run out of space." 18 65 3 \
  93. "4096" "1 inode per 4096 bytes. (default)" \
  94. "2048" "1 inode per 2048 bytes." \
  95. "1024" "1 inode per 1024 bytes." 2> /tmp/density
  96.     DENSITY="`cat /tmp/density`"
  97.     rm -f /tmp/density
  98.     if [ ! "$DENSITY" = "2048" -a ! "$DENSITY" = "1024" ]; then
  99.      DENSITY=4096
  100.     fi
  101.     INODE_DENSITY="Inode density: 1 inode per $DENSITY bytes."
  102.    fi
  103.    dialog --title "FORMATTING" --infobox "Formatting $ROOT_DEVICE  \n\
  104. Size in 1K blocks: $ROOT_SIZE \n\
  105. Filesystem type: $ROOT_SYS_TYPE \n\
  106. $INODE_DENSITY " 6 45
  107.    if mount | fgrep $ROOT_DEVICE 1> /dev/null 2> /dev/null ; then
  108.     umount $ROOT_DEVICE 2> /dev/null
  109.    fi
  110.    if [ "$ROOT_SYS_TYPE" = "ext2" ]; then
  111.     if [ "$DOFORMAT" = "Check" ]; then
  112.      mke2fs -c -i $DENSITY $ROOT_DEVICE $ROOT_SIZE 1> /dev/null 2> /dev/null
  113.     else
  114.      mke2fs -i $DENSITY $ROOT_DEVICE $ROOT_SIZE 1> /dev/null 2> /dev/null
  115.     fi
  116.    else
  117.     if [ "$DOFORMAT" = "Check" ]; then
  118.      mkxfs -c $ROOT_DEVICE $ROOT_SIZE 1> /dev/null 2> /dev/null
  119.     else
  120.      mkxfs $ROOT_DEVICE $ROOT_SIZE 1> /dev/null 2> /dev/null
  121.     fi
  122.    fi
  123.   fi
  124.   sync
  125.   mount -t $ROOT_SYS_TYPE $ROOT_DEVICE $T_PX 1> /dev/null 2> /dev/null
  126.   echo "$ROOT_DEVICE       /        $ROOT_SYS_TYPE        defaults   1   1" > /tmp/SeTnative
  127.   break;
  128.  else # device not tagged Linux native
  129.   dialog --title "INCORRECT PARTITION TYPE" --msgbox "The partition you have selected is not tagged as Linux \
  130. native. Either select a new partition, or tag the selected \
  131. one with Linux fdisk." 10 50
  132.   if [ $? = 255 ]; then
  133.    exit
  134.   fi
  135.   continue;
  136.  fi
  137.  break;
  138. done # mounting the target root partition
  139. # Now, if the user wants to mount some other partitions for /usr or
  140. # /usr/X11 or whatever (/tmp, you name it), Here's where we do that
  141. if [ ! "`echo "$PARTLIST" | sed -n '2 p'`" = "" ]; then
  142.  dialog --yesno "You seem to have more than one partition tagged as Linux \
  143. native. You may use these to distribute your Linux system across more than \
  144. one partition. Currently, you have $ROOT_DEVICE mounted as your / partition. \
  145. You might want to mount large directories such as /usr or /usr/X11 or seperate \
  146. partitions. You should not try to mount /etc, /sbin, or /bin on their own \
  147. partitions since they contain utilities needed to bring the system up and mount \
  148. partitions. Would you like to use some of the other Linux partitions to mount \
  149. some of your directories?" 14 70
  150.  if [ $? = 0 ]; then
  151.   while [ 0 ]; do
  152.    echo > /tmp/tmpmsg
  153.    echo "These are your Linux partitions:" >> /tmp/tmpmsg
  154.    echo "$PARTLIST" >> /tmp/tmpmsg
  155.    echo >> /tmp/tmpmsg
  156.    echo "These partitions are already in use:" >> /tmp/tmpmsg
  157.    mount | fgrep mnt >> /tmp/tmpmsg
  158.    echo >> /tmp/tmpmsg 
  159.    echo "Please enter the partition you would like to use, or" >> /tmp/tmpmsg
  160.    echo "type [q] to quit adding new partitions: " >> /tmp/tmpmsg
  161.    dialog --inputbox "`cat /tmp/tmpmsg`" 22 73 2> /tmp/nextp
  162.    if [ $? = 1 -o $? = 255 ]; then
  163.     break;
  164.    fi
  165.    NEXT_PARTITION="`cat /tmp/nextp`"
  166.    rm -f /tmp/nextp /tmp/tmpmsg
  167.    if [ "$NEXT_PARTITION" = "q" ]; then
  168.     break;
  169.    fi
  170.    if [ ! -b $NEXT_PARTITION ]; then
  171.     dialog --msgbox "Invalid device. Try again. Use a format such as: \
  172. /dev/hda3 or whatever the device name is." 7 50
  173.     continue;
  174.    else
  175.     if fdisk -l | fgrep "Linux native" | fgrep $NEXT_PARTITION 1> /dev/null 2> /dev/null ; then
  176.      NEXT_SIZE="`fdisk -l | fgrep "$NEXT_PARTITION" | cut -b38-45 2> /dev/null`"
  177. #     dialog --menu "What type of filesystem would you like to use?" 9 70 2 \
  178. #"ext2" "Linux Second Extended Filesystem" \
  179. #"xiafs" "Linux Xiafs" 2> /tmp/filesys
  180. #     if [ $? = 1 -o $? = 255 ]; then
  181. #      exit
  182. #     fi
  183. #     NEXT_SYS_TYPE="`cat /tmp/filesys`"
  184.      NEXT_SYS_TYPE=ext2
  185.      rm -f /tmp/filesys
  186.      dialog --menu "Would you like to format this partition?" 10 70 3 \
  187. "Format" "Quick format with no bad block checking" \
  188. "Check" "Slow format that checks for bad blocks" \
  189. "No" "No, do not format this partition" 2> /tmp/format
  190.      if [ $? = 1 -o $? = 255 ]; then
  191.       exit
  192.      fi
  193.      DOFORMAT="`cat /tmp/format`"
  194.      rm -f /tmp/format
  195.      if [ "$DOFORMAT" = "Format" -o "$DOFORMAT" = "Check" ]; then
  196.       if [ "$NEXT_SYS_TYPE" = "ext2" ]; then
  197.        dialog --title "SELECT INODE DENSITY" --menu "Ext2fs defaults to one \
  198. inode per 4096 bytes of drive space. If you're going to have many small files \
  199. on your drive, then you may need more inodes (one is used for each file \
  200. entry). You can change the density to one inode per 2048 bytes, or even per \
  201. 1024 bytes.  Select '2048' or '1024', or just hit enter to accept the default \
  202. of 4096 bytes." 15 65 3 \
  203. "4096" "1 inode per 4096 bytes. (default)" \
  204. "2048" "1 inode per 2048 bytes." \
  205. "1024" "1 inode per 1024 bytes." 2> /tmp/density
  206.        DENSITY="`cat /tmp/density`"
  207.        rm -f /tmp/density
  208.        if [ ! "$DENSITY" = "2048" -a ! "$DENSITY" = "1024" ]; then
  209.         DENSITY=4096
  210.        fi
  211.        INODE_DENSITY="Inode density: 1 inode per $DENSITY bytes."
  212.       fi
  213.       dialog --title "FORMATTING" --infobox "Formatting $NEXT_PARTITION  \n\
  214. Size in 1K blocks: $NEXT_SIZE \n\
  215. Filesystem type: $NEXT_SYS_TYPE \n\
  216. $INODE_DENSITY " 6 45
  217.       if [ "$NEXT_SYS_TYPE" = "ext2" ]; then
  218.        if [ "$DOFORMAT" = "Check" ]; then
  219.         mke2fs -c -i $DENSITY $NEXT_PARTITION $NEXT_SIZE 1> /dev/null 2> /dev/null
  220.        else
  221.         mke2fs -i $DENSITY $NEXT_PARTITION $NEXT_SIZE 1> /dev/null 2> /dev/null
  222.        fi
  223.       else
  224.        if [ "$DOFORMAT" = "Check" ]; then
  225.         mkxfs -c $NEXT_PARTITION $NEXT_SIZE 1> /dev/null 2> /dev/null
  226.        else
  227.         mkxfs $NEXT_PARTITION $NEXT_SIZE 1> /dev/null 2> /dev/null
  228.        fi
  229.       fi
  230.      fi
  231.      dialog --inputbox \
  232. "Now this new partition must be mounted somewhere somewhere in \n\
  233. your new directory tree. For example, if you want to put it under \n\
  234. /usr/X11R6, then respond: /usr/X11R6 \n\n\
  235. Where would you like to mount $NEXT_PARTITION?" 12 70 2> /tmp/newdir
  236.      NEW_DIRECTORY="`cat /tmp/newdir`"
  237.      rm -f /tmp/newdir
  238.      mkdir -p /mnt$NEW_DIRECTORY
  239.      chmod 755 /mnt$NEW_DIRECTORY
  240.      sync
  241.      mount -t $NEXT_SYS_TYPE $NEXT_PARTITION /mnt$NEW_DIRECTORY 1> /dev/null 2> /dev/null
  242.      echo "$NEXT_PARTITION        $NEW_DIRECTORY        $NEXT_SYS_TYPE        defaults   1   1" >> /tmp/SeTnative
  243.      echo > /tmp/tmpmsg  
  244.      echo "This line will be added to your /etc/fstab:" >> /tmp/tmpmsg
  245.      echo >> /tmp/tmpmsg
  246.      echo "$NEXT_PARTITION        $NEW_DIRECTORY        $NEXT_SYS_TYPE        defaults   1   1" >> /tmp/tmpmsg
  247.      echo >> /tmp/tmpmsg
  248.      echo "Would you like to mount some more additional partitions? " >> /tmp/tmpmsg
  249.      dialog --title "MOUNT MORE PARTITIONS?" --yesno "`cat /tmp/tmpmsg`" 15 73
  250.      REPLY=$?
  251.      if [ "$REPLY" = "1" ]; then
  252.       break;
  253.      fi
  254.     else # device not tagged Linux native
  255.      dialog --title "NOT LINUX NATIVE" --msgbox "The partition you have selected is not tagged as Linux \
  256. native. Either select a new partition, or tag the selected \
  257. one with Linux fdisk." 10 40
  258.      continue;
  259.     fi
  260.    fi
  261.   done # mounting additional partitions
  262.  fi # Do you want to use these?
  263. fi # more than one native partition
  264.