#!/bin/bash source /etc/functions.magic ### # newfs patch # Copyright (C) Thomas "ShALLaX" Pedley (gentoox@shallax.com) # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ### clear ### # Ensure the fatx patch is installed ### if [ -z `grep -m1 -i fatx-patch1 /etc/conf.d/magic-database` ]; then echo "Sorry, you have not installed the fatx patch, run magic on its own first." $error exit 1 fi ### # If fatx patch is installed execute ### if [ ! -z `grep -m1 -i fatx-patch1 /etc/conf.d/magic-database` ] && [ ! -z `grep -m1 -i newfs1 /etc/conf.d/magic-database` ]; then echo "This will make additional space for linux using image files on F" echo "This will cause errors to be displayed when rebooting, simply ignore them." echo -e "" ### # Ask for name and size ### $input echo -en "Enter the name for the new space: " && read name echo -en "Enter the size for the new space MB: " && read size ### # < 100MB will mean that there isnt enough free space to be worth having # the new FS. ### if [ $size -lt 100 ]; then clear echo "Sorry, the size must be at least 100MB" $error exit 1 fi ### # 4000MB is the current FatX limitation ### if [ $size -gt 4000 ]; then clear echo "Sorry, the size must be less than or equal to 4000MB" $error exit 1 fi $busy mount /dev/hda55 /mnt/fatx/f 2> /dev/null 1> /dev/null mount -o remount,rw /mnt/fatx/f 2> /dev/null 1> /dev/null ### # If the specified filesystem name doesnt exist already, continue ### if [ ! -f /mnt/fatx/f/$name ]; then $important clear ### # Tell the user whats going on ### echo "$name will be created of size $size MB" echo "If this is not correct, press ctrl+c to cancel" echo -n "10 " && sleep 1 && echo -n "9 " && sleep 1 && echo -n "8 " && sleep 1 && echo -n "7 " && sleep 1 && echo -n "6 " && sleep 1 && echo -n "5 " && sleep 1 && echo -n "4 " && sleep 1 && echo -n "3 " && sleep 1 && echo -n "2 " && sleep 1 && echo -n "1 " && sleep 1 && echo "0 " && echo -e "Continuing..." && sleep 2 clear $busy echo "Making new filesystem..." sleep 5 ### # Make a blank loopback device ### dd if=/dev/zero of=/mnt/fatx/f/$name count=$size bs=1024k ### # Tell mke2fs "yes-to-all" and make the loopback device into a filesystem ### yes | mke2fs -j /mnt/fatx/f/$name tune2fs -c 0 /mnt/fatx/f/$name tune2fs -i 0 /mnt/fatx/f/$name mkdir /mnt/$name ### # Update fstab to automount the new filesystem # Then, make the mountpoint which is where the $name is used ### echo -e "/mnt/fatx/f/$name /mnt/$name ext3 loop,defaults 0 0" >> /etc/fstab mount /mnt/$name 2> /dev/null 1> /dev/null chmod 777 /mnt/$name 2> /dev/null 2> /dev/null clear echo "All done" echo -e "The partition has been mounted to /mnt/$name so you now have an extra" echo -e "$size MB of storage within linux. This image will be automounted on startup" $good exit 0 ### # If the newfs already exists, dont do anything ### else clear echo "Sorry, that file already exists, pick another name" $error exit 1 fi fi ### # Be sure the user resets before running this script to ensure that # the new fatx.o module is loaded ### if [ ! -z `grep -m1 -i fatx-patch1 /etc/conf.d/magic-database` ] && [ -z `grep -m1 -i newfs1 /etc/conf.d/magic-database` ]; then $important echo "It seems this is the first time you have run this script." echo "For safety reasons, the system will be rebooted first." echo "When your Xbox starts up again, please load Gentoox and" echo "then run magic newfs again" echo -n "Press enter to continue..." read echo newfs1 >> /etc/conf.d/magic-database chown root:root /etc/conf.d/magic-database chmod 600 /etc/conf.d/magic-database reboot exit 0 fi