LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   *BSD (http://www.linuxquestions.org/questions/%2Absd-17/)
-   -   Would a Linux swap partition work as a FreeBSD swap partition? (http://www.linuxquestions.org/questions/%2Absd-17/would-a-linux-swap-partition-work-as-a-freebsd-swap-partition-4175467537/)

Froggy192 06-26-2013 11:18 PM

Would a Linux swap partition work as a FreeBSD swap partition?
 
I understand that a single linux swap partition could work as a swap partition for multiple distros, but could I use the same partition as a FreeBSD swap partition?

bigrigdriver 06-26-2013 11:34 PM

Sharing swap space between Linux and FreeBSD

Froggy192 06-28-2013 11:34 AM

I read through it, and I can't seem to...

Quote:

...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
Well, I actually did find /etc/init/rc-sysinit.conf, but there's no indication of anything swap-related in it. Would I need to add everything in there myself, or is the swapon in another file?

bigrigdriver 06-28-2013 01:50 PM

Since Debian (my OS) and Mint are closely related, the file I find in Debian which seems to have the code to turn swap on is /etc/init.d/checkroot.sh. Look for this block of code:
Code:

/etc/init.d/checkroot.sh-      if [ "$ENABLE_SWAP" = yes ]
/etc/init.d/checkroot.sh-      then
/etc/init.d/checkroot.sh-              if [ "$VERBOSE" = no ]
/etc/init.d/checkroot.sh-              then
/etc/init.d/checkroot.sh-                      log_action_begin_msg "Activating swap"
/etc/init.d/checkroot.sh:                      swapon -a -e >/dev/null 2>&1
/etc/init.d/checkroot.sh-                      log_action_end_msg $?
/etc/init.d/checkroot.sh-              else
/etc/init.d/checkroot.sh-                      log_daemon_msg "Activating swap"
/etc/init.d/checkroot.sh:                      swapon -a -v
/etc/init.d/checkroot.sh-                      log_end_msg $?
/etc/init.d/checkroot.sh-              fi
/etc/init.d/checkroot.sh-      fi

In that block you wil find the swapon -a command (swapon -a -e >/dev/null 2>&1) referred to in the instructions.

I have found other references to swap in /etc, but they refer to running swapon again (note that "again" implies swap should be running, but we run swapon again "just in case" it isn't).

Froggy192 06-28-2013 04:03 PM

I've looked for that file, and it doesn't exist in my system and I haven't modified it in any way related to this. I do have two other files titled "checkroot.sh.conf" and "checkroot-bootclean.sh.conf" that reside in /etc/init, but they have nothing close to what you've got - they're almost empty.

Also, I've tried to find any file with "swapon" in it without any success, although my swap works perfectly fine.

bigrigdriver 06-28-2013 06:21 PM

This is the command I used to search through /etc for any file with the word "swapon" in the file.

Code:

find /etc -type f | xargs grep -A 5 -B 5 -i swapon
I hope this produced useful results for you.

Froggy192 06-28-2013 07:47 PM

I used this to try to do the same thing, although nothing showed up at all:

Code:

rgrep -i swapon /etc
And this is the output of what you used:

Code:

neutrino ~ # find /etc -type f | xargs grep -A 5 -B 5 -i swapon
grep: /etc/NetworkManager/system-connections/Auto: No such file or directory
grep: W782k4p: No such file or directory
grep: /etc/skel/.config/chromium/Local: No such file or directory
grep: State: No such file or directory
grep: /etc/skel/.config/chromium/Safe: No such file or directory
grep: Browsing: No such file or directory
grep: Cookies-journal: No such file or directory
grep: /etc/skel/.config/chromium/Safe: No such file or directory
grep: Browsing: No such file or directory
grep: Bloom: No such file or directory
grep: /etc/skel/.config/chromium/Safe: No such file or directory
grep: Browsing: No such file or directory
grep: Cookies: No such file or directory
grep: Provider: No such file or directory
grep: Cache: No such file or directory
grep: /etc/skel/.config/chromium/Default/Current: No such file or directory
grep: Session: No such file or directory
grep: /etc/skel/.config/chromium/Default/Network: No such file or directory
grep: Action: No such file or directory
grep: Predictor-journal: No such file or directory
grep: /etc/skel/.config/chromium/Default/Current: No such file or directory
grep: Tabs: No such file or directory
grep: /etc/skel/.config/chromium/Default/Session: No such file or directory
grep: Storage/LOCK: No such file or directory
grep: /etc/skel/.config/chromium/Default/Session: No such file or directory
grep: Storage/CURRENT: No such file or directory
grep: /etc/skel/.config/chromium/Default/Session: No such file or directory
grep: Storage/000003.log: No such file or directory
grep: /etc/skel/.config/chromium/Default/Session: No such file or directory
grep: Storage/MANIFEST-000002: No such file or directory
grep: /etc/skel/.config/chromium/Default/Session: No such file or directory
grep: Storage/LOG: No such file or directory
grep: /etc/skel/.config/chromium/Default/Archived: No such file or directory
grep: History-journal: No such file or directory
grep: /etc/skel/.config/chromium/Default/Visited: No such file or directory
grep: Links: No such file or directory
grep: /etc/skel/.config/chromium/Default/Web: No such file or directory
grep: Data: No such file or directory
grep: /etc/skel/.config/chromium/Default/Origin: No such file or directory
grep: Bound: No such file or directory
grep: Certs: No such file or directory
grep: /etc/skel/.config/chromium/Default/Managed: No such file or directory
grep: Mode: No such file or directory
grep: Settings: No such file or directory
grep: /etc/skel/.config/chromium/Default/Login: No such file or directory
grep: Data-journal: No such file or directory
grep: /etc/skel/.config/chromium/Default/Top: No such file or directory
grep: Sites: No such file or directory
grep: /etc/skel/.config/chromium/Default/Network: No such file or directory
grep: Action: No such file or directory
grep: Predictor: No such file or directory
grep: /etc/skel/.config/chromium/Default/Archived: No such file or directory
grep: History: No such file or directory
grep: /etc/skel/.config/chromium/Default/Login: No such file or directory
grep: Data: No such file or directory
grep: /etc/skel/.config/chromium/Default/User: No such file or directory
grep: StyleSheets/Custom.css: No such file or directory
grep: Index: No such file or directory
grep: 2013-05: No such file or directory
grep: /etc/skel/.config/chromium/Default/Web: No such file or directory
grep: Data-journal: No such file or directory
grep: /etc/skel/.config/chromium/Default/Top: No such file or directory
grep: Sites-journal: No such file or directory
grep: /etc/skel/.config/chromium/Default/Origin: No such file or directory
grep: Bound: No such file or directory
grep: Certs-journal: No such file or directory
grep: /etc/skel/.config/chromium/First: No such file or directory
grep: Run: No such file or directory
grep: /etc/skel/.config/chromium/Safe: No such file or directory
grep: Browsing: No such file or directory
grep: Bloom: No such file or directory
grep: Filter: No such file or directory
grep: 2: No such file or directory
grep: /etc/skel/.config/chromium/Service: No such file or directory
grep: State: No such file or directory
grep: /etc/skel/.mozilla/firefox/Crash: No such file or directory
grep: Reports/InstallTime20110422203143: No such file or directory

I'm not quite sure what happened here.

Firerat 06-28-2013 08:07 PM

Maybe it is just me, but I don't like sharing swap

Not that I do it very often,
but I like the option of hibernating and starting where I left once done with what I dual booted.

Firerat 06-28-2013 08:15 PM

Quote:

Originally Posted by Froggy192 (Post 4980527)
I used this to try to do the same thing, although nothing showed up at all:

Code:

rgrep -i swapon /etc
And this is the output of what you used:

Code:

neutrino ~ # find /etc -type f | xargs grep -A 5 -B 5 -i swapon
grep: /etc/NetworkManager/system-connections/Auto: No such file or directory
grep: W782k4p: No such file or directory
grep: /etc/skel/.config/chromium/Local: No such file or directory
grep: State: No such file or directory

I'm not quite sure what happened here.

You have spaces in the Dir names

try
Code:

find /etc -type f -exec grep -H -A 5 -B 5 -i swapon {} ';'
Edit: added -H to the grep to print filename

Froggy192 06-28-2013 09:16 PM

Quote:

Originally Posted by Firerat (Post 4980536)
You have spaces in the Dir names

try
Code:

find /etc -type f -exec grep -H -A 5 -B 5 -i swapon {} ';'
Edit: added -H to the grep to print filename

This works, but it doesn't find anything either.

Strange... do I not have anything that causes 'swapon'?

Firerat 06-28-2013 10:29 PM

Quote:

Originally Posted by Froggy192 (Post 4980554)
This works, but it doesn't find anything either.

Strange... do I not have anything that causes 'swapon'?

try to work out what is happening ;)

i.e. follow the boot process

/etc/rc.*.d

are your different runlevels,
the files in there are just sysmlinks to /etc/init.d/
have a read of those scripts
You can ignore things like network, you are interested in mounting things

vorbote 07-27-2013 02:06 PM

All those hacks are not needed.
 
I'll necrobump this thread a bit to make an observation: The hack described in comment 2 is old, very old. As in completely useless advice from last century.

The fact is that since version 8, FreeBSD can mount and use a GNU/Linux formatted swap partition by simply adding the partition to the fstab file. This from personal experience. The only thing you must be careful about is to not boot FreeBSD if you have hibernated Linux previously as this will erase the hibernate file written to the swap partition, but that applies to any other Linux distro that may be installed in the same system.


All times are GMT -5. The time now is 04:50 AM.