Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 17 May 2015 02:53:54 +1000 (EST)
From:      Ian Smith <smithi@nimnet.asn.au>
To:        Avinash Sonawane <rootkea@gmail.com>
Cc:        Warren Block <wblock@wonkity.com>, freebsd-questions@freebsd.org
Subject:   Re: Swap partition for FreeBSD
Message-ID:  <20150517010804.E69409@sola.nimnet.asn.au>
In-Reply-To: <mailman.65.1431777601.2454.freebsd-questions@freebsd.org>
References:  <mailman.65.1431777601.2454.freebsd-questions@freebsd.org>

Next in thread | Previous in thread | Raw E-Mail | Index | Archive | Help
In freebsd-questions Digest, Vol 571, Issue 6
On Sat, 16 May 2015 15:16:56 +0530 Avinash Sonawane <rootkea@gmail.com> wrote:

Avinash, I'm cutting various bits out of this digest, because I can :)

In response to Matthew Seaman <matthew@freebsd.org> you wrote:

 > When I tried to delete the said partition from freebsd as `gpart
 > delete -i 2878773 ada0s4` it says "gpart: pre-check failed: Operation

-i there shouldn't be a block number, from my reading of gpart(8) on 
9.3, but I'm not sure how exactly delete ada0s6 should be crafted, if 
it's possible with your kernel as is (below).  (yoo hoo, Warren!)

 > canceled". So I booted to Debian and deleted that partition using
 > Gparted and then when I tried to create freebsd-swap in FreeBSD (from
 > previously freed 8GB) as `gpart add -t freebsd-swap -b 181362690
 > ada0s4` it again said "gpart: pre-check failed: Operation canceled"
 > 
 > After searching a bit on the web I came to know that default kernel
 > build options specify "options GEOM_PART_EBR_COMPAT" which prevents
 > GEOM from editing EBR partition schemes. So to create a partition of
 > type freebsd-swap in extended partition it looks like I need to
 > recompile the kernel without the GEOM_PART_EBR_COMPAT kernel option.
 > 
 > Any other way beside this?

Possibly not - and it's not clear to me from descriptions in gpart(8) 
that even if you just had GEOM_PART_EBR in kernel (see /sys/conf/NOTES)
that you will be able to access ada0s6, nor whether - even if you can, 
R/W, for data - that it would be supported for swap anyway.

Last time I used (then called) Extended Partitions was pre-GEOM and 
pre-FUSE, where a DEFAULT kernel with a compiled module worked fine 
mounting and reading NTFS and/or HPFS partitions - I had many of the 
latter from OS/2 to recover to UFS - when reading was fine but writing 
was 'experimental' and not then to be relied upon.

 > > There's no formatting required for a swap area: the system just uses it
 > > as a blob of available space and writes what it needs to.
 > 
 > Ok. But I am getting really annoyed by that error message during boot
 > and and a feeling that my 8GB freebsd swap partition won't be able to
 > store the kernel dumps.

Well ..

 > >> I was trying to build www/webkit-gtk3 (a dependency for x11/gnome3)
 > >> then it abruptly exited with "Out of swap space error" so I created a
 > >> separate 8GB partition to be used as freebsd-swap.
 > >
 > > Why don't use a regular file as swap?
 > 
 > Because I read somewhere that swap partition is much more faster than
 > swap file and given that I already have 4GB RAM and then too I was
 > posed with "out of RAM/swap space" like error (which I never
 > anticipated) I wanted a more and faster swap. So dedicated swap
 > partition.

In the long run, when you get this sorted out, sure, but meanwhile a 
swapfile is almost infinitely better than no swap at all :)

 > May be this will justify:
 > http://unix.stackexchange.com/a/2211

Sure, though there is some dispute there too .. worry about that later.

In response to Polytropon <freebsd@edvax.de> you wrote:

 > I have 4 Primary partitions. Out of which one ada0s1 has FreeBSD,
 > ada0s2 has Debian, ada0s3 is one extra Primary partition (which
 > currently holds data) and ada0s4 is an extended partition (to create
 > further logical partitions like linux-swap, data partitions etc.)

Understandable, with that mix of systems.

 > > Typically, you use _one_ "DOS primary partition" - in BSD
 > > called a slice - to carry the FreeBSD filesystems _and_ the
 > > swap partition, for example:
 > >
 > >         ada0s1a = /
 > >         ada0s1b = swap  <- not a separate slice!
 > >         ada0s1d = /tmp
 > >         ada0s1e = /var
 > >         ada0s1f = /usr
 > >         ada0s1g = /home

Unfortunately that sort of sub-partitioning is almost unknown now, as 
bsdinstall defaults to the usually totally inappropriate linux-style 
single / partition, requiring certain learned magic to install such a 
scheme.  You were bitten by this, as you have no part of ada0s1 that you 
can delete, or backup separately using dump & restore, and/or resize.

However the default install normally includes a swap partition too.

 > > With gpart or (the old-fashioned) fdisk, you would create
 > > the slice, then use bsdlabel to create the partitions inside
 > > that slice. Those that are _not_ swap partitions would then
 > > be formatted with a UFS file system; swap doesn't need to be
 > > formatted.

Even if using fdisk to create / manage slices, you are likely much 
better off using gpart -s bsd instead of bsdlabel thereafter - see: 
http://www.wonkity.com/~wblock/docs/html/disksetup.html

 > > It seems to be that way. Using "extended DOS partitions" has never
 > > been a good idea. :-)

Maybe not, but I may have headed into Linuxland without that support :)

 > I have Freebsd installed in ada0s1a so can I create ada0s1b inside
 > ada0s1 to have freebsd-swap? How do I do that?

With only a single / on that slice it's backup, redo the partitioning 
leaving room for swap, and restoring.  Good practice, anyway :)

 > Or should I create ada0s6b as swap partition inside ada0s6 slice?

I have serious doubts that will work - but you can try, for education :)

Another option perhaps, quoting from your http://pastebin.com/KSFM49yP

=======
#gpart show -p
=>       63  976773105    ada0  MBR  (466G)
         63  195035085  ada0s1  freebsd  [active]  (93G)
  195035148     718836          - free -  (351M)
  195753984  193753088  ada0s2  linux-data  (92G)
  389507072  191754240  ada0s3  linux-data  (91G)
  581261312       2046          - free -  (1.0M)
  581263358  395507714  ada0s4  ebr  (189G)
  976771072       2096          - free -  (1.0M)

=>        0  195035085   ada0s1  BSD  (93G)
          0  195035084  ada0s1a  freebsd-ufs  (93G)
  195035084          1           - free -  (512B)

=>        0  395507714  ada0s4  EBR  (189G)
          0  181362690  ada0s5  ntfs  (86G)
  181362690   16777216  ada0s6  linux-data  (8.0G)
  198139906  189368320  ada0s7  ntfs  (90G)
  387508226    7999488  ada0s8  linux-swap  (3.8G)
=======

Could ada0s2 be a bit (like 8GB) smaller?  If so you could backup - tar 
I guess - and delete ada0s2, extend ada0s1 - backed up, dumped from / 
and deleted - then readd ada0s2 and restore both.  Pretty messy unless 
you have somewhere handy to shunt such big backups, but I guess you do?

If you can rearrange any of your linux (or ntfs) space somewhat to suit 
FreeBSD's (at least) reticence to use anything on ada0s4, you should be 
able to get something reasonable.  Otherwise yes you'll need to fit swap 
into ada0s1 93GB - however you should be able to share common data with 
either linux-data slice; not at all sure about accessing ntfs on EBR ..

cheers, Ian



Want to link to this message? Use this URL: <http://docs.FreeBSD.org/cgi/mid.cgi?20150517010804.E69409>