Re: Adding file swap on btrfs

2022-12-23 Thread Chris Murphy
FWIW there are some fixes and enhancements coming in btrfs-progs 6.1, now in 
koji for Rawhide, including making it easier to get info about hibernation file 
offset in a swapfile.

I haven't messed with the new subcommand, but I personally prefer putting 
swapfiles in their own subvolume so that I can still snapshot the root 
subvolume. Snapshotting a subvolume containing a swapfile will render the 
swapfile invalid for use (or maybe the snapshot fails, not sure, haven't tried 
recently).

The way I do this is mount the top-level of the file system (just do a normal 
mount without any options), and inside you'll see what appears to be two 
directories: root and home. Those are the subvolumes the installer creates by 
default. Create a new subvolume in here and add it to fstab such that:

UUID=$fsuuid /var/swap   btrfs   noatime,subvol=swap 0 0

I use chattr +C on this swap subvolume, that way any new files created inside 
will inherit. This is something the new subcommand will do for you.

An additional entry in fstab:
/var/swap/swapfile1 none swap defaults 0 0

You can certainly make a nested /var/swap thereby avoiding the need to create 
the earlier fstab entry. But note that snapshots still don't have this nested 
subvolume in them, so if you do a rollback it also won't have the nested swap 
subvolume or file - thus you boot probably hangs because the fstab is looking 
for this swapfile to activate and never finds it. So I just do it the way I 
describe, that way I can more or less forget about it. But an alternative to 
that, if you really prefer nested, is s/defaults/nofail/ for the swapfile entry 
and now a missing swap won't cause boot to fail *but* you also may one day 
forget all this and come to realize that there's no swap activated because you 
once did a rollback way back when... :D


--
Chris Murphy
___
users mailing list -- users@lists.fedoraproject.org
To unsubscribe send an email to users-le...@lists.fedoraproject.org
Fedora Code of Conduct: 
https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: 
https://lists.fedoraproject.org/archives/list/users@lists.fedoraproject.org
Do not reply to spam, report it: 
https://pagure.io/fedora-infrastructure/new_issue


Re: Adding file swap on btrfs

2022-12-19 Thread Barry


> On 19 Dec 2022, at 19:59, Neal Becker  wrote:
> 
> 
> I've just installed f37 on a new lenovo x1 carbon.
> One thing, the installation didn't setup any swap (other than zswap).
> 

That is the preferred way to setup swap. Research has shown that
use of swap files on HDD or SSD is far worse then using the zswap in almost
all desktop workloads.

My advice is to not bother adding a swap file, you are very unlikely to ever 
need it.

Barry



> After a bit of reading I found
> sudo btrfs filesystem mkswapfile -s 32G /swapfile
> But:
>  sudo swapon -v /swapfile 
> swapon: /swapfile: found signature [pagesize=4096, signature=swap] 
> swapon: /swapfile: pagesize=4096, swapsize=1073741824, devsize=34359738368
> 
> Although I created 32G swapfile, only 1G is used.
> swapon 
> NAME   TYPE   SIZE USED PRIO 
> /dev/zram0 partition8G 6.3M  100 
> /swapfile  file  1024M   0B   -2
> 
> 
> What's wrong?
> 
> Thanks,
> Neal
> ___
> users mailing list -- users@lists.fedoraproject.org
> To unsubscribe send an email to users-le...@lists.fedoraproject.org
> Fedora Code of Conduct: 
> https://docs.fedoraproject.org/en-US/project/code-of-conduct/
> List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
> List Archives: 
> https://lists.fedoraproject.org/archives/list/users@lists.fedoraproject.org
> Do not reply to spam, report it: 
> https://pagure.io/fedora-infrastructure/new_issue
___
users mailing list -- users@lists.fedoraproject.org
To unsubscribe send an email to users-le...@lists.fedoraproject.org
Fedora Code of Conduct: 
https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: 
https://lists.fedoraproject.org/archives/list/users@lists.fedoraproject.org
Do not reply to spam, report it: 
https://pagure.io/fedora-infrastructure/new_issue


Re: Adding file swap on btrfs

2022-12-19 Thread Samuel Sieb

On 12/19/22 12:19, Jonathan Billings wrote:


On Dec 19, 2022, at 15:10, Samuel Sieb  wrote:


On 12/19/22 11:58, Neal Becker wrote:

I've just installed f37 on a new lenovo x1 carbon.
One thing, the installation didn't setup any swap (other than zswap).
After a bit of reading I found
sudo btrfs filesystem mkswapfile -s 32G /swapfile
But:
 sudo swapon -v /swapfile
swapon: /swapfile: found signature [pagesize=4096, signature=swap]
swapon: /swapfile: pagesize=4096, swapsize=1073741824, 
devsize=34359738368

Although I created 32G swapfile, only 1G is used.
swapon
NAME   TYPE   SIZE USED PRIO
/dev/zram0 partition    8G 6.3M  100
/swapfile  file  1024M   0B   -2
What's wrong?


Something is wrong with how it creates the swap format.  Just run 
"mkswap /swapfile" and it will be


I totally missed the size discrepancy.

I believe in new btrfs versions, you can use:

# btrfs filesystem mkswapfile swapfile
# swapon swapfile


That's what he did, but the swapfs on the volume had the wrong size.  So 
a simple run of mkswap fixes that.  It's still the same volume with all 
the same attributes, just different data.

___
users mailing list -- users@lists.fedoraproject.org
To unsubscribe send an email to users-le...@lists.fedoraproject.org
Fedora Code of Conduct: 
https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: 
https://lists.fedoraproject.org/archives/list/users@lists.fedoraproject.org
Do not reply to spam, report it: 
https://pagure.io/fedora-infrastructure/new_issue


Re: Adding file swap on btrfs

2022-12-19 Thread Jonathan Billings

On Dec 19, 2022, at 15:10, Samuel Sieb  wrote:
> 
> On 12/19/22 11:58, Neal Becker wrote:
>> I've just installed f37 on a new lenovo x1 carbon.
>> One thing, the installation didn't setup any swap (other than zswap).
>> After a bit of reading I found
>> sudo btrfs filesystem mkswapfile -s 32G /swapfile
>> But:
>>  sudo swapon -v /swapfile
>> swapon: /swapfile: found signature [pagesize=4096, signature=swap]
>> swapon: /swapfile: pagesize=4096, swapsize=1073741824, devsize=34359738368
>> Although I created 32G swapfile, only 1G is used.
>> swapon
>> NAME   TYPE   SIZE USED PRIO
>> /dev/zram0 partition8G 6.3M  100
>> /swapfile  file  1024M   0B   -2
>> What's wrong?
> 
> Something is wrong with how it creates the swap format.  Just run "mkswap 
> /swapfile" and it will be  

I totally missed the size discrepancy. 

I believe in new btrfs versions, you can use:

# btrfs filesystem mkswapfile swapfile
# swapon swapfile

https://btrfs.readthedocs.io/en/latest/Swapfile.html

Otherwise you need to set the No_COW attribute with `chattr +C 
/path/to/swap/directory`. 

--
Jonathan Billings___
users mailing list -- users@lists.fedoraproject.org
To unsubscribe send an email to users-le...@lists.fedoraproject.org
Fedora Code of Conduct: 
https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: 
https://lists.fedoraproject.org/archives/list/users@lists.fedoraproject.org
Do not reply to spam, report it: 
https://pagure.io/fedora-infrastructure/new_issue


Re: Adding file swap on btrfs

2022-12-19 Thread Samuel Sieb

On 12/19/22 12:13, Richard Shaw wrote:
On Mon, Dec 19, 2022 at 2:10 PM Samuel Sieb > wrote:


On 12/19/22 11:58, Neal Becker wrote:
 > I've just installed f37 on a new lenovo x1 carbon.
 > One thing, the installation didn't setup any swap (other than zswap).
 >
 > After a bit of reading I found
 > sudo btrfs filesystem mkswapfile -s 32G /swapfile
 > But:
 >   sudo swapon -v /swapfile
 > swapon: /swapfile: found signature [pagesize=4096, signature=swap]
 > swapon: /swapfile: pagesize=4096, swapsize=1073741824,
devsize=34359738368
 >
 > Although I created 32G swapfile, only 1G is used.
 > swapon
 > NAME   TYPE   SIZE USED PRIO
 > /dev/zram0 partition    8G 6.3M  100
 > /swapfile  file  1024M   0B   -2
 >
 >
 > What's wrong?

Something is wrong with how it creates the swap format.  Just run
"mkswap /swapfile" and it will be fine.


Not quite, without the chattr +C it will still perform COW file 
operations which you don't want on large files.


It's still the same device that was created by the btrfs tool.  I just 
ran the mkswap formatting tool to fix the swap size.

___
users mailing list -- users@lists.fedoraproject.org
To unsubscribe send an email to users-le...@lists.fedoraproject.org
Fedora Code of Conduct: 
https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: 
https://lists.fedoraproject.org/archives/list/users@lists.fedoraproject.org
Do not reply to spam, report it: 
https://pagure.io/fedora-infrastructure/new_issue


Re: Adding file swap on btrfs

2022-12-19 Thread Richard Shaw
On Mon, Dec 19, 2022 at 2:10 PM Samuel Sieb  wrote:

> On 12/19/22 11:58, Neal Becker wrote:
> > I've just installed f37 on a new lenovo x1 carbon.
> > One thing, the installation didn't setup any swap (other than zswap).
> >
> > After a bit of reading I found
> > sudo btrfs filesystem mkswapfile -s 32G /swapfile
> > But:
> >   sudo swapon -v /swapfile
> > swapon: /swapfile: found signature [pagesize=4096, signature=swap]
> > swapon: /swapfile: pagesize=4096, swapsize=1073741824,
> devsize=34359738368
> >
> > Although I created 32G swapfile, only 1G is used.
> > swapon
> > NAME   TYPE   SIZE USED PRIO
> > /dev/zram0 partition8G 6.3M  100
> > /swapfile  file  1024M   0B   -2
> >
> >
> > What's wrong?
>
> Something is wrong with how it creates the swap format.  Just run
> "mkswap /swapfile" and it will be fine.
>

Not quite, without the chattr +C it will still perform COW file operations
which you don't want on large files.

Thanks,
Richard
___
users mailing list -- users@lists.fedoraproject.org
To unsubscribe send an email to users-le...@lists.fedoraproject.org
Fedora Code of Conduct: 
https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: 
https://lists.fedoraproject.org/archives/list/users@lists.fedoraproject.org
Do not reply to spam, report it: 
https://pagure.io/fedora-infrastructure/new_issue


Re: Adding file swap on btrfs

2022-12-19 Thread Jonathan Billings
On Dec 19, 2022, at 14:59, Neal Becker  wrote:

> I've just installed f37 on a new lenovo x1 carbon.
> One thing, the installation didn't setup any swap (other than zswap).
> 
> After a bit of reading I found
> sudo btrfs filesystem mkswapfile -s 32G /swapfile
> But:
>  sudo swapon -v /swapfile 
> swapon: /swapfile: found signature [pagesize=4096, signature=swap] 
> swapon: /swapfile: pagesize=4096, swapsize=1073741824, devsize=34359738368
> 
> Although I created 32G swapfile, only 1G is used.
> swapon 
> NAME   TYPE   SIZE USED PRIO 
> /dev/zram0 partition8G 6.3M  100 
> /swapfile  file  1024M   0B   -2
> 
> 
> What's wrong?

This is pretty much expected behavior. 

Your zram swap device has a priority of 100, the swap file of -2. 

See the swap(2) man page:
https://linux.die.net/man/2/swapon

Basically, you want to have swapped pages in the compressed memory device, it 
is much faster and essentially is expanding available RAM. If memory pressure 
gets high enough it will use your swap file, but unlikely unless your system is 
really thrashing. 

--
Jonathan Billings___
users mailing list -- users@lists.fedoraproject.org
To unsubscribe send an email to users-le...@lists.fedoraproject.org
Fedora Code of Conduct: 
https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: 
https://lists.fedoraproject.org/archives/list/users@lists.fedoraproject.org
Do not reply to spam, report it: 
https://pagure.io/fedora-infrastructure/new_issue


Re: Adding file swap on btrfs

2022-12-19 Thread Samuel Sieb

On 12/19/22 11:58, Neal Becker wrote:

I've just installed f37 on a new lenovo x1 carbon.
One thing, the installation didn't setup any swap (other than zswap).

After a bit of reading I found
sudo btrfs filesystem mkswapfile -s 32G /swapfile
But:
  sudo swapon -v /swapfile
swapon: /swapfile: found signature [pagesize=4096, signature=swap]
swapon: /swapfile: pagesize=4096, swapsize=1073741824, devsize=34359738368

Although I created 32G swapfile, only 1G is used.
swapon
NAME   TYPE   SIZE USED PRIO
/dev/zram0 partition    8G 6.3M  100
/swapfile  file  1024M   0B   -2


What's wrong?


Something is wrong with how it creates the swap format.  Just run 
"mkswap /swapfile" and it will be fine.

___
users mailing list -- users@lists.fedoraproject.org
To unsubscribe send an email to users-le...@lists.fedoraproject.org
Fedora Code of Conduct: 
https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: 
https://lists.fedoraproject.org/archives/list/users@lists.fedoraproject.org
Do not reply to spam, report it: 
https://pagure.io/fedora-infrastructure/new_issue


Re: Adding file swap on btrfs

2022-12-19 Thread Neal Becker
On Mon, Dec 19, 2022 at 2:58 PM Neal Becker  wrote:

> I've just installed f37 on a new lenovo x1 carbon.
> One thing, the installation didn't setup any swap (other than zswap).
>
> After a bit of reading I found
> sudo btrfs filesystem mkswapfile -s 32G /swapfile
> But:
>  sudo swapon -v /swapfile
> swapon: /swapfile: found signature [pagesize=4096, signature=swap]
> swapon: /swapfile: pagesize=4096, swapsize=1073741824, devsize=34359738368
>
> Although I created 32G swapfile, only 1G is used.
> swapon
> NAME   TYPE   SIZE USED PRIO
> /dev/zram0 partition8G 6.3M  100
> /swapfile  file  1024M   0B   -2
>
>
> What's wrong?
>
> Thanks,
> Neal
>

Something wrong with btrfs filesystem mkswap.  If I do it the old-fashioned
way:

# truncate -s 0 swapfile# chattr +C swapfile# fallocate -l 2G
swapfile# chmod 0600 swapfile# mkswap swapfile# swapon swapfile

It works correctly
___
users mailing list -- users@lists.fedoraproject.org
To unsubscribe send an email to users-le...@lists.fedoraproject.org
Fedora Code of Conduct: 
https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: 
https://lists.fedoraproject.org/archives/list/users@lists.fedoraproject.org
Do not reply to spam, report it: 
https://pagure.io/fedora-infrastructure/new_issue


Adding file swap on btrfs

2022-12-19 Thread Neal Becker
I've just installed f37 on a new lenovo x1 carbon.
One thing, the installation didn't setup any swap (other than zswap).

After a bit of reading I found
sudo btrfs filesystem mkswapfile -s 32G /swapfile
But:
 sudo swapon -v /swapfile
swapon: /swapfile: found signature [pagesize=4096, signature=swap]
swapon: /swapfile: pagesize=4096, swapsize=1073741824, devsize=34359738368

Although I created 32G swapfile, only 1G is used.
swapon
NAME   TYPE   SIZE USED PRIO
/dev/zram0 partition8G 6.3M  100
/swapfile  file  1024M   0B   -2


What's wrong?

Thanks,
Neal
___
users mailing list -- users@lists.fedoraproject.org
To unsubscribe send an email to users-le...@lists.fedoraproject.org
Fedora Code of Conduct: 
https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: 
https://lists.fedoraproject.org/archives/list/users@lists.fedoraproject.org
Do not reply to spam, report it: 
https://pagure.io/fedora-infrastructure/new_issue