elitak / nixos-infect

[GPLv3+] install nixos over the existing OS in a DigitalOcean droplet (and others with minor modifications)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Oracle Cloud Ampere instance dev-sda2.swap failed on nixos-rebuild switch

efim opened this issue · comments

commented

On the always free tier machine
Image: Oracle-Linux-7.9-aarch64-2021.10.20-0
Shape: VM.Standard.A1.Flex

Execution of the "nixos-infect" script is successful
But even right after the successful completion of the script

$ nixos-rebuils switch
leads to the following error:
building Nix...
building the system configuration...
updating GRUB 2 menu...
activating the configuration...
setting up /etc...
reloading user units for root...
setting up tmpfiles
warning: the following units failed: dev-sda2.swap

× dev-sda2.swap - Swap Partition
     Loaded: loaded (/run/systemd/generator.late/dev-sda2.swap; generated)
     Active: failed (Result: exit-code) since Sun 2021-12-12 13:03:32 UTC; 32ms ago
       What: /dev/sda2
       Docs: man:systemd-gpt-auto-generator(8)
         IP: 0B in, 0B out
        CPU: 4ms

Dec 12 13:03:32 instance-20211212-1554 systemd[1]: Activating swap Swap Partition...
Dec 12 13:03:32 instance-20211212-1554 swapon[1242]: swapon: /dev/sda2: swap format pagesize does not match. (Use --fixpgsz to reinitialize it.)
Dec 12 13:03:32 instance-20211212-1554 swapon[1242]: swapon: /dev/sda2: swapon failed: Invalid argument
Dec 12 13:03:32 instance-20211212-1554 systemd[1]: dev-sda2.swap: Swap process exited, code=exited, status=255/EXCEPTION
Dec 12 13:03:32 instance-20211212-1554 systemd[1]: dev-sda2.swap: Failed with result 'exit-code'.
Dec 12 13:03:32 instance-20211212-1554 systemd[1]: Failed to activate swap Swap Partition.
warning: error(s) occurred while switching to the new configuration

After a bit of studying I've attempted to recretate (?) swap file

$ swapon -af /dev/sda2
swapon: /dev/sda2: swap format pagesize does not match.
swapon: /dev/sda2: reinitializing the swap.
mkswap: /dev/sda2: warning: wiping old swap signature.
Setting up swapspace version 1, size = 8 GiB (8589930496 bytes)
no label, UUID=a4f9827d-d978-4837-ab36-31d09c83ad7d

$ nixos-rebuild switch
building Nix...
building the system configuration...
updating GRUB 2 menu...
activating the configuration...
setting up /etc...
reloading user units for root...
setting up tmpfiles

and all seems well

I don't know enough to understand whether this is something that can be addressed via script modification, or something that is inevitable.
In any case note on this experience could help anyone who might encounter similar issue

P.S. I have a lot of gratitude to the authors and supporters of this script, it is marvelous!

I am not having this issue, but @efim how you are able to log back into the instance after infection? There are no console gui for logging back in, and seems like the ssh key has been removed after infection?

commented

I was always able to successfully ssh into machines after the infection
And the key that I've specified during the creation was picked up by the script and added into config

I've been running the script several times for aarch and x86 machines in the past month

@efim Just tried again, and it worked if I am connecting with root(which is not permitted by the default image), instead of ubuntu. Sorry for hijacking and I will add that to README. Thanks for the reply.