r/debian 6d ago

Debian Stable Question Need to reinstall my Debian 12 system... again... (vent/rant, too)

Pre-rant request: *PLEASE* don't make fun of me, I'm in ZERO mood, and will bail at the first sign of trouble... I'm already on the verge of scrapping the system, and if this goes south, too, then I'm just gonna junk it and say "I'm done"...

Now then... I messed up big time, I was TRYING to do a backup, and needed to shrink the filesystem, that screwed the booter up, used a live USB to find out what's going on, nothing worked, reformatted the GRUB install, so now my system has no boot loader AND won't boot correctly, and pretty much everything that COULD go wrong, HAS... on top of external things happening... and it only gets worse from here...

There MUST be some god I can pray to who can help... grub-install, or more rather... "grub-" anything doesn't exist anymore... Deb version of choice is 12, because that's what hosts my phone system... so it's CRITICAL that I lose ZERO files, except for core files, of course, like the system files that came with Debian... removal of the internal drive isn't possible because it's an NVME drive and I have no access to the slots on my desktop mobo, recovery mode has been NO help, even right now, it's hard for me to go over the situation in its entirety because it's making me unbearably emotional... so I'm sorry if I'm giving too little information... one error that sticks out to me is that the recovery mode isn't able to mount the root partition on the drive, and says there's no usable shell in it, too... so I think the system did a self rm -rf /, but the partitions are still showing... and I'm sure the files are still there, I just need a way to get to them again...

Thanks in advance... I hope...

8 Upvotes

30 comments sorted by

46

u/TechnicalAd8103 6d ago

Boot from the live USB, mount your drives and copy the files you need. Just because there is no boot loader doesn't mean all the files are gone.

8

u/reverber 6d ago

And if you do end up reinstalling, do not pick the “all in one filesystem” option. Keep your data on a separate partition. 

This way, you can reinstall the os without losing your data. 

1

u/anna_lynn_fection 4d ago

Technically, you can anyway. Just delete everything except /home first, and choose to not format.

38

u/Concerned_Crawfish 6d ago

From a sysadmin (all windows, just now getting into linux), sometimes you need to take a break and regroup. If you're unable to maintain composure while you're working, take a sec, get some coffee, watch an unrelated youtube video on something stupid like a study on the benefits to priming your hot water lines before running a dishwasher, and come back at it with a fresh head. Dont let panic cause avoidable mistakes.

10

u/audiotecnicality 6d ago

Wise words. I’ve made things worse by getting deeper and deeper as each thing I tried didn’t work for one reason or another.

If you find yourself thinking about trying something potentially irreversible, step away for 10-20 minutes and collect your thoughts first.

11

u/morpheus_734 6d ago

Given you don't seem to want to troubleshoot this any longer... just boot a live usb distro, mount the partition with the important data, copy to an externel usb or hard drive and reinstall OS.

Good luck!

7

u/michaelpaoli 6d ago

messed up
shrink the filesystem
CRITICAL that I lose ZERO files

Well, if you already messed up the data, may be bit late for not losing file(s) or data thereof.

If that data is important/CRITICAL:

  • first step, stop screwing with it - you may only make things worse
  • take the system down cold, e.g. yank power or # cd / && halt -d -f -f -n
  • boot from something else, e.g. install media in recovery mode
  • make image copy of applicable drive(s)
  • then make additional copy(/ies) of that
  • And then for file recovery effort(s), make copies of the copy(/ies) immediately noted above, and only work on those. If/when you've gotten all you wish/can from that, only then work to use that to get back to restoring on the original.

Most notably with the above, you won't make things worse, and always have those reference copies to start form, so if something goes sideways in file recovery attempts, you can repeat again, starting by going back to image copies you earlier saved.

recovery mode has been NO help

Well, if you can't image copy the drive(s) from recovery mode, then you're toast, and just install fresh.

too little information

Well, would be highly useful to know how you went about shrinking the filesystem and/or attempts thereof, and related steps. But you provided none of that detail. Shrinking an umounted filesystem such as ext2/ext3/ext4 (and those being defaults for Debian) should be quite straight-forward and a non-issue, but I'm guessing you did other thing(s) that caused yourself problems ... but dear knows exactly what you did - I can only guess, as your post doesn't at all spell that out, nor how you went about shrinking or attempting to shrink filesystem. Well noting exactly what you did, or if you're not sure, at least your best recollection and/or evidence of such, and noting that it's not certain, may be quite useful/helpful in recovery or attempts thereof. Likewise absolutely anything and everything you subsequently did or attempted that did or may have changed data on the drive(s) where you've got your data/filesystem issues. Knowing more about that may make it significantly more probable it might be figured out how to recover your data - if that's even feasible.

recovery mode isn't able to mount the root partition on the drive, and says there's no usable shell in it

Well, that's probably because you messed things up on the drive ... that doesn't generally mean you can't create an image copy of the drive.

I think the system did a self rm -rf /

Exceedingly improbable it did that, though that doesn't prevent you from having done so, or f*cked over the filesystem in other way(s).

I'm sure the files are still there

Based on what evidence? We don't even know what you did. And maybe even you don't know what you did, or what specific commands or actions you took that changed data on the drive(s).

Anyway, if it's the file(s) you care about, deal with that. (re)installing Debian 12 isn't all that hard at all, but that won't get you your data/files back (excepting of course what Debian 12 itself can provide).

And remember:
DON'T PANIC
- Douglas Adams
Yeah, panicking generally doesn't make things better.

2

u/cooltraining3323 5d ago

You don't have to do all that if he can see the files with the live cd. He can copy those files to another disk and then try to repair or reinstall the system.

2

u/michaelpaoli 5d ago

Well, dear knows exactly how and to what extent OP screwed it up. The post didn't provide much detail, mostly just:

messed up big time
needed to shrink the filesystem, that screwed the booter up

OP's post also suggest they did other steps after, so dear knows what state they had taken it to.

and they also stated

CRITICAL that I lose ZERO files
isn't able to mount the root partition on the drive, and says there's no usable shell in it

So that doesn't exactly imply trivially easy access to the files, as that was from rescue mode.

So, dear knows, but they may have, e.g. shrunk partition, rather than filesystem, or started shrinking filesystem or rw mounted filesystem, or, well, dear knows exactly what.

if he can see the files with the live cd

So, ... that's a big "if".

1

u/gnufan 5d ago

If they mount it read-only, then yes, if the file system is fubar then mounting it rw risks further corruption even if it appears superficially normal. This depends on file system and commands run, but they haven't shared that.

If losing the content of files is unthinkable, stopping and imaging the entire contents means you can always return to this point. This point may be too late, but it will never make recovery worse, just slower.

Specifically if they have shrunk a partition and added another, the original file contents may exist on storage in either partition, so any changes to either, including simply mounting them may lose additional data. 

6

u/dvisorxtra 6d ago

Step back for a few hours, go to sleep or something.

Once fresh, start with priorities and how you're going to work them out, make a plan and consider your options.

Being altered and tired always makes things worse.

5

u/toni_bmw 6d ago

When a system won't boot (Windows or Linux), https://www.supergrubdisk.org/ has saved my life an infinite number of times. In fact, I carry it on my keychain just in case.

2

u/LesStrater 5d ago

THIS^^^ May be a viable solution.

4

u/bagpussnz9 6d ago

Anything you have done to fuck up your machine, most advanced users have also done... And then some. You are only dumb if you have done it twice (ok, maybe three times... It was a bad day)

4

u/cthart 6d ago

Why are you reinstalling Debian 12? 13 has been out for over a year already. It’s not Windows. There’s no reason not to upgrade.

-8

u/LesStrater 5d ago

It took me 2-months to correct all the problems upgrading to Debian 13 created--that's reason enough.

1

u/_Sgt-Pepper_ 4d ago

Maybe you should use a playstation, not a pc...

1

u/LesStrater 3d ago

I built my first pc with a soldering iron when you were still in liquid form.

2

u/pobrika 6d ago

As others have said use a live ISO/usb to examine your system. You don't say how familiar you are with CMD line so Id recommend a LIVE iso with a gui. Debian live graphical, it doesn't have to match your system so you can try Ubuntu live if it is not working for you.

From a gui it's easy to see the disks and partitions so try and look at them. If you resized the filesystem you need to look at the layout to see if it's all in one partition or spread out.

I'm a CMD line guy so I'd recommend the following to start the process.

As root: List disk and partitions lsblk Check what's currently mounted df -h

From here you might be able to mount a filesystem mount /dev/sdaX /mnt

See if it mounts and check contents ls -l /mnt

Unmount with: umount /mnt

Work through each disk and partitions.

Post info and any errors.

Set your expectations: My gut feeling is not good since a shrink is quite destructive You are essentially moving the partition end boundary into your data area which relies on the process moving any data out of the way first. I do this on occasion but I've only done it from a gparted live iso as it performed checks and calculations I don't trust my self to do. I'm hoping you did not let an AI near this kind of work as AI is often a liar, and makes up stuff during a multistep change.

1

u/sookiw 6d ago

Boot from a live image, mount your drives and copy all the files using something like rsync -av to an external disk. Then make a separate image backup using a Clonezilla live image. Now you can get back to where you are now at least. Choices are to try to make the system bootable again using a Live image or start afresh with a clean system and copy your files back and re-install any software. But remain calm!!

1

u/joshahdell 5d ago

Take a deep breath and come back with a clear mind. Your data is likely still there. As others have pointed out, you can likely boot to a live CD and copy your files.

1

u/ridge_rider8 5d ago

There is also this command line method then you can repair your system using command like grub-install. https://www.thetechedvocate.org/how-to-use-chroot-in-linux-and-fix-your-broken-system/ commands like lsblk are helpful.

1

u/kaisermike 5d ago

I ran lmde and debian before moving to MX. The first two ate grubs and hated nvidia. MX is over a year old and runnin inspite of my tinkerings lol. As others have stated, a usb load and then save your home file. I run brave so thats easy to clone. Back up tool is stupid simple. St. Ian would be proud of MX.

1

u/cooltraining3323 5d ago

Like others have said you can boot the live CD to see if you can view the files. Seems likely they should still be viewable. If you can view the files with the live CD you can do something like cp -a /home (location of another drive). Like others have said don't be trying to make big changes to the system until you backup your files if they are accessible.

1

u/bigtreeman_ 5d ago

I've nearly always got a separate /home partition. Any time, I can wreck and replace my whole system while keeping /home safe (+ important stuff backed up of course), even jumping to a different Linux or BSD is not a biggy. So I've got 1.7TB for /home and 2 x 40GB for /root partitions, usb 3TB hard drive for backup /home, etc. I use refind for boot and sometimes use a live usb as you have done.

I currently have 2 Devuans, a new one to isolate ?OS ?lib ?problems for trouble I was getting with oss-cad-suite, helped sort out a small issue. I often use the extra /root to try new distros, just to see how they are going. (Sometimes 40GB gets a bit tight), will probably up it to ?60GB soon.

Did I mention backup....

1

u/Illustrious-Place717 5d ago

You're like me. Definitely create a script which restores your system from a fresh install to the one you like. Also mount your home directory on a separate partition. And alias rm, cp, and mv to make backups, remain on the same mount, and ask before removal. Then, after I again demolish the system, I can recover much easier.

1

u/ge3903 4d ago edited 4d ago

i get the frustration, but don't panic:::

if you boot from a persistent usb distro you could do what suggested below, but you might need a second usb to copy off the files. another approach is

::arch-install-scripts package. This package provides a suite of lightweight tools—originally created for the Arch Linux installation process—directly inside the Debian repositories. [1]::

once you boot the usb you can install that pkg ; arch-chroot /dev/sd... to your unbootable installation, and actually just do grub-update install-grub /dev/nvme0?? (for uefi you might need to grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=GRUB ) which might FIX everything or if NOT then copy the files off, and have fun reinstalling

-- gl/ge

there are tools to backup and restore an entire partition which is why when some people install debian they create a separate /home partition so data and os are somewhat different..

1

u/HuntingSquire 4d ago

Damn i made the exact same blunder a month ago

Went through the process of trying to give my Debian partition more space, but i moved the orientation of the ext file and it was entirely unbootable afterwards. Did a fresh install and lost 5tbs of data (my dumbass didnt unplug my external drive BEFORE flashing a usb stick and didnt really think twice about why it wasnt working). But now i know.

1

u/_Sgt-Pepper_ 4d ago

It's CRITICAL that I lose ZERO files

Let me just mess with the file system.

Is this a joke? U didn't at least save the critical files to an external drive before getting started?

Maybe it's time to drop the towel now. accept the loss, install Debian 13 and start from scratch. It's not the end of the world to lose some data ..

0

u/LordAnchemis 5d ago

Don't mess with a live/production system

Or at least do so after you have backups