You are not logged in.

#1 2024-06-01 20:14:20

Serpentarius13
Member
Registered: 2024-04-19
Posts: 8

[SOLVED] Formatted boot partition by mistake

The other day my boot partition (from arch install script there were three - boot, root and home) was lacking on space and I decided to resize it with Gnome Partition Manager from flash drive. Since this utility doesnt have support for resizing FAT32 partitions, there was a tutorial on their page telling me to reformat it. Stupid me forgot that reformatting means deleting everything along it, so I just wiped it out moving it to EXT4 and then back to FAT32. After realizing my mistake, I tried to boot back into the system, but got into Grub rescue mode. I tinkered for few hours and finally found a solution to at least boot the system - I have entered Arch installation medium, mounted partitions into /mnt, did pacstrap and then after arch-chroot installed and configured grub with grub-install and grub-mkconfig. It works, but randomly after I reboot or shut down and power back my pc, it pushes me back to rescue mode until I do all the steps again. Can someone help me please? Forgive for my newbiness

Last edited by Serpentarius13 (2024-06-02 09:25:27)

Offline

#2 2024-06-01 20:32:25

Funny0facer
Member
From: Germany
Registered: 2022-12-03
Posts: 95

Re: [SOLVED] Formatted boot partition by mistake

can you post the output of the following commands for further information? please use code brackets.

lsblk
cat /etc/fstab
tree /boot

Offline

#3 2024-06-01 20:33:29

cryptearth
Member
Registered: 2024-02-03
Posts: 346

Re: [SOLVED] Formatted boot partition by mistake

pacstrap is only needed for the initial setup of a new system - don't do it to an existing system!
If you can boot from install and arch-chroot into the existing system (from the wiki you just skip the steps between mounting and arch-chroot) then you likely just have to fix the bootloader.
As you use grub on uefi it's likely that the uefi bootorder got messed up.
A somewhat straight-forward yet simple way would be to wipe the ESP, use efibootmrg to clear the bootorder (the actual problem here) and do a fresh and clean install of grub and the config.
The other more complicated way would be to fix the uefi boot order by hand - but this requires a bit of finess to get right.

Offline

#4 2024-06-01 20:42:11

Serpentarius13
Member
Registered: 2024-04-19
Posts: 8

Re: [SOLVED] Formatted boot partition by mistake

Funny0facer wrote:

can you post the output of the following commands for further information? please use code brackets.

lsblk
cat /etc/fstab
tree /boot
 
NAME        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
sda           8:0    1 238.5G  0 disk 
└─sda1        8:1    1 238.5G  0 part /run/media/star/Новый том
sdb           8:16   1 465.8G  0 disk 
├─sdb1        8:17   1   100M  0 part 
├─sdb2        8:18   1    16M  0 part 
├─sdb3        8:19   1 464.6G  0 part /run/media/star/E8E2773CE2770DD6
└─sdb4        8:20   1   516M  0 part 
sdc           8:32   1  58.6G  0 disk 
└─sdc1        8:33   1  58.6G  0 part /run/media/star/ARCH_202405
zram0       254:0    0     4G  0 disk [SWAP]
nvme0n1     259:0    0 931.5G  0 disk 
├─nvme0n1p1 259:1    0  27.6G  0 part /boot
├─nvme0n1p2 259:2    0  73.8G  0 part /
└─nvme0n1p3 259:3    0   823G  0 part /home
# Static information about the filesystems.
# See fstab(5) for details.

# <file system> <dir> <type> <options> <dump> <pass>
# /dev/nvme0n1p2
UUID=5e3ec4d3-2302-4898-a46f-45a9939e8540	/         	ext4      	rw,relatime	0 1


# /dev/nvme0n1p3
UUID=151aed93-c77a-4240-a41c-cb1498f5f163	/home     	ext4      	rw,relatime	0 2
# /dev/nvme0n1p2
UUID=5e3ec4d3-2302-4898-a46f-45a9939e8540	/         	ext4      	rw,relatime	0 1

# /dev/nvme0n1p1
UUID=F075-A2D6      	/boot     	vfat      	rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro	0 2

/boot
├── EFI
│   └── GRUB
│       └── grubx64.efi
├── grub
│   ├── fonts
│   │   └── unicode.pf2
│   ├── grub.cfg
│   ├── grubenv
│   ├── locale
│   │   ├── ast.mo
│   │   ├── ca.mo
│   │   ├── da.mo
│   │   ├── de_CH.mo
│   │   ├── de@hebrew.mo
│   │   ├── de.mo
│   │   ├── en@arabic.mo
│   │   ├── en@cyrillic.mo
│   │   ├── en@greek.mo
│   │   ├── en@hebrew.mo
│   │   ├── en@piglatin.mo
│   │   ├── en@quot.mo
│   │   ├── eo.mo
│   │   ├── es.mo
│   │   ├── fi.mo
│   │   ├── fr.mo
│   │   ├── gl.mo
│   │   ├── he.mo
│   │   ├── hr.mo
│   │   ├── hu.mo
│   │   ├── id.mo
│   │   ├── it.mo
│   │   ├── ja.mo
│   │   ├── ka.mo
│   │   ├── ko.mo
│   │   ├── lg.mo
│   │   ├── lt.mo
│   │   ├── nb.mo
│   │   ├── nl.mo
│   │   ├── pa.mo
│   │   ├── pl.mo
│   │   ├── pt_BR.mo
│   │   ├── pt.mo
│   │   ├── ro.mo
│   │   ├── ru.mo
│   │   ├── sl.mo
│   │   ├── sr.mo
│   │   ├── sv.mo
│   │   ├── tr.mo
│   │   ├── uk.mo
│   │   ├── vi.mo
│   │   ├── zh_CN.mo
│   │   └── zh_TW.mo
│   ├── themes
│   │   └── starfield
│   │       ├── blob_w.png
│   │       ├── boot_menu_c.png
│   │       ├── boot_menu_e.png
│   │       ├── boot_menu_ne.png
│   │       ├── boot_menu_n.png
│   │       ├── boot_menu_nw.png
│   │       ├── boot_menu_se.png
│   │       ├── boot_menu_s.png
│   │       ├── boot_menu_sw.png
│   │       ├── boot_menu_w.png
│   │       ├── COPYING.CC-BY-SA-3.0
│   │       ├── dejavu_10.pf2
│   │       ├── dejavu_12.pf2
│   │       ├── dejavu_14.pf2
│   │       ├── dejavu_16.pf2
│   │       ├── dejavu_bold_14.pf2
│   │       ├── README
│   │       ├── slider_c.png
│   │       ├── slider_n.png
│   │       ├── slider_s.png
│   │       ├── starfield.png
│   │       ├── terminal_box_c.png
│   │       ├── terminal_box_e.png
│   │       ├── terminal_box_ne.png
│   │       ├── terminal_box_n.png
│   │       ├── terminal_box_nw.png
│   │       ├── terminal_box_se.png
│   │       ├── terminal_box_s.png
│   │       ├── terminal_box_sw.png
│   │       ├── terminal_box_w.png
│   │       └── theme.txt
│   └── x86_64-efi
│       ├── acpi.mod
│       ├── adler32.mod
│       ├── affs.mod
│       ├── afs.mod
│       ├── afsplitter.mod
│       ├── ahci.mod
│       ├── all_video.mod
│       ├── aout.mod
│       ├── appleldr.mod
│       ├── archelp.mod
│       ├── ata.mod
│       ├── at_keyboard.mod
│       ├── backtrace.mod
│       ├── bfs.mod
│       ├── bitmap.mod
│       ├── bitmap_scale.mod
│       ├── bli.mod
│       ├── blocklist.mod
│       ├── boot.mod
│       ├── boottime.mod
│       ├── bsd.mod
│       ├── bswap_test.mod
│       ├── btrfs.mod
│       ├── bufio.mod
│       ├── cacheinfo.mod
│       ├── cat.mod
│       ├── cbfs.mod
│       ├── cbls.mod
│       ├── cbmemc.mod
│       ├── cbtable.mod
│       ├── cbtime.mod
│       ├── chain.mod
│       ├── cmdline_cat_test.mod
│       ├── cmp.mod
│       ├── cmp_test.mod
│       ├── command.lst
│       ├── configfile.mod
│       ├── core.efi
│       ├── cpio_be.mod
│       ├── cpio.mod
│       ├── cpuid.mod
│       ├── crc64.mod
│       ├── cryptodisk.mod
│       ├── crypto.lst
│       ├── crypto.mod
│       ├── cs5536.mod
│       ├── ctz_test.mod
│       ├── datehook.mod
│       ├── date.mod
│       ├── datetime.mod
│       ├── diskfilter.mod
│       ├── disk.mod
│       ├── div.mod
│       ├── div_test.mod
│       ├── dm_nv.mod
│       ├── echo.mod
│       ├── efifwsetup.mod
│       ├── efi_gop.mod
│       ├── efinet.mod
│       ├── efitextmode.mod
│       ├── efi_uga.mod
│       ├── ehci.mod
│       ├── elf.mod
│       ├── eval.mod
│       ├── exfat.mod
│       ├── exfctest.mod
│       ├── ext2.mod
│       ├── extcmd.mod
│       ├── f2fs.mod
│       ├── fat.mod
│       ├── file.mod
│       ├── fixvideo.mod
│       ├── font.mod
│       ├── fshelp.mod
│       ├── fs.lst
│       ├── functional_test.mod
│       ├── gcry_arcfour.mod
│       ├── gcry_blowfish.mod
│       ├── gcry_camellia.mod
│       ├── gcry_cast5.mod
│       ├── gcry_crc.mod
│       ├── gcry_des.mod
│       ├── gcry_dsa.mod
│       ├── gcry_idea.mod
│       ├── gcry_md4.mod
│       ├── gcry_md5.mod
│       ├── gcry_rfc2268.mod
│       ├── gcry_rijndael.mod
│       ├── gcry_rmd160.mod
│       ├── gcry_rsa.mod
│       ├── gcry_seed.mod
│       ├── gcry_serpent.mod
│       ├── gcry_sha1.mod
│       ├── gcry_sha256.mod
│       ├── gcry_sha512.mod
│       ├── gcry_tiger.mod
│       ├── gcry_twofish.mod
│       ├── gcry_whirlpool.mod
│       ├── geli.mod
│       ├── gettext.mod
│       ├── gfxmenu.mod
│       ├── gfxterm_background.mod
│       ├── gfxterm_menu.mod
│       ├── gfxterm.mod
│       ├── gptsync.mod
│       ├── grub.efi
│       ├── gzio.mod
│       ├── halt.mod
│       ├── hashsum.mod
│       ├── hdparm.mod
│       ├── hello.mod
│       ├── help.mod
│       ├── hexdump.mod
│       ├── hfs.mod
│       ├── hfspluscomp.mod
│       ├── hfsplus.mod
│       ├── http.mod
│       ├── iorw.mod
│       ├── iso9660.mod
│       ├── jfs.mod
│       ├── jpeg.mod
│       ├── json.mod
│       ├── keylayouts.mod
│       ├── keystatus.mod
│       ├── ldm.mod
│       ├── legacycfg.mod
│       ├── legacy_password_test.mod
│       ├── linux16.mod
│       ├── linux.mod
│       ├── loadbios.mod
│       ├── loadenv.mod
│       ├── loopback.mod
│       ├── lsacpi.mod
│       ├── lsefimmap.mod
│       ├── lsefi.mod
│       ├── lsefisystab.mod
│       ├── lsmmap.mod
│       ├── ls.mod
│       ├── lspci.mod
│       ├── lssal.mod
│       ├── luks2.mod
│       ├── luks.mod
│       ├── lvm.mod
│       ├── lzopio.mod
│       ├── macbless.mod
│       ├── macho.mod
│       ├── mdraid09_be.mod
│       ├── mdraid09.mod
│       ├── mdraid1x.mod
│       ├── memdisk.mod
│       ├── memrw.mod
│       ├── minicmd.mod
│       ├── minix2_be.mod
│       ├── minix2.mod
│       ├── minix3_be.mod
│       ├── minix3.mod
│       ├── minix_be.mod
│       ├── minix.mod
│       ├── mmap.mod
│       ├── moddep.lst
│       ├── modinfo.sh
│       ├── morse.mod
│       ├── mpi.mod
│       ├── msdospart.mod
│       ├── mul_test.mod
│       ├── multiboot2.mod
│       ├── multiboot.mod
│       ├── nativedisk.mod
│       ├── net.mod
│       ├── newc.mod
│       ├── nilfs2.mod
│       ├── normal.mod
│       ├── ntfscomp.mod
│       ├── ntfs.mod
│       ├── odc.mod
│       ├── offsetio.mod
│       ├── ohci.mod
│       ├── part_acorn.mod
│       ├── part_amiga.mod
│       ├── part_apple.mod
│       ├── part_bsd.mod
│       ├── part_dfly.mod
│       ├── part_dvh.mod
│       ├── part_gpt.mod
│       ├── partmap.lst
│       ├── part_msdos.mod
│       ├── part_plan.mod
│       ├── part_sun.mod
│       ├── part_sunpc.mod
│       ├── parttool.lst
│       ├── parttool.mod
│       ├── password.mod
│       ├── password_pbkdf2.mod
│       ├── pata.mod
│       ├── pbkdf2.mod
│       ├── pbkdf2_test.mod
│       ├── pcidump.mod
│       ├── pgp.mod
│       ├── plainmount.mod
│       ├── play.mod
│       ├── png.mod
│       ├── priority_queue.mod
│       ├── probe.mod
│       ├── procfs.mod
│       ├── progress.mod
│       ├── raid5rec.mod
│       ├── raid6rec.mod
│       ├── random.mod
│       ├── rdmsr.mod
│       ├── read.mod
│       ├── reboot.mod
│       ├── regexp.mod
│       ├── reiserfs.mod
│       ├── relocator.mod
│       ├── romfs.mod
│       ├── scsi.mod
│       ├── search_fs_file.mod
│       ├── search_fs_uuid.mod
│       ├── search_label.mod
│       ├── search.mod
│       ├── serial.mod
│       ├── setjmp.mod
│       ├── setjmp_test.mod
│       ├── setpci.mod
│       ├── sfs.mod
│       ├── shift_test.mod
│       ├── signature_test.mod
│       ├── sleep.mod
│       ├── sleep_test.mod
│       ├── smbios.mod
│       ├── spkmodem.mod
│       ├── squash4.mod
│       ├── strtoull_test.mod
│       ├── syslinuxcfg.mod
│       ├── tar.mod
│       ├── terminal.lst
│       ├── terminal.mod
│       ├── terminfo.mod
│       ├── test_blockarg.mod
│       ├── testload.mod
│       ├── test.mod
│       ├── testspeed.mod
│       ├── tftp.mod
│       ├── tga.mod
│       ├── time.mod
│       ├── tpm.mod
│       ├── trig.mod
│       ├── tr.mod
│       ├── true.mod
│       ├── udf.mod
│       ├── ufs1_be.mod
│       ├── ufs1.mod
│       ├── ufs2.mod
│       ├── uhci.mod
│       ├── usb_keyboard.mod
│       ├── usb.mod
│       ├── usbms.mod
│       ├── usbserial_common.mod
│       ├── usbserial_ftdi.mod
│       ├── usbserial_pl2303.mod
│       ├── usbserial_usbdebug.mod
│       ├── usbtest.mod
│       ├── video_bochs.mod
│       ├── video_cirrus.mod
│       ├── video_colors.mod
│       ├── video_fb.mod
│       ├── videoinfo.mod
│       ├── video.lst
│       ├── video.mod
│       ├── videotest_checksum.mod
│       ├── videotest.mod
│       ├── wrmsr.mod
│       ├── xfs.mod
│       ├── xnu.mod
│       ├── xnu_uuid.mod
│       ├── xnu_uuid_test.mod
│       ├── xzio.mod
│       ├── zfscrypt.mod
│       ├── zfsinfo.mod
│       ├── zfs.mod
│       └── zstd.mod
├── initramfs-linux-fallback.img
├── initramfs-linux.img
└── vmlinuz-linux

9 directories, 362 files

Offline

#5 2024-06-01 20:43:40

Serpentarius13
Member
Registered: 2024-04-19
Posts: 8

Re: [SOLVED] Formatted boot partition by mistake

cryptearth wrote:

pacstrap is only needed for the initial setup of a new system - don't do it to an existing system!
If you can boot from install and arch-chroot into the existing system (from the wiki you just skip the steps between mounting and arch-chroot) then you likely just have to fix the bootloader.
As you use grub on uefi it's likely that the uefi bootorder got messed up.
A somewhat straight-forward yet simple way would be to wipe the ESP, use efibootmrg to clear the bootorder (the actual problem here) and do a fresh and clean install of grub and the config.
The other more complicated way would be to fix the uefi boot order by hand - but this requires a bit of finess to get right.

So I would need to launch into USB again, wipe my boot partition with something like mkfs, then do efibootmrg plus what I've described in my post?

Last edited by Serpentarius13 (2024-06-01 20:43:56)

Offline

#6 2024-06-01 21:09:51

Funny0facer
Member
From: Germany
Registered: 2022-12-03
Posts: 95

Re: [SOLVED] Formatted boot partition by mistake

a reasonable size for /boot would be 1GB to 3GB for new installs. Your 27GB are quite big in my opinion. Is this your intention?

your root directy is twice in /etc/fstab, i suggest to clean or regenerate it.

another cleaning could be advisable: Can you boot from your live image and only mount your root directory and check if there are fragements in /boot without mounting yout boot partition? In my experience, this could mess things up.

I personally go only with the grub-install --removable option as this survives typically everything. Even a wipe mit efibootmgr or flashing the motherboard firmware.

Offline

#7 2024-06-01 23:33:46

cryptearth
Member
Registered: 2024-02-03
Posts: 346

Re: [SOLVED] Formatted boot partition by mistake

Serpentarius13 wrote:

So I would need to launch into USB again, wipe my boot partition with something like mkfs, then do efibootmrg plus what I've described in my post?

My point is: Your fstab shows you executed gen-fstab at least twice - so you already did quite some harm to your system overall. By cleaning these issues I recommend to get at least back stable booting:
1) clean up your fstab - it should list the / only once
2) use efibootmgr to first check the current uefi bootorder - I guess it has some issues causing your "once in a while rescue shell"
3) clean up the uefi bootorder - unless you have a board with a very broken uefi impl you should be fine by simply clean all entries
4) clean /boot (no - you don't need another mkfs - a simple rm -rf /boot/* is sufficient)
5) to restore kernel and initrd the easiest option is just to reinstall the kernel by pacman -S linux (it's a good idea to first do a complete system update with the usual pacman -Syu)
6) check that both the kernel and initrd are recreated in /boot
7) do a clean install of grub with grub-install and grub-mkconfig
8) check if the install was successfull by run efibootmgr once again and cat grub.cfg
9) do a clean reboot
It shouldn't matter if you do this either from the running system itself or from install while chroot - the result should be the same.
As mentioned by funny: 27g for ESP is quite excessive - as you complaint about ESP too small and resizing this means you had to shrink and move the root partition, too - this very likely caused some harm to your OS. I would recommend a full clean re-install of the entire OS. What was the initial size of ESP and why you made it so big - just to get everyone up to speed: What was the actual thing you wanted to do in the first place?

Offline

#8 2024-06-02 09:24:52

Serpentarius13
Member
Registered: 2024-04-19
Posts: 8

Re: [SOLVED] Formatted boot partition by mistake

cryptearth wrote:
Serpentarius13 wrote:

So I would need to launch into USB again, wipe my boot partition with something like mkfs, then do efibootmrg plus what I've described in my post?

My point is: Your fstab shows you executed gen-fstab at least twice - so you already did quite some harm to your system overall. By cleaning these issues I recommend to get at least back stable booting:
1) clean up your fstab - it should list the / only once
2) use efibootmgr to first check the current uefi bootorder - I guess it has some issues causing your "once in a while rescue shell"
3) clean up the uefi bootorder - unless you have a board with a very broken uefi impl you should be fine by simply clean all entries
4) clean /boot (no - you don't need another mkfs - a simple rm -rf /boot/* is sufficient)
5) to restore kernel and initrd the easiest option is just to reinstall the kernel by pacman -S linux (it's a good idea to first do a complete system update with the usual pacman -Syu)
6) check that both the kernel and initrd are recreated in /boot
7) do a clean install of grub with grub-install and grub-mkconfig
8) check if the install was successfull by run efibootmgr once again and cat grub.cfg
9) do a clean reboot
It shouldn't matter if you do this either from the running system itself or from install while chroot - the result should be the same.
As mentioned by funny: 27g for ESP is quite excessive - as you complaint about ESP too small and resizing this means you had to shrink and move the root partition, too - this very likely caused some harm to your OS. I would recommend a full clean re-install of the entire OS. What was the initial size of ESP and why you made it so big - just to get everyone up to speed: What was the actual thing you wanted to do in the first place?

I have 1 TB on my disk that were unlikely to be used by my system as of now, so I decided to increase it dumbly to some arbitrage value. I didn't resize root partition, but shrank my home one. I did the steps (dunno if works, but works now), thank you for your help!! Will reinstall it later properly, just don't have time now

Offline

Board footer

Powered by FluxBB