View previous topic :: View next topic |
Author |
Message |
ct85711 Veteran
![Veteran Veteran](/images/ranks/rank_rect_5_vet.gif)
Joined: 27 Sep 2005 Posts: 1791
|
Posted: Mon Nov 06, 2017 3:26 am Post subject: Resizing btrfs for swap |
|
|
I am unsure on what I should do, so I am hoping for some advice. I am needing to either make a swap file or swap partition for my system (already setup). The issue I am encountering, is the only partition I have room to allocate for the swap, but it is a btrfs raid 5 partition (of 3 drives). Now I am aware, having swap on a btrfs fs is unsafe. I am at the point that I don't know if I can or how I can shrink a btrfs subvolume/device (I already shrunk the fs, so that is taken care of) or is it better to just wipe the btrfs and recreate the partion to ext4 (and create a swap partition).
Code: | /dev/sda1 /boot/efi vfat noatime 1 2
/dev/sdc1 / ext4 discard,noatime 0 1
/dev/sdc2 /home btrfs defaults 0 0
|
Note: /home is composed of /dev/sda2, dev/sdc2, and /dev/sdb1; sdb1 is the desired device that needs to be shrunk. (there is more than plenty of free space available, as in <25% is used).
Sadly, the root partition is too constrained on space to consider allocating space on that partition (I am frequently having to clear by space regularly as it is).
The raid 5 is setup only in btrfs and not through lvm, nor am I worried about keeping the raid 5 setup. I made that setup over 3 years ago for fun and have no requirement on sticking with btrfs any fashion. |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
Ant P. Watchman
![Watchman Watchman](/images/ranks/rank-G-2-watchman.gif)
Joined: 18 Apr 2009 Posts: 6920
|
Posted: Mon Nov 06, 2017 5:29 am Post subject: |
|
|
Look up the device ID of your sdb1 (the first number on the bottom line of this command's output):
Code: | # btrfs filesystem show /home/
[...]
devid 1 size xxx.yyGiB used [...] |
Use that to shrink it by 1.5-2x how much space you want for swap (it doesn't matter that this number is sloppy):
Code: | # btrfs filesystem resize $devid:-4G /home/ |
Run fdisk or cfdisk to shrink the end of that partition (by the amount you actually want to use for swap).
Create the swap partition, then verify it shows up in /dev/. You may need to use hdparm -z if fdisk doesn't refresh it automatically, but it should.
After that, fix the btrfs so it's not wasting space:
Code: | # btrfs filesystem resize $devid:max /home/ |
|
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
nokilli Apprentice
![Apprentice Apprentice](/images/ranks/rank_rect_2.gif)
![](images/avatars/20145535435516d33e4ff04.png)
Joined: 25 Feb 2004 Posts: 237
|
Posted: Mon Nov 06, 2017 8:59 am Post subject: Re: Resizing btrfs for swap |
|
|
ct85711 wrote: | Now I am aware, having swap on a btrfs fs is unsafe. |
The bigger issue is putting swap on a raid5. It's wrong on several levels.
Sometimes you just have to backup the system, reformat, and restore. You can still have the raid5. Just create standard partition tables for each disk, make one partition for swap (keeping in mind you'll have three and that you can have multiple swap partitions so they can be small) and the other for the raid array. _________________ We are the block device. The kernel is our client. |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|