tazusb diff tazusb @ rev 13

Add command gen-swap
author Christophe Lincoln <pankso@slitaz.org>
date Thu Mar 13 00:31:11 2008 +0100 (2008-03-13)
parents 1a64f0e814c0
children cf3cb5310f4c
line diff
     1.1 --- a/tazusb	Thu Mar 13 00:05:10 2008 +0100
     1.2 +++ b/tazusb	Thu Mar 13 00:31:11 2008 +0100
     1.3 @@ -30,7 +30,8 @@
     1.4    		tazSupported compression: lzma. gzip, none.
     1.5    format	Format and label device with ext3 filesystem 
     1.6                  (for LiveUSB or /home).
     1.7 -  gen-liveusb 	Generate a bootable LiveUSB using files from the LiveCD.\n"
     1.8 +  gen-liveusb 	Generate a bootable LiveUSB using files from the LiveCD.
     1.9 +  gen-swap      Creat or recreat and active additionnal swap memory.\n"
    1.10  }
    1.11  
    1.12  # Status function.
    1.13 @@ -269,6 +270,35 @@
    1.14  	fi
    1.15  }
    1.16  
    1.17 +# Generate a virtual swap file in /home/swap. SliTaz boot script 
    1.18 +# will active it, usefull for low memory system
    1.19 +gen_swap_file()
    1.20 +{
    1.21 +	echo ""
    1.22 +	echo -en "\033[1mGen swap\033[0m
    1.23 +===============================================================================
    1.24 +Generate a swap file in /home/swap that will be activate on each boot to have
    1.25 +more memory available (Empty value to exit).
    1.26 +
    1.27 +Swap file in Mb : "
    1.28 +	read size
    1.29 +	if [ -z "$size" ]; then
    1.30 +		echo -e "\nEmpty value. Exiting...\n"
    1.31 +		exit 0
    1.32 +	fi
    1.33 +	cd /home
    1.34 +	# Sanity check
    1.35 +	if [ -f swap ]; then
    1.36 +		swapoff swap 2>/dev/null
    1.37 +	fi
    1.38 +	# DD to gen a virtual disk.
    1.39 +	dd if=/dev/zero of=swap bs=1M count=$size
    1.40 +	# Make swap filesystem.
    1.41 +	mkswap swap
    1.42 +	swapon swap
    1.43 +	echo ""
    1.44 +}
    1.45 +
    1.46  #
    1.47  # Tazusb sequence
    1.48  #
    1.49 @@ -398,6 +428,10 @@
    1.50  		install_boot
    1.51  		exit_or_reboot
    1.52  		;;
    1.53 +	gen-swap)
    1.54 +		check_root
    1.55 +		gen_swap_file
    1.56 +		;;
    1.57  	usage|*)
    1.58  		# Display usage by default.
    1.59  		usage