#encrypted swap not working + screenshare on wayland

1 messages · Page 1 of 1 (latest)

whole pilot
#

hi

#

org.kde.xwaylandvideobridge: Could not select sources QDBusError("org.freedesktop.portal.Error.InvalidArgument", "Unavailable cursor mode 4")

#
DESKTOP-OUNAE5C /opt # dd if=/dev/zero of=swap count=8192 bs=1M 
8192+0 records in
8192+0 records out
8589934592 bytes (8.6 GB, 8.0 GiB) copied, 4.02722 s, 2.1 GB/s
DESKTOP-OUNAE5C /opt #  btrfs subvolume create swap_vol 
Create subvolume './swap_vol'
DESKTOP-OUNAE5C /opt # chattr +C swap_vol 
DESKTOP-OUNAE5C /opt # fallocate -l 8G swap_vol/swapfile 
DESKTOP-OUNAE5C /opt # chmod 600 swap_vol/swapfile 
DESKTOP-OUNAE5C /opt # swapon swap 
swapon: /opt/swap: insecure permissions 0644, 0600 suggested.
swapon: /opt/swap: read swap header failed
DESKTOP-OUNAE5C /opt # chmod 600 swap_vol/swapfile 
DESKTOP-OUNAE5C /opt # swapon swap 
swapon: /opt/swap: insecure permissions 0644, 0600 suggested.
swapon: /opt/swap: read swap header failed
DESKTOP-OUNAE5C /opt # ```
#
DESKTOP-OUNAE5C /opt # dd if=/dev/zero of=swap count=8192 bs=1M 
8192+0 records in
8192+0 records out
8589934592 bytes (8.6 GB, 8.0 GiB) copied, 4.02722 s, 2.1 GB/s
DESKTOP-OUNAE5C /opt #  btrfs subvolume create swap_vol 
Create subvolume './swap_vol'
DESKTOP-OUNAE5C /opt # chattr +C swap_vol 
DESKTOP-OUNAE5C /opt # fallocate -l 8G swap_vol/swapfile 
DESKTOP-OUNAE5C /opt # chmod 600 swap_vol/swapfile 
DESKTOP-OUNAE5C /opt # swapon swap 
swapon: /opt/swap: insecure permissions 0644, 0600 suggested.
swapon: /opt/swap: read swap header failed
DESKTOP-OUNAE5C /opt # chmod 600 swap_vol/swapfile 
DESKTOP-OUNAE5C /opt # swapon swap 
swapon: /opt/swap: insecure permissions 0644, 0600 suggested.
swapon: /opt/swap: read swap header failed
DESKTOP-OUNAE5C /opt # emerge -pv util-linux

These are the packages that would be merged, in order:

Calculating dependencies... done!
Dependency resolution took 2.13 s.

[ebuild   R    ] sys-apps/util-linux-2.39.1::gentoo  USE="(audit) (caps) cramfs cryptsetup hardlink logger ncurses nls pam readline (selinux) (split-usr) su suid (unicode) -build -fdformat -kill -magic -python (-rtas) -slang -static-libs -systemd -test -tty-helpers -udev -verify-sig" ABI_X86="32 (64) (-x32)" PYTHON_TARGETS="python3_11 -python3_10" 0 KiB

Total: 1 package (1 reinstall), Size of downloads: 0 KiB

 * IMPORTANT: 19 news items need reading for repository 'gentoo'.
 * Use eselect news read to view new items.

DESKTOP-OUNAE5C /opt # 
tardy crest
#

try ```sh
cryptsetup --type plain -d /dev/urandom open path_to_swapfile swap
mkswap path_to_swapfile
swapon path_to_swapfile

#

after creating the btrfs subvolume and the swapfile

#

"Then, edit /etc/fstab and either /etc/crypttab (if using systemd) or /etc/conf.d/dmcrypt (if using OpenRC) to automatically active the swap file: ..."

#

i think this swapon: /opt/swap: read swap header failed is because you didnt mkswap first

#

also im not sure what doing cryptsetup on the file will do if the whole partition is already encrypted maybe try w/o just mkswap

grave glen
whole pilot
#

Changed my username though

grave glen
#

ah I see

whole pilot
#

How would I undo all the steps I did already

#

Like creating the subvolume and stuff?

#
Btrfs subvolume delete swap_vol 
rm swap
swapoff swap```
#

Like that?

tardy crest
#

you probably dont need to undo that just pick up where the last thing worked

#

like the subvol is probably good

whole pilot
#

should there be two separate files btw? Swap and swapfile?

tardy crest
#

im not sure why there's the two files

#

im scared that the 'swap' file was created by cryptsetup as the "mapped name" idk what those args do

#

it does appear as if you've successfully made and mounted swap_vol/swapfile tho

#

maybe try cryptsetup again with swap_vol/swapfile as both the last args?

#

was it the cryptsetup command that created swap?

whole pilot
#

No, the dd if=swap command

tardy crest
#

oh okay

#

yeah thats just a zero file rn you can delete it

#

cuz it looks like the other things you did worked

#

i dont know how to check if cryptsetup worked like the command returned success

#

i dont know what the command does lol i just picked it out of the wiki

whole pilot
#

cryptsetup created an encrypted subvolume

tardy crest
#

the type of your swap is crypt from lsblk maybe thats a good indication

#

yeah nice

whole pilot
tardy crest
#

uhhh maybe

#

can you check if its functioning as swap

#

check top or something

#

see if you have swap

whole pilot
#

I do not see swap

tardy crest
#

hmm

#

cuz it looks like swapon worked

whole pilot
#

should this be in my /etc/crypttab btw?

tardy crest
#

i think so

#

"to automatically active the swap file" according to the wiki

whole pilot
#

and this in dmcrypt?

tardy crest
#

uh its one or the other

#

depending on your init

whole pilot
#

wait shad do you mean

#

oh

#

wait

#

I'm using openrc

tardy crest
#

ah the dmcrypt one then

whole pilot
#

ye

tardy crest
#

and you gotta enable the service

#

concerning rn tho is that the swapfile isnt working

#

maybe try swapon <file> again?

whole pilot
tardy crest
#

uh fuser /opt/swap_vol/swapfile ?

whole pilot
#

ran

tardy crest
#

returned nothing

#

hmm

#

wth

#

maybe try again but without cryptsetup

#

see if that gets you swap at least

#

i mean

#

delete swap_vol/swapfile

#

fallocate it again

#

and just swapon it

#

and see if that works as swap

whole pilot
#

alright 👍

#

rm: cannot remove 'swap_vol/swapfile': Operation not permitted

#

I think I'd have to swapoff everything

#

lemme try rebooting and see if everything works first

tardy crest
#

okay yeah

whole pilot
#

@tardy crest

tardy crest
#

uhhh yes lmao?

#

i mean its not gonna break anything important

#

yeah i think it was cryptsetup --type plain -d /dev/urandom open path_to_swapfile swap this that was wrong

#

and it should be cryptsetup --type plain -d /dev/urandom open path_to_swapfile path_to_swapfile

whole pilot
#

Ahh

tardy crest
#

maybe

whole pilot
#

Should I type no and then redo it?

tardy crest
#

nah you should type YES

#

and see what happens

#

maybe it works who knows

#

it looks like it almost wants to work

whole pilot
#

I might call it a night due to that jui jitsu injury plus I've got a headache but thank you for all the help

tardy crest
#

yeah np lmk if it works later or not

whole pilot
#

Do you think you would be able to help me out later today @tardy crest

tardy crest
#

yeah sure

whole pilot
tardy crest
#

yeah

whole pilot
#

ok

#

im online

tardy crest
#

aight sick

#

what did you do yesterday with the yes/no thing

#

did you end up checking it out

#

or going and restarting or something

#

@whole pilot

whole pilot
#

I don't think any of it ended up working

#

I just switched to my Gentoo system btw

#

From windows

tardy crest
#

ah okay

#

yeah id try to make the btrfs subvolume and fallocate the swapfile again

whole pilot
#

it's still up though so I've got to follow the steps in reverse

tardy crest
#

yeah just swapoff it and delete the swapfile

whole pilot
#

oh wait how exactly

tardy crest
#

maybe swapoff isnt needed

#

just delete the swapfile and fallocate a new one

#

then try to swapon it without cryptsetup-ing it so we know the btrfs stuff works

#

dont do the Encrypted Swap bit

whole pilot
#

im undoing the file stuff too

#

and restarting my laptop

tardy crest
#

lol fair enough

whole pilot
#

just so I don't have that partition up

#

like in lsblk

tardy crest
#

yee sure

whole pilot
#

ok

#

back to square one

#

I'm pulling up thw wiki @tardy crest

#

it'll probably show [swap] if I reboot

#

should I?

tardy crest
#

yeah im not sure if the subvolume/swapfile should appear as a block device

#

maybe not

#

swapon --show is a good sign that its worked

#

now you can try to decipher the crpytsetup command and make that work if you want

#

also id uh unify your boot partition

#

you dont need two partitions for a uefi boot system

#

like the 8gb partition is doing nothing (?) except being the mountpoint for another partition your actual esp

whole pilot
#
cd /opt
btrfs subvolume create swap_vol 
chattr +C swap_vol 
cd swap_vol
dd if=/dev/zero of=swap count=8192 bs=1M
cryptsetup --type plain -d /dev/urandom open swap swap 
mkswap swap 
chmod 600 swap 
swapon swap 
swapon --show
#
#/etc/fstab
/opt/swap_vol/swap none swap sw 0 0
tardy crest
#

yeah that looks about right actually

whole pilot
#
#/etc/conf.d/dmcrypt
swap=swap
source=/opt/swap_vol/swap
tardy crest
#

youll want a dmcrypt entry too to automatically activate it

whole pilot
#
rc-update add dmcrypt boot
#
# If you are only using local swap partitions, you should not change
# this file. Otherwise, you need to uncomment the below rc_before line
# followed by the appropriate rc_need line.
rc_before="!localmount"
#
# If you are using swap files stored on local file systems, uncomment
# this line.
rc_need="localmount"
#
# If you are using swap files stored on network file systems or swap
# partitions stored on network block devices such as iSCSI, uncomment
# this line.
#rc_need="netmount"
tardy crest
#

edit /etc/conf.d/dmcrypt as the wiki suggests

#

also

#

^^

whole pilot
tardy crest
#

oh you did post it yeah

#

yeah looks good 👌

whole pilot
#

alright, I have set it up

tardy crest
#

it works?

whole pilot
#

it was being weird

#

so

#

i got this once i unlocked my drive

#

then it said some weird stuff about hashing or something regarding swap

#

and then said dmcrypt failed to start

#

but now it started so idk

#

it's really weird

tardy crest
#

lol aight

#

semisuccess

whole pilot
#

also idk why it's giving me that modprobe error

#

I only ran modprobe once a really long time ago on that kernel module

#

this is in lsblk btw

#

no [swap]

#

when i run swapon --show it doesn't work btw

#

like

#

there's no output

#

meaning it's not being autostarted

#

i ran swapon /opt/swap_vol/swap and it shows up under it but I don't have much of a way of checking it

#

oh wait c:

#

so it works but it's not autostarted

whole pilot
#

Not sure how to fix the autostart

#

I might be able to take a picture of the error but it's only on the screen for a split second

whole pilot
#

@timber flame could you possibly take a look?

whole pilot
#

I shall share my screen momentarily

whole pilot
#

Btw not a vid but how would I fix this warning

#

Regarding modules

#

And then involving swap, I'm not sure what to do

#

Around where decrypt is

timber flame
#

@grave glen can you read for me please

grave glen
#

WARNING: The --hash parameter is being ignored in plain mode with keufile specified
WARNING: Device /opt/swap_vol/swap already contains a 'swap' superblock signature

Detected device signature(s) on /opt/swap_vol/swap. Proceeding further may damage existing data.

timber flame
#

I don’t think you were supposed to format it

#

Should have been an empty file

#

Or partition

whole pilot
#

#1134980581365665883 message

#

@timber flame this is what I had run

#

and then I have the files I edited and their contents up there too

#

you have to have it in a subvolume for btrfs and for encryption, you need the files that were specified

whole pilot
whole pilot
#

hello @timber flame are you possibly availible to look at it?

arctic talon
#

I don't think dmcrypt is the right place to setup (create) an encrypted block. If you're going to run a custom script anyway just create your own init script or call the script in local. Also why always recreate the block?

timber flame
#

He’s doing encrypted swap because if you don’t need hibernation it is simpler than putting it inside the luks container. Especially compared to swap files on btrfs.

Random encryption key at startup means you don’t need to store the key somewhere, which also reduces complexity.

arctic talon
#

Ok I see the point. The warnings can be probably be avoided by running a few dd writes against the existing block before create.

#

The "unable to erase bootable sectors" however needs to be reproduced in the command-line first.

#

The insmod errors on the other hand... I'm not sure how to fix them... it's odd that openrc doesn't use modprobe instead. Modprobe wouldn't complain if they're alreaded loaded. In this case they're already loaded as builtin.

timber flame
#

I wonder if this is what is happening

arctic talon
#

I think it's best to just avoid use of crypttab as well since it's just a disposable LUKS. Again better just create your own init.l script. You'll have full control over dependencies.

timber flame
#

Oh he formatted it as swap: use wipefs -a /dev/path/to/swap/partition

arctic talon
timber flame
#

Unable to erase bootable sectors

#

You are right this is too confusing

#

I dont know if hes on file or partition now

#

It worked when I did it but then again I always use wipefs when changing a disk around, and I didn’t try to mkswap partition

#

And it was not a file, making it a file on btrfs has the chattr +C requirement, and it has to be on it’s own subvolume because any subvolume containing a swap file btrfs will refuse to snapshot