QQ登录

只需一步,快速开始

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1719|回复: 17

FreeBSD能否和Linux共享swap分区???

[复制链接]
发表于 2006-5-27 15:35:26 | 显示全部楼层 |阅读模式
无意中发现有这个说法,不知可不可行,来这确认一下,谢谢
发表于 2006-5-27 15:40:21 | 显示全部楼层
毫无疑问


可以
回复

使用道具 举报

 楼主| 发表于 2006-5-27 17:23:20 | 显示全部楼层
谢谢,

这下可以省下500M的空间了,
回复

使用道具 举报

发表于 2006-5-27 18:35:30 | 显示全部楼层
可以吗?


怀疑一下
回复

使用道具 举报

发表于 2006-5-27 20:11:27 | 显示全部楼层
毫无疑问的不可以,理由懒得说了,自己看看freebsd handbook的分区那一章后就知道为什么了
回复

使用道具 举报

发表于 2006-5-27 20:22:18 | 显示全部楼层
在启动脚本里 mkswap ?
回复

使用道具 举报

发表于 2006-5-27 22:25:10 | 显示全部楼层
[quote:68fa404bb2="jozhu"]毫无疑问的不可以,理由懒得说了,自己看看freebsd handbook的分区那一章后就知道为什么了[/quote]
讨教下
回复

使用道具 举报

发表于 2006-5-27 22:43:17 | 显示全部楼层
我们有个好朋友叫做 Google   

3. Sharing swap space between Linux and FreeBSD

最后再赞一下:自由操作系统无所不能!
回复

使用道具 举报

发表于 2006-5-27 22:51:39 | 显示全部楼层
[code:1]
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. :-)
[/code:1]
谢谢kuye
回复

使用道具 举报

发表于 2006-5-27 22:58:24 | 显示全部楼层
  
原来可以这样做。。。忘了LINUX可以挂载FREEBSD分区的。
回复

使用道具 举报

 楼主| 发表于 2006-5-27 23:42:02 | 显示全部楼层
恩,
我刚刚试过了,可以

谢谢大家,:       
回复

使用道具 举报

发表于 2006-5-27 23:45:45 | 显示全部楼层
实践出真知。
回复

使用道具 举报

 楼主| 发表于 2006-5-28 00:00:01 | 显示全部楼层
[quote:d58e224074="npcomet"]实践出真知。[/quote]

经典 :D  :D
回复

使用道具 举报

发表于 2006-5-28 00:19:03 | 显示全部楼层
嗯,上标题的当啦。。
回复

使用道具 举报

 楼主| 发表于 2006-5-28 00:32:58 | 显示全部楼层
  
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

GMT+8, 2024-11-14 00:54 , Processed in 0.044221 second(s), 15 queries .

© 2021 Powered by Discuz! X3.5.

快速回复 返回顶部 返回列表