动态网站制作指南
[  QQ表情  ]
[ 投票调查 ]
[ 企业邮箱 ]
[ 网站空间 ]
网络编程 | 站长之家 | 网页制作 | 图形图象 | 操作系统 | 冲浪宝典 | 软件教学 | 网络办公 | 邮件系统 | 网络安全 | 认证考试 | 系统进程
ASP源码 | .Net源码 | PHP源码 | JSP源码 | JAVA源码 | CGI源码 | VB源码 | C++源码 | Delphi源码 | PB源码 | VF源码 | 汇编 | 服务器
电脑书籍下载:程序设计书籍 | 数据库教程书籍 | 平面与多媒体书籍 | 网络通讯书籍 | 系统管理书籍 | 网络安全书籍 | 认证考试书籍
Firefox | IE | Maxthon | 迅雷 | 电驴 | BitComet | FlashGet | QQ | QQ空间 | Vista | 输入法 | Ghost | Word | Excel | wps | Powerpoint
asp | .net | php | jsp | Sql | c# | Ajax | xml | Dreamweaver | FrontPages | Javascript | css | photoshop | fireworks | Flash | Cad | Discuz!
当前位置 > 网站建设学院 > 操作系统 > Linux教程
文章搜索服务
邮件订阅
输入你的邮件地址,
你将不会错过任何关于:
[ Linux教程 ]的信息

本月文章推荐
.Linux 开机程序之研讨.
.Linux 指令篇:DOS相容指令--mlab.
.读核日记(六).
.Fedora8系统Gnome桌面环境下安装.
.在Linux系统下实验SMB网络协议具.
.起步走 二十五步跟我搞定Linux系.
.Ubuntu公司宣布提供6.10支持的截.
.配置linux与win2000/XP/NT 双重引.
.最新Linux内核:更好的Wi-Fi和文.
.Linux操作系统下远程登录Windows.
.Linux下C开发环境的构成和安装.
.Linux管理员手册(9)--Keeping Ti.
.Linux网络环境下如何玩转GMail信.
.删除Linux后如何找回Windows启动.
.优化Linux系统硬盘的七个实用技巧.
.Linux 网管 123 --- 第7章. 自订.
.磁带驱动器的使用.
.如何使用命令trap来捕捉信号?.
.Linux系统下使用Windows XP字体美.
.Redhat9.0 下DNS配置笔记.

Linux 和 Windows 共享交换区

文章类别:Linux教程 | 发表日期:2005-4-15 |


1. 前言 
      现在,越来越多的人在一台使用Linux 和 Windows. 这应该说是Linux的胜利. 我们知
      道, Linux 要使用交换分区, 
      Windows 要使用交换文件。如果一台PIII, 有192M 内存,我们分配给Linux 192M 交换
      区, Windows 2000 至少要 
      200M. 那么,我们要用近400M硬盘空间。如果交换区更大,浪费就更可观了。 
      由于两个系统的交换区都只是运行时的临时数据,所以,我们采用动态修改分区信息的方法
      来达到共享目的. 

      2. 方法简介 
      1). 备份Windows 分区信息。 
      2). 当启动Linux时, 将该分区做成Linux 交换区,并将其激活。 
      3) 当Linux 关闭时,将该分区重新变成Windows 交换区。 

      3. 具体步骤 
      1). 分区 
      Fdisk, 只分主分区, 不分扩展分区 
      2). 安装 Windows. 
      3). 安装Linux (占一个主分区) 
      4). 在Linux 下, 分扩展分区) 
      5). 设定Linux交换区(假定/dev/hda10) 
      6). 建立winswap 设备 
      ln -s /dev/hda10 /dev/winswap 
      7). 启动Linux, 关闭交换区 
      # swapoff -a 
      8). 从文件安装表中删除该分区 
      vi /etc/fstab 
      注释掉该行 (/dev/hda10) 
      9). 将该分区该成 FAT16 或其他 DOS 分区. 
      10). 启动 Windows 
      a). 格式化该分区 
      b). 将系统的交换文件设在该分区. 
      11). 启动 Linux, 计算Total Special Sectors 
      公式: 
      T = r + (s * f) + (d / 16) 
      参数: 
      Reserved Sectors at beginning : r 
      FAT Copies : f 
      Sectors per FAT : s 
      Root directory entries : d 
      参见: msinfo.sh 
      注解: 可以运行 msinfo.sh 来获得. 
      # msinfo.sh /dev/hda10 

      12). 备份Windows 分区信息 
      # dd if=/dev/winswap bs=512 count=XXX | gzip -9 > /etc/winswap.gz 
      这里, XXX = T 
      14). 编写启动, 退出脚本, 并把它们放在 /etc/rc.d/xxx. 
      可用 grep -nr * | grep swapon (或 swapoff) 来找系统激活和关闭交换区, 将它们
      替换称我们 
      的脚本) 
      我们在附录中提供了启动和关闭的脚本. 
      4. 附加说明 
      1. 本文使用的是FAT16, 如果使用NTFS 或其它, 必须修改脚本. 
      2. mkswap /dev/winswap 377496 (这个值需要修改, 依照你的分区大小) 

      5. 参考资料: 
      Linux HOWTO: Swap-space 

      6. 附录 -- 相应的脚本 
      1. msinfo.sh 脚本 
      #!/bin/sh 
      # 
      # msinfo.sh This shell script displays the boot sector of the 
      # given partition. 
      # 
      # Author: Rahul U. Joshi 
      # 
      # Modifications Removed the use of expr and replaced it by the let 
      # command. 


      # check for command line arguments 
      if [ $# -ne 1 ]; then 
      echo "Usage: msinfo " 
      exit 1 
      fi 

      # check whether the input name is a block device 
      if [ ! -b $1 ]; then 
      echo "msinfo: $1 is not a block device" 
      exit 1 
      fi 

      # create two temporary files for use 
      TMPFILE=`mktemp -q /tmp/$0.XXXXXX` 
      if [ $? -ne 0 ]; then 
      echo "msinfo: Can't create temp file, exiting..." 
      exit 1 
      fi 

      TXTFILE=`mktemp -q /tmp/$0.XXXXXX` 
      if [ $? -ne 0 ]; then 
      echo "msinfo: Can't create temp file, exiting..." 
      rm -f $TMPFILE 
      exit 1 
      fi 

      back_title="`printf "%78s" "msinfo, Information about FAT16 filesystem --
      Rahul 
      Joshi"`" 

      dialog --title "Boot sector of $1" --backtitle "$back_title" --infobox
      "\nAnalysing boot sector for $1\nPlease wait ..." 14 60 

      # truncate TXTFILE to zero length 
      echo > $TXTFILE 

      # get Formatting DOS version 
      dd 2>/dev/null if=$1 bs=1 count=8 skip=3 | dd 2>/dev/null of=$TMPFILE 
      printf >>$TXTFILE "%30s : %s\n" "Formatting DOS version" "`cat $TMPFILE`"


      # get file system 
      dd 2>/dev/null if=$1 bs=1 count=8 skip=54 | dd 2>/dev/null of=$TMPFILE 
      printf >>$TXTFILE "%30s : %s\n" "Filesystem" "`cat $TMPFILE`" 

      # check if filesystem in a FAT16 
      if [ "`cat $TMPFILE`" != "FAT16 " ]; then 
      dialog --title "Boot sector of $1" --backtitle "$back_title" --infobox
      "\nCan't find a FAT16 filesystem on $1" 14 60 
      exit 2 
      fi 

      # get volume label in boot sector 
      dd 2>/dev/null if=$1 bs=1 count=11 skip=43 | dd 2>/dev/null of=$TMPFILE 
      printf >>$TXTFILE "%30s : %s\n" "Volume label in boot sector" "`cat
      $TMPFILE`" 

      # get Sector size 
      dd 2>/dev/null if=$1 bs=1 count=2 skip=11| od -An -tdS | dd 2>/dev/null
      of=$TMPFILE 
      printf >>$TXTFILE "%30s : %d\n" "Sector size" `cat $TMPFILE` 
      sector_size=`cat $TMPFILE` 


      # get Reserved sectors 
      dd 2>/dev/null if=$1 bs=1 count=2 skip=14| od -An -tdS | dd 2>/dev/null
      of=$TMPFILE 
      printf >>$TXTFILE "%30s : %d\n" " Reserved sectors" `cat $TMPFILE` 
      reserved_sectors=`cat $TMPFILE` 


      # get FAT sectors 
      dd 2>/dev/null if=$1 bs=1 count=1 skip=16| od -An -tdS | dd 2>/dev/null
      of=$TMPFILE 
      fat_count=`cat $TMPFILE` 

      dd 2>/dev/null if=$1 bs=1 count=2 skip=22| od -An -tdS | dd 2>/dev/null
      of=$TMPFILE 
      sectors_per_fat=`cat $TMPFILE` 

      # calculate the no of sectors allocated for FAT's 
      let fat_sectors=fat_count*sectors_per_fat 

      printf >>$TXTFILE "%30s : %u (%u x %u) \n" "FAT sectors" "$fat_sectors"
      "$fat_count" "$sectors_per_fat" 


      # get root directory sectors 
      dd 2>/dev/null if=$1 bs=1 count=2 skip=17| od -An -tdS | dd 2>/dev/null
      of=$TMPFILE 
      root_sectors=`cat $TMPFILE` 

      # calculate the no of sectors allocated for root directory 
      let root_sectors=root_sectors*32/sector_size 

      printf >>$TXTFILE "%30s : %u\n" "Root directory sectors" "$root_sectors" 


      # get Total special sectors 
      let total=reserved_sectors+fat_sectors+root_sectors 
      printf >>$TXTFILE "%30s : %u\n" "Total special sectors" "$total" 

      # display the information in a message box 
      dialog --title "Boot sector of $1" --backtitle "$back_title" --msgbox
      "`cat $TXTFILE`" 14 60 

      # delete temporary files 
      rm -f $TMPFILE 
      rm -f $TXTFILE 

      # end of msinfo.sh 

      2. swapinit.sh 
      #!/bin/sh 
      # 
      # /etc/rc.d/init.d/swapinit.sh - activate the swap partition 
      # 
      # written by Rahul U. Joshi 
      # Verify and initialize swap space 
      # 

      echo -n 'Verifying swap space... ' 

      loopcount=0 

      # flag to indicate whether the partition has been activated or not 
      activated=0 

      # check for signatures 6 times before giving up 
      while [ $loopcount -lt 6 ] 
      do 
      if [ "`/bin/dd 2>/dev/null if=/dev/winswap bs=1 count=10 skip=4086`" =
      'SWAPSPACE2' ]; then 

      echo "Linux signature found, iteration $loopcount" 
      echo "Activating swap partitions" 
      swapon /dev/winswap 
      activated=1 
      break 

      elif [ "`/bin/dd 2>/dev/null if=/dev/winswap bs=1 count=5 skip=54`" =
      'FAT16' ]; then 
      echo "DOS signature found, iteration $loopcount" 
      echo "Making swap partition" 
      mkswap /dev/winswap 377496 
      echo "Activating swap partitions" 
      swapon /dev/winswap 
      activated=1 
      break 

      else 
      let loopcount=loopcount+1 
      fi 

      done 


      if [ $activated -ne 1 ] ; then 
      echo "Swap signature not found after $loopcount tries" 
      echo "No swapping partitions activated" 
      exit 1 
      fi 

      3. swaphalt.sh 
      #!/bin/sh 
      # 
      # /etc/rc.d/init.d/swapinit.sh - activate the swap partition 
      # 
      # written by Rahul U. Joshi 
      # Verify and initialize swap space 
      # 

      echo -n 'Verifying swap space... ' 

      loopcount=0 

      # flag to indicate whether the partition has been activated or not 
      activated=0 

      # check for signatures 6 times before giving up 
      while [ $loopcount -lt 6 ] 
      do 
      if [ "`/bin/dd 2>/dev/null if=/dev/winswap bs=1 count=10 skip=4086`" =
      'SWAPSPACE2' ]; then 

      echo "Linux signature found, iteration $loopcount" 
      echo "Activating swap partitions" 
      swapon /dev/winswap 
      activated=1 
      break 

      elif [ "`/bin/dd 2>/dev/null if=/dev/winswap bs=1 count=5 skip=54`" =
      'FAT16' ]; then 
      echo "DOS signature found, iteration $loopcount" 
      echo "Making swap partition" 
      mkswap /dev/winswap 377496 
      echo "Activating swap partitions" 
      swapon /dev/winswap 
      activated=1 
      break 

      else 
      let loopcount=loopcount+1 
      fi 

      done 


      if [ $activated -ne 1 ] ; then 
      echo "Swap signature not found after $loopcount tries" 
      echo "No swapping partitions activated" 
      exit 1 
      fi

上一篇:LINUX引导过程 人气:8531
下一篇:Linux中文件查找技术大全 人气:9881
点击此处浏览全部Linux的内容 Dreamweaver插件下载 常用网页广告代码全集
  最新网站源码 最新软件下载
2008-5-16 轩溪下载系统 v3.78 build 0515
2008-5-16 普沙B2B 浙江省商贸网 v2.0
2008-5-16 asp抓蜘蛛的小程序 v1.0
2008-5-16 齐齐乐网私服发布站 仿haosf新版
2008-5-16 IssTech信息反馈系统 v1.0
2008-5-16 自由领域大头贴(js接口版) 修正版
2008-5-16 医院网站系统
2008-5-15 bBlog v0.7.6
2008-5-15 team论坛 v2.0.3 SQL
2008-5-7 Windows XP SP3 官方英文版
2008-5-7 Windows XP SP3 官方香港中文版
2008-5-7 Windows XP SP3 官方繁体中文版
2008-5-7 Windows XP SP3 官方简体中文版
2008-4-30 Multiple Unzip Wizard 1.02
2008-4-30 Multiple Unrar Wizard 1.0.0
2008-4-30 WinZip Install/Try/Uninstall a
2008-4-30 ZIP压缩文件修复器WzipFix 2.0
2008-4-30 Pentazip 6.01 Build 189 For Wi
  发表评论
姓 名: 验证码: [ 全部贴吧 ] [ 浏览评论 ]
内 容:
[ 汉字翻译拼音 ] [ 广告代码 ] [ 符号对照表 ] [ 进制转换 ] [ 经典小工具 ] [ 个税计算 ] [ 汉字简繁转换 ] [ 普通单位换算 ] [ 公制单位换算 ]
[ 生辰老黄历 ] [ 国内电话区号 ] [ 国家代码与域名缩写 ] [ 文字加密解密 ] [ 健康查询 ] [ 万年历 ] [ 手机号码查询 ] [ ip搜索 ] [ Google PR查询 ]
业务联系 | 广告刊登 | 频道合作 | 投稿荐稿 | 联系方式 | 加入收藏 | RSS订阅
Copyright © 2000-2008 www.knowsky.com All rights reserved | 网络实名:动态网站制作指南 | 沪ICP备05001343号
ホームページ制作 不動産検索システム 求人情報