Creating swapfile: swapon failure

Sorry for delay in reply - my newbie status on these forums limited number of replies per day, and then I forgot I had not posted the reply !

Got a little off topic but really glad you got it working without too much trouble :grin:

To bring the topic back to original subject title, I made a new encrypted swapfile the other day. Here is what I did for anyone who came here for that/interested:

First, preallocate space to the file. 8G represents 8gigs. Traditionally most use same as their ram:
fallocate -l 8G /cryptswap

then add this line below your encrypted partition line in /etc/crypttab:

cryptswap /cryptswap /dev/urandom swap

in /etc/fstab add this line:
/dev/mapper/cryptswap none swap sw 0 0

run:
mkswap /cryptswap

run:
service cryptdisks reload

run:
swapon -a

My swap file was active after rebooting.

Wanted to bring everything back to the title topic.

Now that you are running, Welcome to Parrot! :grin:

Thanks for bringing this back on topic
I ran the commands but did not get same outcome
See below

└──╼ #fallocate -l 8G /cryptswap
┌─[root@parrot]─[/home/phil]
└──╼ #mkswap /cryptswap
mkswap: /cryptswap: insecure permissions 0644, 0600 suggested.
Setting up swapspace version 1, size = 8 GiB (8589930496 bytes)
no label, UUID=d58cd47c-027a-465f-afce-b0bd9cf2fb29
┌─[root@parrot]─[/home/phil]
└──╼ #service cryptdisks reload
┌─[root@parrot]─[/home/phil]
└──╼ #swapon -a
swapon: cannot open /dev/mapper/cryptswap: No such file or directory
┌─[✗]─[root@parrot]─[/home/phil]
└──╼ #

I didn’t see if you had edited fstab & crypttab & just want to be sure you do edit them ahead of time.

Make sure to have added this line to /etc/crypttab:
cryptswap /cryptswap /dev/urandom swap

Make sure to add this line to /etc/fstab so it can keep swap for boot:
/dev/mapper/cryptswap none swap sw 0 0

rememeber to reboot

if you still have trouble finding /dev/mapper/cryptswap, try this to restart cryptdisks:
swapoff -a

/etc/init.d/cryptdisks start

swapon -a

swapon -s

then to check if /dev/mapper/cryptswap exists:

ls -al /dev/mapper

Let me know how it goes. Rebooting part is important :slightly_smiling_face:

This is now working
I followed the same procedure after undoing my previous changes. I had the same errors for cryptswap permissions and also for swapon -a not finding anything in /dev/mapper
I then followed your instructions to restart cryptdisks (not forgetting the reboot step at the appropriate juncture) and now all is well, another problem solved - thanks, brilliant.

I am now heading over to write up my Tor-launcher experience, not so positive unfortunately

1 Like

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.