You are not logged in.
I'd a partition /dev/sda3, resized it using cfdisk, created /dev/sda4 out of it, executed command mkfs.ext4 /dev/sda4 and now I can't access the resized /dev/sda3!
Dolphin says: "Error mounting /dev/sda3 .... : wrong fs type"! Is there a way to recover the partition /dev/sda3 along with the data in it?
Last edited by emonhaque (2019-07-16 15:07:43)
Offline
What do you mean "resized it using cfdisk"??
Restore the *exact* old partition table, do *NOT* call mkfs on it.
Anything you might have overridden w/ the sd4 FS header is gone.
If you cannot recreate the *exact* old partitioning or you managed to override the FS headers of sda3, you're w/ tools like photorec and testdisk.
Repartitioning is NOT done this way: https://wiki.archlinux.org/index.php/Pa … partitions
If you manage to rescue your data, MAKE A BACKUP FIRST.
Offline
There's an option [Resize] in cfdisk and using that option I've reduced the size of /dev/sda3 and created /dev/sda4. Here's what cfdisk shows now about /dev/sda4
Partition UUID: BF898C73-109A-8442-9C7A-40A48856E3B9
Partition type: Linux filesystem (0FC63DAF-8483-4772-8E79-3D69D8477DE4)
Filesystem UUID: b36e96c4-6b1e-4b16-baaa-743ae14a021b
Filesystem: ext4
Mountpoint: /run/media/emon/b16e96c4-6b1e-4b26-baaa-743ae14a026b (mount
and for /dev/sda3
Partition UUID: 80E6DB56-2462-344C-BFEA-A9B017615EC1
Partition type: Linux filesystem (0FC63DAF-8483-4772-8E79-3D69D8477
Filesystem UUID: 251447bf-985c-4c73-bb9e-8010bfd53fd3
Filesystem: ext4
Last edited by emonhaque (2019-07-16 14:07:55)
Offline
How did you resize /dev/sda3, exactly?
Looks like you wanted to shrink sda3 to make space for a new sda4.
To shrink a EXT2/3/4 partition, one must first use resize2fs to shrink the filesystem, then, change the partition table to match the new size. Using cfdisk alone would have only altered the partition table.
Your great mistake is to have run mkfs.ext4 on the new partition sda4. Some of your data was likely overwritten on disk, as seth said above.
If your data is important enough, do a disk backup now using dd. I'd then try to recover things from the disk image file first, and avoid touching the physical disk until I'm certain what works.
EDIT
I don't know about cfdisk, but I think fdisk is more straightforward. Post the output of
fdisk -l /dev/sda
But first of all, you shouldn't mount the partitions at this point. If your data is important, and you want the best chance of recovery, don't touch the disk now. Make a disk image first.
Once you have done that, you can proceed to try and restore the partition table.
You don't seem to have done too much damage, I think...
Last edited by lolilolicon (2019-07-16 14:18:18)
This silver ladybug at line 28...
Offline
I just selected /dev/sda3, then selected [Resize], hit enter and put the size (500G) and hit enter again. After resizing /dev/sda3, I'd got some free space automatically, selected that free space and selected [New] and hit enter with the default size it gave. After all that, I'd selected [Write] and hit enter.
Last edited by emonhaque (2019-07-16 14:15:04)
Offline
you have to restore sda3 to its original size (same start sector, same size or larger than before is fine too)
I'm unfamiliar with cfdisk resize, but parted resizepart would do it. It just resizes the partition, it does not concern itself with the contents or filesystems of that partition.
obviously first you have to delete the offending partition now occupying the freed space. do not delete sda3.
if the new partition was formatted and the disk is SSD (or virtual machine disk), there is a risk all data in that partition has been discarded already... mkfs.ext4 discards data if the storage supports it
Last edited by frostschutz (2019-07-16 14:20:36)
Offline
Yeah, again: THIS IS NOT HOW IT'S DONE!
Do not write onto that disk. Not sda3, not sda4 either (if you have, you can kiss more data bye-bye)
Operating on a copy is probably a very good idea in this case, then restore the former partition table (essentially remove sda4 and re-grow sda3 (to the exact former size!)
Run partprobe and pray.
In case that's not clear, you data is not stored like this
##################......................................
but like this
##.#...###...#.#.......####.###.#....#....#.............
Offline
yep, have to shrink filesystem first (resize2fs) before you shrink partition. even if there was no data, it would complain out of principle, simply because the size the filesytem remembers is larger than the size of the partition now.
Offline
hmm! deleting /dev/sda4 and resizing /dev/sda3 to its original size caused some data loss! I've lost a 25GB folder I copied from my desktop last night! I'm not sure whether it's SSD.
Offline
You're pretty lucky!
Now you can consider setting up regular backups.
BTW, you can mark this [SOLVED] by editing the title.
Last edited by lolilolicon (2019-07-16 14:47:18)
This silver ladybug at line 28...
Offline
hmm! deleting /dev/sda4 and resizing /dev/sda3 to its original size caused some data loss! I've lost a 25GB folder I copied from my desktop last night! I'm not sure whether it's SSD.
even if it's not, the mkfs.ext4 on sda4 has written data all over the place (new superblock, backup superblocks, etc. - more if you actually copied anything to it) so natuarlly some damage may be in the sda3 filesystem that previously occupied this space.
it's also possible for files to be there but contain bad data (file metadata, and file contents, are stored in different places)
that 25GB you copied might still be "somewhere" just the metadata pointing to it damaged... who knows.
make backups in future
Last edited by frostschutz (2019-07-16 14:47:22)
Offline
I didn't have that much in /dev/sda3 other than that 25GB folder. Beside that, I'd Qt Installer, texlive2019 installer, archlinux2019 iso, Etcher and a few other text and pdf docs, everything recovered seems alright.
Qt and texlive2019 has been installed without any issue, Etcher also runs without any issue and documents open without any issue.
Offline
@frostschutz, is there any tool to recover that 25 GB? I used to use a tool in windows (can't recall the name right now) to recover deleted data from a disk.
Offline
Offline