免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 3563 | 回复: 5
打印 上一主题 下一主题

freebsd能和linux共用swap吗? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-06-11 22:23 |只看该作者 |倒序浏览
不懂,问一下,呵呵

[ 本帖最后由 wblue 于 2008-6-11 22:24 编辑 ]

论坛徽章:
0
2 [报告]
发表于 2008-06-12 07:11 |只看该作者
文件系统不同

论坛徽章:
2
2015年迎新春徽章
日期:2015-03-12 10:39:39IT运维版块每日发帖之星
日期:2015-10-10 06:20:00
3 [报告]
发表于 2008-06-12 14:44 |只看该作者
觉得应该能共用,解决好文件区码格式

论坛徽章:
0
4 [报告]
发表于 2008-06-12 16:05 |只看该作者
我也一样,认为可以!不过,我没有试过!

论坛徽章:
0
5 [报告]
发表于 2008-06-13 22:17 |只看该作者

回复 #1 wblue 的帖子

google了一下找到了一些,不过是不是真行,就不知道了
3. Sharing swap space between Linux and FreeBSD

This section describes how I got Linux and FreeBSD to share a swap partition. There may be other ways to get the same result. You can install FreeBSD before Linux if you want to, just pay attention to the order of the partitions in the FreeBSD slice.

3.1 Installing and preparing Linux

The first step is to install Linux as normal. You have to leave space for the FreeBSD slice at your hard drive. You don't have to make a Linux swap partition, but if you want one, put it in the space you want to allocate for FreeBSD. That way you can delete the Linux swap partition later and use the space for FreeBSD.

When you have installed Linux you have to build a new kernel. Read The Linux Kernel HOWTO if this is new to you. You have to include both UFS filesystem support (read only) and BSD disklabel (FreeBSD partition tables) support:

UFS filesystem support (read only) (CONFIG_UFS_FS) [N/y/m/?] y
BSD disklabel (FreeBSD partition tables) support (CONFIG_BSD_DISKLABEL) [N/y/?]
(NEW) y

Install the new kernel and reboot. Remove any line including the word swap from your /etc/fstab file if you have made a Linux swap partition. Make sure you have a working Linux boot floppy with the new kernel. Now you are ready to install FreeBSD.

3.2 Installing FreeBSD

Install FreeBSD as described in the FreeBSD documentation. Remove the Linux swap partition if you have made one (you can use the FreeBSD fdisk program.) Pay attention to the order of the partitions in the FreeBSD slice. If you use the default labelling the second partition will be the swap partition. Complete the installation of FreeBSD and reboot into Linux using the new Linux boot floppy.

3.3 Setting up the FreeBSD swap partition in Linux

Run dmesg when you have booted into Linux. In the output you should see something like this:

Partition check:
hda: hda1 hda2 hda3 hda4 < hda5 hda6 hda7 hda8 >

This means that /dev/hda4 is your FreeBSD slice, while /dev/hda5, /dev/hda6, /dev/hda7 and /dev/hda8 are the FreeBSD partitions. If your swap partition is the second partition in the slice, it will be /dev/hda6.

You have to put the following line into your Linux /etc/fstab file to enable the swap partition:

/dev/hda6       none            swap            sw              0       0

While FreeBSD can use any type of partition as swap space, Linux needs a special signature in the swap partition. This signature is made by mkswap. FreeBSD ruins this signature when it uses the shared swap partition, so you will have to run mkswap each time you boot into Linux. To do this automagically you have to find the script that runs swapon at boot time. In Red Hat Linux it is /etc/rc.d/rc.sysinit. Put the following line into that file just before swapon -a:

awk -- '/swap/ && ($1 !~ /#/) { system("mkswap "$1"" }' /etc/fstab

This will run mkswap on any swap partitions in /etc/fstab every time you boot except if they are commented out (having ``#'' as the first character in the line.)

Run free to check out the size of the swap space when you have rebooted into Linux. You should also reboot into FreeBSD to make sure everything works as expected. If it does not, you have probably used the wrong partition as swap partition. The only solution to that problem is to reinstall FreeBSD and try again. Experience is a great teacher.



3、在Linux和FreeBSD系统上共享swap空间

  这个部分描述了如何使用Linux和FreeBSD来共享一个swap空间。有几种不同的方法可以实现它。如果你愿意,你可以在Linux安装之前安装FreeBSD,只是需要注意FreeBSD slice的分区顺序。

  3.1.1安装Linux

  第一步是正常安装Linux。你必须在硬盘上留下一些空间作为FreeBSD的slice。你不必分出一个Linux swap分区,但是如果你需要一个,将其放在你为FreeBSD安排的空间中。这个方法可以使你在以后使用FreeBSD的空间时,删除 Linuxswap分区。

  当你安装了Linux后,你必须重新编译一个新的内核。如果不熟悉,请读一下Linux kernel HOWTO。你必须在内核中包入UFS文件系统支持(只读)和BSD磁盘标记(FreeBSD分区表)支持:


UFS filesystem support (read only) (CONFIG_UFS_FS) [N/y/m/?] y
BSD disklabel (FreeBSD partition tables) support (CONFIG_BSD_DISKLABEL) [N/y/?]
(NEW) y

  安装新内核和重新启动。如果你建立了一个Linux swap分区,则需要在/etc/fstab文件中的将任何一行包括swap的关键字的行删除。确定你一个可以以新的内核工作的启动软盘。现在你可以安装FreeBSD了。

  3.2 安装FreeBSD

  遵照FreeBSD的文档,安装FreeBSD。如果你已经建立了一个swap分区,则删除Linux的swap分区,(你可以使用 FreeBSD的fdisk程序)注意在FreeBSD分区中的顺序。如果你使用默认方式来标记,则第二个分区将被建立为swap分区。完成安装后,使用新Linux内核的软盘,重新启动系统。

  3.3在Linux中设置FreeBSD的swap分区

  如果已经以Linux启动了,就运行dmesg命令。显示可能是:


  Partition check:
   hda: hda1 hda2 hda3 hda4 < hda5 hda6 hda7 hda8 >

  这就意味着/dev/hda4是你的FreeBSD slice,当/dev/hda5,/dev/hda6,/dev/hda7并且/dev/hda8是FreeBSD分区。如果你的swap分区是在slice中的第二个分区,它可以是/dev/hda6。

  你必须在/etc/fstab文件中放入以下行内容,以使swap分区工作:

/dev/hda6       none            swap            sw              0       0

  当FreeBSD可以使用任何一种类型的分区作为swap分区,Linux需要一个特别的标记在这个swap分区中。这个标记被mkswap程序所建立。FreeBSD会在其使用这个共享的swap分区时删除这个标记,所以你将必须每次进入Linux后,运行mkswap。为了使其可以自动运行,你必须在启动时运行swapon的脚本程序。在Red Hat Linux它们是/etc/rc.d/rc.sysinit。在下面一行放在这个文件的swapon -a之前:

  awk -- '/swap/ && ($1 !~ /#/) { system("mkswap "$1"" }' /etc/fstab

  在每次你启动时,这将会在/etc/fstab文件中的每个swap分区都被mkswap操作一次,除非被注释的行。(#是注释符号)

论坛徽章:
0
6 [报告]
发表于 2008-06-14 06:40 |只看该作者
NetBSD可以
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP