From owner-freebsd-questions@freebsd.org Thu Dec 29 13:37:49 2016 Return-Path: Delivered-To: freebsd-questions@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 28571C89898 for ; Thu, 29 Dec 2016 13:37:49 +0000 (UTC) (envelope-from freebsd@edvax.de) Received: from mailrelay10.qsc.de (mailrelay10.qsc.de [212.99.163.152]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "*.antispameurope.com", Issuer "TeleSec ServerPass DE-2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id A20F91101 for ; Thu, 29 Dec 2016 13:37:48 +0000 (UTC) (envelope-from freebsd@edvax.de) Received: from mx01.qsc.de ([213.148.129.14]) by mailrelay10.qsc.de; Thu, 29 Dec 2016 14:37:57 +0100 Received: from r56.edvax.de (port-92-195-28-64.dynamic.qsc.de [92.195.28.64]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx01.qsc.de (Postfix) with ESMTPS id 2F4213CC3F; Thu, 29 Dec 2016 14:37:43 +0100 (CET) Received: from r56.edvax.de (localhost [127.0.0.1]) by r56.edvax.de (8.14.5/8.14.5) with SMTP id uBTDbhiX004114; Thu, 29 Dec 2016 14:37:43 +0100 (CET) (envelope-from freebsd@edvax.de) Date: Thu, 29 Dec 2016 14:37:43 +0100 From: Polytropon To: Stari Karp Cc: FreeBSD Questions Subject: Re: swap partition Message-Id: <20161229143743.af8fd698.freebsd@edvax.de> In-Reply-To: <1483015755.95305.5.camel@yandex.com> References: <1483012420.95172.9.camel@yandex.com> <20161229130806.914b65a1.freebsd@edvax.de> <1483015755.95305.5.camel@yandex.com> Reply-To: Polytropon Organization: EDVAX X-Mailer: Sylpheed 3.1.1 (GTK+ 2.24.5; i386-portbld-freebsd8.2) Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-cloud-security-sender: freebsd@edvax.de X-cloud-security-recipient: freebsd-questions@freebsd.org X-cloud-security-Virusscan: CLEAN X-cloud-security-disclaimer: This E-Mail was scanned by E-Mailservice on mailrelay10.qsc.de with 0607068343B X-cloud-security-connect: mx01.qsc.de[213.148.129.14], TLS=1, IP=213.148.129.14 X-cloud-security: scantime:.2374 X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 29 Dec 2016 13:37:49 -0000 On Thu, 29 Dec 2016 07:49:15 -0500, Stari Karp wrote: > On Thu, 2016-12-29 at 13:08 +0100, Polytropon wrote: > > On Thu, 29 Dec 2016 06:53:40 -0500, Stari Karp wrote: > > >=20 > > > I like to increase swap partition but I am scary to screw up my > > > system. > > > FreeBSD is installed on iMac (Mountain Lion). > > >=20 > > > gpart show > > > =3D>=A0=A0=A0=A0=A0=A0=A0=A034=A0=A01953525101=A0=A0ada0=A0=A0GPT=A0= =A0(932G) > > > =A0=A0=A0=A0=A0=A0=A0=A0=A0=A034=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A06=A0= =A0=A0=A0=A0=A0=A0=A0- free -=A0=A0(3.0K) > > > =A0=A0=A0=A0=A0=A0=A0=A0=A0=A040=A0=A0=A0=A0=A0=A0409600=A0=A0=A0=A0= =A01=A0=A0efi=A0=A0(200M) > > > =A0=A0=A0=A0=A0=A0409640=A0=A01216587112=A0=A0=A0=A0=A02=A0=A0apple-h= fs=A0=A0(580G) > > > =A0 1216996752=A0=A0=A0=A0=A01269536=A0=A0=A0=A0=A03=A0=A0apple-boot= =A0=A0(620M) > > > =A0 1218266288=A0=A0=A0=A0=A0=A0=A0=A01024=A0=A0=A0=A0=A04=A0=A0freeb= sd-boot=A0=A0(512K) > > > =A0 1218267312=A0=A0=A0727710720=A0=A0=A0=A0=A05=A0=A0freebsd-ufs=A0= =A0(347G) > > > =A0 1945978032=A0=A0=A0=A0=A07547102=A0=A0=A0=A0=A06=A0=A0freebsd-swa= p=A0=A0(3.6G) > > > =A0 1953525134=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A01=A0=A0=A0=A0=A0=A0=A0= =A0- free -=A0=A0(512B) > > >=20 > > > What I planning to do: > > > Boot to OS X and than decrease apple-hfs partition for 64 GB. > > > Than boot to FreeBSD (single user) and: > > > swapoff -a > > > gpart resize -i6 ada0 > > > swapon -a > > >=20 > > > Do I need to use gpart resize -i6 -s 64G ada0 or gpart will find > > > empty > > > space and use it, please? > > I don't think this is possible. Partitions have to be coherent > > disk space. If I read your current layout correctly, shrinking > > ada0p2 (apple-hfs) would leave a "hole" before ada0p3 (apple-boot), > > but your swap space is ada0p6. > >=20 > > However, you can add a second swap space (and maybe even ignore > > your existing one), so the final layout could be this: > >=20 > > ada0p1=A0=A0efi=A0=A0(200M) > > ada0p2=A0=A0apple-hfs=A0=A0(580G - 64G) <--- shrink > > ada0p3=A0=A0freebsd-swap=A0=A0(64G) <--- create in "hole" > > ada0p4=A0=A0apple-boot=A0=A0(620M) > > ada0p5=A0=A0freebsd-boot=A0=A0(512K) > > ada0p6=A0=A0freebsd-ufs=A0=A0(347G) > > ada0p7=A0=A0freebsd-swap=A0=A0(3.6G) <--- maybe ignore > >=20 > > However, I don't have experience regarding partitioning on > > Mac OS X systems, but from a "logic point of view", this sounds > > reasonable. I'm also not sure if repartitioning will cause > > partition numbers to change, or if the offset and size will > > be assigned accordingly (so the new partition would become > > ada0p7). > >=20 > >=20 > >=20 > > >=20 > > > Should I format on OS X empty space to FAT? > > No, leave it untouched, "empty space", unallocated. A swap > > partition doesn't need a file system, in fact, is _has to be_ > > void of a file system. > >=20 > Resizing apple-hfs is not a problem, what I am scary more is changes of > partition numbers. Use labels, and you don't have to worry. Labels will keep consistent across partition number changes (or even device filename changes), they are a very convenient way to describe partitions. > It will be nice if I could add empty space to the > end. But according to your gpart output, there is not sufficient space left at the end. Partitions usually don't "shift down" after beging resized; instead, a "hole" is left. > I didn't ose OS X years and I need to check what can I do. I just > know that was easy when I shrink hfs for Installed FreeBSD. As Bernt Hansson suggested, you can use a file-based swap from within the FreeBSD partition: Allocate a 64 GB file and use it as swap file. So if you want additional 64 GB of swap file: # dd if=3D/dev/zero of=3D/usr/swap0 bs=3D1024m count=3D64 # chmod 0600 /usr/swap0 In /etc/fstab, add: md99 none swap sw,file=3D/usr/swap0,late 0 0 And finally activate it: # swapon -aL Source (ch. 11.12.2, ex 11.2): https://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/adding-swap-spac= e.html Note that FreeBSD can utilize more than one swap partition or swap file, so if you keep your existing swap partition, it will not interefere with an additional swap file on the UFS partition. See "man swapctl" for details. I'm doing something similar on SSDs using /etc/rc.local to allocate via a dummy file (no disk space is being used until there is actually anything written to swap): SWAP=3D"/ssdswap" /bin/rm -f $SWAP /bin/dd if=3D/dev/zero of=3D$SWAP bs=3D16m seek=3D500 count=3D0 /sbin/mdconfig -a -t vnode -u 0 -f $SWAP || /bin/sh /bin/chflags nodump $SWAP /bin/rm $SWAP /sbin/swapctl -a /dev/md0 Note the "count=3D0" in the dd call, and finally the "rm" call. The swap access will be performed using the memory disk virtual device, /dev/md0. And at shutdown time, cleaning up, via /etc/rc.shutdown.local: /sbin/swapctl -d /dev/md0 /sbin/mdconfig -d -u 0 But I'm not sure if it will work as good with HDDs in the same was as it does on SSDs. :-) --=20 Polytropon Magdeburg, Germany Happy FreeBSD user since 4.0 Andra moi ennepe, Mousa, ...