ZXNet эхоконференция «zxnet.pc»


тема: Linux Windows OS/2... общий своп



от: Kirill Frolov
кому: All
дата: 08 Nov 2002
Hемедленно нажми на RESET, All! Как в винде NT сделать FORMAT C: до подключения свопа? Использовать боюсь, форматнёт что-нибудь... Где здесь ошибки? === Cut === #!/bin/sh # Use one FAT16 swap-partition(s) for Linux and other OS # example line for /etc/fstab: # /dev/hdaX none fatswap label=SWAPSPACE,serial=3D28F8E5 0 0 # 'label' and 'serial' is FAT16 filesystem label and serial number # serial number must be less than 7FFFFFFF because of bug in mkfs.msdos # FAT16 partition will be used as swap only if label and serial is correct # If you want to add new partitions to swap space edit /etc/fstab then # execute 'fatswap {start|stop} force' # send bugs to: Kirill.Frolov@p2.f827.n5030.z2.fidonet.org # update-rc.d fatswap start 11 S . stop 89 6 0 . (for debian) # print partition list of specified drive in form of "partition typename" function partlist() { fdisk -l $1 | sed -e "'^$1'!d;s/([^[:space:]]*)[[:space:]][^[:digit:]]*[[:digit:]]{1,}[^[:digit :]]{1,}[ [:digit:]]{1,}[^[:digit:]]{1,}[[:digit:]]{1,}[^[:digit:]]{1,}([[:digit :]]{1,} )[^[:space:]]*[[:space:]]{1,}(.*[^[:space:]])[[:space:]]*/1 3/" return ${PIPESTATUS[0]} } # print partition type of specified partition function parttype() { local x=$(echo $1 | sed -e 's/(.*)[[:digit:]]{1,}/1/') partlist $x | sed -e "'$1'!d;s/[^[:space:]]*[[:space:]]*([^[:space:]].*)/1/" return ${PIPESTATUS[0]} } # print serial number of FAT16 filesystem on specified partition function fatserial() { echo $(dd if=$1 bs=1 skip=39 count=4 2> /dev/null | od -A n -t x4) return ${PIPESTATUS[0]} } # print label of FAT16 filesystem on specified partition function fatlabel() { dd if=$1 bs=1 skip=43 count=11 2> /dev/null | sed -e 's/(.*[^[:space:]])[[:space:]]*/1/' return ${PIPESTATUS[0]} } # print filesystem name on specified FAT16 partition function fatfsname() { dd if=$1 bs=1 skip=54 count=8 2> /dev/null | sed -e 's/(.*[^[:space:]])[[:space:]]*/1/' return ${PIPESTATUS[0]} } # check if specified partition is linux swap or not function islnxswap() { test "$(dd if=$1 bs=1 count=10 skip=4086 2> /dev/null)" = "SWAPSPACE2" && return 0 # test "$(dd if=$1 bs=1 count=10 skip=4086 2> /dev/null)" = "SWAP_SPACE" && return 0 return 1 } # add swap on FAT16 drive, $1=device, $2=fat16label, $3=fat16serial, [$4="force"] function addfatswap() { echo -n "Adding [FAT]swap on $dev " if [ "$(parttype $1)" != "FAT16" ]; then echo "FAILED: partition type is not FAT16 at $1 !" return 1 fi if [ "$4" != "force" ]; then if [ "$(fatfsname $1)" != "FAT16" ]; then echo "FAILED: filesystem name is not FAT16 at $1 !" return 1 fi if [ -n "$2" -a "$(fatlabel $1)" != "$2" ]; then echo "FAILED: incorrect filesystem label at $1 !" return 1 fi if [ -n "$3" -a "$(fatserial $1)" != "$3" ]; then echo "FAILED: incorrect filesystem serial number at $1 !" return 1 fi fi if ! { mkswap -v1 "$1" && swapon "$1" ; } ; then echo "FAILED!" return 1 fi echo "OK." return 0 } # format all fatswaps $1=device, $2=label, $3=serial, # $4="force" to force creation of fat filesystem if linux swap signature not found function fatswapoff() { echo -n "Removing [FAT]swap from $1 " swapoff $1 2> /dev/null if swapoff -s | egrep "^$1[[:space:]]" ; then echo "FAILED! can't turn off swap." return 2 fi if [ "$(parttype $1)" != "FAT16" ]; then echo "FAILED: partition type is not FAT16 at $1 !" return 1 fi if ! islnxswap "$1" ; then local msg="can't find linux swap signature." if [ "$4" = "force" ]; then echo -n "WARNING! $msg " else echo "FAILED! $msg" return 1 fi fi if [ "$4" != "force" ]; then if [ "$(fatfsname $1)" != "FAT16" ]; then echo "FAILED: filesystem name is not FAT16 at $1 !" return 1 fi if [ -n "$2" -a "$(fatlabel $1)" != "$2" ]; then echo "FAILED: incorrect filesystem label at $1 !" return 1 fi if [ -n "$3" -a "$(fatserial $1)" != "$3" ]; then echo "FAILED: incorrect filesystem serial number at $1 !" return 1 fi fi if ! mkfs.msdos -n "$2" -i "$3" "$1" > /dev/null ; then echo "FAILED! can't create FAT filesystem." return 2 fi echo "OK." return 0 } # parse fatswap options function getfatswapopts() { unset label serial label=$(echo $opts | sed -e 's/.*(,|^)label=([^,[:space:]]*).*/2/;t;d') serial=$(echo $opts | sed -e 's/.*(,|^)serial=([^,[:space:]]*).*/2/;t;d') } # read /etc/fstab and activate all fatswaps, [$1="force"] function makefatswaps() { ( while read dev mnt type opts do case "$dev" in ""|#*) continue ;; *) if [ "$type" = "fatswap" ]; then getfatswapopts addfatswap "$dev" "$label" "$serial" "$1" fi ;; esac done ) < /etc/fstab } # read /etc/fstab and restore FAT16 filesystem on all fatswaps, [$1="force"] function restorefatswaps() { ( while read dev mnt type opts do case "$dev" in ""|#*) continue ;; *) if [ "$type" = "fatswap" ]; then getfatswapopts fatswapoff "$dev" "$label" "$serial" "$1" fi ;; esac done ) < /etc/fstab } case "$1" in start) makefatswaps $2 exit $? ;; stop) restorefatswaps $2 exit $? ;; *) echo "This script makes linux swap in place of FAT16 swap drives and vice versa." echo "Usage: $0 {start|stop} [force]" >&2 exit 1 ;; esac exit 0 === Cut ===




Темы: Игры, Программное обеспечение, Пресса, Аппаратное обеспечение, Сеть, Демосцена, Люди, Программирование

Похожие статьи:
Inferno - Авторы и контакты редакции.
Эпилог
Список BBS - Сетевые новости.
Поправки - опечатка в рубрике "Новость дня".
Вступление - содержание номера.

В этот день...   8 мая