BTRFS accidentaly formated swap partition

Made the mistake of formatting my swap partition in windows when mistaking it for another drive. Looking into restoring it since I takes a lot longer to log in now and I am unsure what else if affected. Should i be more focused on a fresh install or is this salvageable?

For generation a new swap file, would involve just making a subvolume and ensure it is non-snapshotted? Btrfs - ArchWiki

Here is drive structure and my install is on /dev/nvme1n1 where /dev/nvme1n1p1 is my btrfs volume and /dev/nvme1n2 was where my swap used to be.

Disk /dev/sda: 476.94 GiB, 512110190592 bytes, 1000215216 sectors
Disk model: Samsung SSD 850
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xe88560ef

Device     Boot  Start        End    Sectors   Size Id Type
/dev/sda1  *      2048     206847     204800   100M  7 HPFS/NTFS/exFAT
/dev/sda2       206848 1000212479 1000005632 476.8G  7 HPFS/NTFS/exFAT


Disk /dev/sdb: 3.64 TiB, 4000787030016 bytes, 7814037168 sectors
Disk model: WDC WD4000FYYZ-0
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x292b151f

Device     Boot Start        End    Sectors Size Id Type
/dev/sdb1        2048 4294965247 4294963200   2T  7 HPFS/NTFS/exFAT


Disk /dev/nvme0n1: 1.82 TiB, 2000398934016 bytes, 3907029168 sectors
Disk model: Samsung SSD 970 EVO Plus 2TB
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 8EEF171A-98C3-4B47-B69C-AC553034F95C

Device           Start        End    Sectors  Size Type
/dev/nvme0n1p1    2048    1085439    1083392  529M Windows recovery environment
/dev/nvme0n1p2 1085440    1288191     202752   99M EFI System
/dev/nvme0n1p3 1288192    1320959      32768   16M Microsoft reserved
/dev/nvme0n1p4 1320960 3907026943 3905705984  1.8T Microsoft basic data


Disk /dev/nvme1n1: 465.76 GiB, 500107862016 bytes, 976773168 sectors
Disk model: Samsung SSD 970 EVO 500GB
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x96cbb0ea

Device         Boot Start       End   Sectors   Size Id Type
/dev/nvme1n1p1 *     2048 904424855 904422808 431.3G 83 Linux


Disk /dev/zram0: 31.3 GiB, 33603715072 bytes, 8204032 sectors
Units: sectors of 1 * 4096 = 4096 bytes
Sector size (logical/physical): 4096 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes

Are there anythings that i am missing or routes that would make more sense in repairing this such as a tool from the live environment? Here is additional information for my setup:

System:
  Kernel: 5.18.15-zen1-1-zen arch: x86_64 bits: 64 compiler: gcc v: 12.1.0
    parameters: BOOT_IMAGE=/@/boot/vmlinuz-linux-zen
    root=UUID=052b08b6-4b04-4770-b2cb-31b98943efb3 rw [email protected]
    quiet splash rd.udev.log_priority=3 vt.global_cursor_default=0
    systemd.unified_cgroup_hierarchy=1
    resume=UUID=dc95f6f1-c463-4373-8178-702b16ab719e loglevel=3 ibt=off
  Desktop: N/A wm: LG3D vt: 1 dm: SDDM Distro: Garuda Linux
    base: Arch Linux
Machine:
  Type: Desktop Mobo: Micro-Star model: MPG X570 GAMING PLUS (MS-7C37) v: 2.0
    serial: <superuser required> UEFI-[Legacy]: American Megatrends v: A.40
    date: 09/10/2019
CPU:
  Info: model: AMD Ryzen 5 3600X bits: 64 type: MT MCP arch: Zen 2 gen: 3
    built: 2020-22 process: TSMC n7 (7nm) family: 0x17 (23)
    model-id: 0x71 (113) stepping: 0 microcode: 0x8701013
  Topology: cpus: 1x cores: 6 tpc: 2 threads: 12 smt: enabled cache:
    L1: 384 KiB desc: d-6x32 KiB; i-6x32 KiB L2: 3 MiB desc: 6x512 KiB
    L3: 32 MiB desc: 2x16 MiB
  Speed (MHz): avg: 3807 high: 4073 min/max: N/A cores: 1: 3800 2: 3800
    3: 3800 4: 3800 5: 3800 6: 3800 7: 3800 8: 3800 9: 3800 10: 3800 11: 4073
    12: 3622 bogomips: 91202
  Flags: avx avx2 ht lm nx pae sse sse2 sse3 sse4_1 sse4_2 sse4a ssse3 svm
  Vulnerabilities:
  Type: itlb_multihit status: Not affected
  Type: l1tf status: Not affected
  Type: mds status: Not affected
  Type: meltdown status: Not affected
  Type: mmio_stale_data status: Not affected
  Type: retbleed mitigation: untrained return thunk; SMT enabled with STIBP
    protection
  Type: spec_store_bypass mitigation: Speculative Store Bypass disabled via
    prctl
  Type: spectre_v1 mitigation: usercopy/swapgs barriers and __user pointer
    sanitization
  Type: spectre_v2 mitigation: Retpolines, IBPB: conditional, STIBP:
    always-on, RSB filling
  Type: srbds status: Not affected
  Type: tsx_async_abort status: Not affected
Graphics:
  Device-1: AMD Navi 21 [Radeon RX 6800/6800 XT / 6900 XT] vendor: Sapphire
    driver: amdgpu v: kernel arch: RDNA-2 code: Navi-2x process: TSMC n7 (7nm)
    built: 2020-22 pcie: gen: 4 speed: 16 GT/s lanes: 16 ports:
    active: DP-2,HDMI-A-1 empty: DP-1,DP-3 bus-ID: 2f:00.0 chip-ID: 1002:73bf
    class-ID: 0300
  Display: x11 server: X.Org v: 21.1.4 with: Xwayland v: 22.1.3
    compositor: Picom v: git-c4107 driver: X: loaded: amdgpu gpu: amdgpu
    display-ID: :0 screens: 1
  Screen-1: 0 s-res: 4480x1440 s-dpi: 96 s-size: 1185x381mm (46.65x15.00")
    s-diag: 1245mm (49.01")
  Monitor-1: DP-2 mapped: DisplayPort-1 pos: primary,left model: LG
    (GoldStar) 27GL850 serial: <filter> built: 2020 res: 2560x1440 hz: 144
    dpi: 109 gamma: 1.2 size: 597x336mm (23.5x13.23") diag: 685mm (27")
    ratio: 16:9 modes: max: 2560x1440 min: 640x480
  Monitor-2: HDMI-A-1 mapped: HDMI-A-0 pos: right model: LG (GoldStar)
    23EA63 built: 2012 res: 1920x1080 hz: 60 dpi: 96 gamma: 1.2
    size: 510x290mm (20.08x11.42") diag: 587mm (23.1") ratio: 16:9 modes:
    max: 1920x1080 min: 640x480
  OpenGL: renderer: AMD Radeon RX 6800 (sienna_cichlid LLVM 14.0.6 DRM 3.46
    5.18.15-zen1-1-zen) v: 4.6 Mesa 22.1.4 direct render: Yes
Audio:
  Device-1: AMD Navi 21/23 HDMI/DP Audio driver: snd_hda_intel v: kernel
    pcie: gen: 4 speed: 16 GT/s lanes: 16 bus-ID: 2f:00.1 chip-ID: 1002:ab28
    class-ID: 0403
  Device-2: AMD Starship/Matisse HD Audio vendor: Micro-Star MSI
    driver: snd_hda_intel v: kernel pcie: gen: 4 speed: 16 GT/s lanes: 16
    bus-ID: 31:00.4 chip-ID: 1022:1487 class-ID: 0403
  Sound Server-1: ALSA v: k5.18.15-zen1-1-zen running: yes
  Sound Server-2: JACK v: 1.9.21 running: no
  Sound Server-3: PulseAudio v: 16.1 running: no
  Sound Server-4: PipeWire v: 0.3.56 running: yes
Network:
  Device-1: Realtek RTL8111/8168/8411 PCI Express Gigabit Ethernet
    vendor: Micro-Star MSI X570-A PRO driver: r8169 v: kernel pcie: gen: 1
    speed: 2.5 GT/s lanes: 1 port: d000 bus-ID: 27:00.0 chip-ID: 10ec:8168
    class-ID: 0200
  IF: enp39s0 state: up speed: 100 Mbps duplex: full mac: <filter>
Drives:
  Local Storage: total: 6.38 TiB used: 384.17 GiB (5.9%)
  SMART Message: Required tool smartctl not installed. Check --recommends
  ID-1: /dev/nvme0n1 maj-min: 259:0 vendor: Samsung model: SSD 970 EVO Plus
    2TB size: 1.82 TiB block-size: physical: 512 B logical: 512 B
    speed: 31.6 Gb/s lanes: 4 type: SSD serial: <filter> rev: 2B2QEXM7
    temp: 49.9 C scheme: GPT
  ID-2: /dev/nvme1n1 maj-min: 259:5 vendor: Samsung model: SSD 970 EVO
    500GB size: 465.76 GiB block-size: physical: 512 B logical: 512 B
    speed: 31.6 Gb/s lanes: 4 type: SSD serial: <filter> rev: 2B2QEXE7
    temp: 41.9 C scheme: MBR
  ID-3: /dev/sda maj-min: 8:0 vendor: Samsung model: SSD 850 PRO 512GB
    size: 476.94 GiB block-size: physical: 512 B logical: 512 B speed: 6.0 Gb/s
    type: SSD serial: <filter> rev: 2B6Q scheme: MBR
  ID-4: /dev/sdb maj-min: 8:16 vendor: Western Digital
    model: WD4000FYYZ-01UL1B2 size: 3.64 TiB block-size: physical: 512 B
    logical: 512 B speed: 6.0 Gb/s type: HDD rpm: 7200 serial: <filter>
    rev: 1K03 scheme: MBR
Partition:
  ID-1: / raw-size: 431.26 GiB size: 431.26 GiB (100.00%) used: 384.17 GiB
    (89.1%) fs: btrfs dev: /dev/nvme1n1p1 maj-min: 259:6
  ID-2: /home raw-size: 431.26 GiB size: 431.26 GiB (100.00%) used: 384.17
    GiB (89.1%) fs: btrfs dev: /dev/nvme1n1p1 maj-min: 259:6
  ID-3: /var/log raw-size: 431.26 GiB size: 431.26 GiB (100.00%) used: 384.17
    GiB (89.1%) fs: btrfs dev: /dev/nvme1n1p1 maj-min: 259:6
  ID-4: /var/tmp raw-size: 431.26 GiB size: 431.26 GiB (100.00%) used: 384.17
    GiB (89.1%) fs: btrfs dev: /dev/nvme1n1p1 maj-min: 259:6
Swap:
  Kernel: swappiness: 133 (default 60) cache-pressure: 100 (default)
  ID-1: swap-1 type: zram size: 31.3 GiB used: 768 KiB (0.0%) priority: 100
    dev: /dev/zram0
Sensors:
  System Temperatures: cpu: 55.2 C mobo: N/A gpu: amdgpu temp: 66.0 C
    mem: 64.0 C
  Fan Speeds (RPM): N/A gpu: amdgpu fan: 0
Info:
  Processes: 336 Uptime: 13m wakeups: 0 Memory: 31.3 GiB used: 3.35 GiB
  (10.7%) Init: systemd v: 251 default: graphical tool: systemctl
  Compilers: gcc: 12.1.0 Packages: pacman: 2007 lib: 480 flatpak: 0
  Shell: fish v: 3.5.1 default: Bash v: 5.1.16 running-in: alacritty
  inxi: 3.3.20
Garuda (2.6.5-1):
  System install date:     2022-01-01
  Last full system update: 2022-07-30
  Is partially upgraded:   No
  Relevant software:       NetworkManager
  Windows dual boot:       <superuser required>
  Snapshots:               Timeshift (maybe)
  Failed units:            bluetooth-autoconnect.service

All you need to do is remove the line from the /etc/fstab file.
This delays your startup by, correct me if I'm wrong about the default, 1 minute and 30 seconds.
You are free to create a new swap partition, just do it in KDE partition manager or whatever you prefer and add it back to /etc/fstab or let KDE partition manager add it for you, whatever fits you best.
You don't need a live environment.

3 Likes

Thanks. Was able to make a linixswap formatted partition in KDE. I am not sure if it updated /etc/fstab correctly since it still takes a while to start. Here is whats in my fstab:

# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a device; this may
# be used with UUID= as a more robust way to name devices that works even if
# disks are added and removed. See fstab(5).
#
# <file system>             <mount point>  <type>  <options>  <dump>  <pass>
UUID=052b08b6-4b04-4770-b2cb-31b98943efb3 / btrfs subvol=/@,defaults,noatime,noautodefrag,compress=zstd 0 0 #Modified_by_garuda-hot
fixes(1)
UUID=052b08b6-4b04-4770-b2cb-31b98943efb3 /home btrfs subvol=/@home,defaults,noatime,noautodefrag,compress=zstd 0 0 #Modified_by_ga
ruda-hotfixes(1)
UUID=052b08b6-4b04-4770-b2cb-31b98943efb3 /root btrfs subvol=/@root,defaults,noatime,noautodefrag,compress=zstd 0 0 #Modified_by_ga
ruda-hotfixes(1)
UUID=052b08b6-4b04-4770-b2cb-31b98943efb3 /srv btrfs subvol=/@srv,defaults,noatime,noautodefrag,compress=zstd 0 0 #Modified_by_garu
da-hotfixes(1)
UUID=052b08b6-4b04-4770-b2cb-31b98943efb3 /var/cache btrfs subvol=/@cache,defaults,noatime,noautodefrag,compress=zstd 0 0 #Modified
_by_garuda-hotfixes(1)
UUID=052b08b6-4b04-4770-b2cb-31b98943efb3 /var/log btrfs subvol=/@log,defaults,noatime,noautodefrag,compress=zstd 0 0 #Modified_by_
garuda-hotfixes(1)
UUID=052b08b6-4b04-4770-b2cb-31b98943efb3 /var/tmp btrfs subvol=/@tmp,defaults,noatime,noautodefrag,compress=zstd 0 0 #Modified_by_
garuda-hotfixes(1)
UUID=dc95f6f1-c463-4373-8178-702b16ab719e swap           swap    defaults,noatime 0 0

I noticed that i have zram0 (/dev/zram0) in my partition manager. Is that something that was always there?

You can hit ESC during boot to see logs. If you see somethimg like "waiting for device ..." that doesn't disappear for a while then you did the configuration wrong.

If this UUID matches the UUID of the swap partition you created, then your configuration is correct. You can use sudo blkid to view UUIDs of partitions.

2 Likes

Got a different message than expected.

Error: resume : hibernation device  `UUID=dc95f6f1-c463-4373-8178-702b16ab719e`

This matches the id of zram0 /dev/zram0 and i did not create that. The partition for the swap on the disk is /dev/nvme1n1p2. Should i change the UUID in fstab to match the partition i made? Here is the output of blkid.

/dev/nvme0n1p1: LABEL="Recovery" BLOCK_SIZE="512" UUID="E43CE3273CE2F388" TYPE="ntfs" PARTLABEL="Basic data partition" PARTUUID="15bb482f-6de4-493e-bda7-d709070a7c8c"
/dev/nvme0n1p4: BLOCK_SIZE="512" UUID="4A84E3B984E3A623" TYPE="ntfs" PARTLABEL="Basic data partition" PARTUUID="e2d211e5-4c16-4b78-887a-a7a35bae3e62"
/dev/nvme0n1p2: UUID="22E3-316B" BLOCK_SIZE="512" TYPE="vfat" PARTLABEL="EFI system partition" PARTUUID="1377f095-3aac-41d8-828f-d2fc89befbd8"
/dev/sdb1: LABEL="Storage Disk" BLOCK_SIZE="512" UUID="F40056D500569E84" TYPE="ntfs" PARTUUID="292b151f-01"
/dev/nvme1n1p2: UUID="2f66aad3-a3c1-4519-b2dc-f69f7a762c10" TYPE="swap" PARTUUID="96cbb0ea-02"
/dev/nvme1n1p1: UUID="052b08b6-4b04-4770-b2cb-31b98943efb3" UUID_SUB="cf7f44bf-2dab-41b6-916c-6f8564d378be" BLOCK_SIZE="4096" TYPE="btrfs" PARTUUID="96cbb0ea-01"
/dev/sda2: BLOCK_SIZE="512" UUID="3EB25CEEB25CABE1" TYPE="ntfs" PARTUUID="e88560ef-02"
/dev/sda1: LABEL="System Reserved" BLOCK_SIZE="512" UUID="5EE21F5AE21F362D" TYPE="ntfs" PARTUUID="e88560ef-01"
/dev/nvme0n1p3: PARTLABEL="Microsoft reserved partition" PARTUUID="6fd2f842-7339-4282-9278-8087608dfb86"
/dev/zram0: LABEL="zram0" UUID="4d5c86fe-15b1-4243-8a87-ec34dfd24c5c" TYPE="swap"

In file /etc/default/grub remove the parameter that starts with "resume=".

1 Like

Was it under GRUB_CMDLINE_LINUX_DEFAULT? I removed it and I still have "resume= " during startup.

Now run

sudo grub-mkconfig -o /boot/grub/grub.cfg
2 Likes

Thanks, that seems to fix the startup issue. Also, i changed the UUID for the swap in fstab to match the linuxswap i made in KDE partition manager.

# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a device; this may
# be used with UUID= as a more robust way to name devices that works even if
# disks are added and removed. See fstab(5).
#
# <file system>             <mount point>  <type>  <options>  <dump>  <pass>
UUID=052b08b6-4b04-4770-b2cb-31b98943efb3 / btrfs subvol=/@,defaults,noatime,noautodefrag,compress=zstd 0 0 #Modified_by_garuda-hotfixes(1)
UUID=052b08b6-4b04-4770-b2cb-31b98943efb3 /home btrfs subvol=/@home,defaults,noatime,noautodefrag,compress=zstd 0 0 #Modified_by_garuda-hotfixes(1)
UUID=052b08b6-4b04-4770-b2cb-31b98943efb3 /root btrfs subvol=/@root,defaults,noatime,noautodefrag,compress=zstd 0 0 #Modified_by_garuda-hotfixes(1)
UUID=052b08b6-4b04-4770-b2cb-31b98943efb3 /srv btrfs subvol=/@srv,defaults,noatime,noautodefrag,compress=zstd 0 0 #Modified_by_garuda-hotfixes(1)
UUID=052b08b6-4b04-4770-b2cb-31b98943efb3 /var/cache btrfs subvol=/@cache,defaults,noatime,noautodefrag,compress=zstd 0 0 #Modified_by_garuda-hotfixes(1)
UUID=052b08b6-4b04-4770-b2cb-31b98943efb3 /var/log btrfs subvol=/@log,defaults,noatime,noautodefrag,compress=zstd 0 0 #Modified_by_garuda-hotfixes(1)
UUID=052b08b6-4b04-4770-b2cb-31b98943efb3 /var/tmp btrfs subvol=/@tmp,defaults,noatime,noautodefrag,compress=zstd 0 0 #Modified_by_garuda-hotfixes(1)
UUID=2f66aad3-a3c1-4519-b2dc-f69f7a762c10 swap           swap    defaults,noatime 0 0
#UUID=dc95f6f1-c463-4373-8178-702b16ab719e swap           swap    defaults,noatime 0 0

No problem. You may mark my last post as solution, also if you want hibernation you can add resume=UUID=2f66aad3-a3c1-4519-b2dc-f69f7a762c10 to GRUB_CMDLINE_LINUX and GRUB_CMDLINE_LINUX_DEFAULT then run sudo grub-mkconfig /boot/grub/grub.cfg again.

1 Like

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