2

I have Arch Linux installed on my computer along with Windows 10. When I installed the Linux, I only gave 35GB of space for the filesystem and now that I don't use Windows anymore, I wanted to resize the partition. I booted to the Arch live usb stick and deleted the linux partition. There were free space only before the Linux file system partition. I.e. my partition table looked something like this

Free space 1000000 1500000
/dev/sda6  1500000 2000000  Linux filesystem
/dev/sda7  2000000 2000400  Boot sector

No i made new Linux filesystem partition on the sector 1000000-2000000, but I don't know, how to shift the filesystem back, so that Grub will find the entry point for the operating system...

Is it possible to do this or should I just re-install Arch?

Thanks!

EDIT

I tried following this tutorial http://positon.org/resize-an-ext3-ext4-partition but resize2fs gave me only "Bad magic number in super-block while trying to open /dev/sda6"

  • So, you just wiped the linux partition, wrote another partition over it and now you're wondering where your filesystem is? Re-install. – Mioriin Feb 18 '18 at 12:41
  • I thought I only changed the partition table but didn't delete anything? – Miksu Feb 18 '18 at 12:42
  • Okay, to learn from this, what should I have done to expand the partition from the start of the sector? – Miksu Feb 18 '18 at 12:44
1

You're correct about the fact that only changing the partition table doesn't delete anything. However, there's no tool that I know of that can shift the filesystem. Here's what you can do to remedy the issue, assuming the free space is large enough to contain your Linux filesystem:

  1. Backup your system.
  2. Restore the partition table to what it was. Basically, what you want is to have the Linux partition start where it's supposed to in order to make the ext4 super block accessible.
  3. Create a new partition in the free space, and put the same filesystem type on it.
  4. Copy the files in sda6 to your new filesystem. You can use tar.
  5. Delete both, the old and new Linux partitions, and create a new one in its place which starts where the new partition started and ends where the old partition ended. Using your example: 1000000 to 2000000
  6. Use growfs so that your new Linux filesystem can utilize the now larger partition.
  7. Update your GRUB config so that it looks for the new partition. Not only has the partition changed, so has the filesystem identifier.
  • 1
    Hello? gparted? – psusi Feb 20 '18 at 19:40
  • @psusi Yes, or fdisk, or cfdisk. – Emmanuel Rosa Feb 20 '18 at 21:00
  • No, those can't move/resize partitions. – psusi Feb 20 '18 at 21:06
2

Okay, I got it! So I had lost the entrypoint to my filesystem but I knew the sector, where the partition ended. I shrunk the partition I made earlier to 36GB because it was originally 35GB. Then I executed ext2scan from this post to find the superblock. Then I made a partition starting from the sector the ext2scan found and ending in the sector I knew it had to end in. Then dumpe2fs found the superblock and my filesystem. Lastly I booted into grub-resque and fixed it.

1

So you deleted Linux filesystem (sectors 1000000-2000000) then you created another partition on top of it. And now you'd want your old filesystem back?

If you have mechanical Hard Disk Drive, it's possible to undo what you did, but DO NOT TRY TO WRITE ANY DATA ON NEW PARTITION(S) if you want them back.

FOLLOW THESE INSTRUCTIONS

  • Putting the actual answer (INSTRUCTIONS) here would make it a good answer, what happens when the link dies / changes? Besides, why not just use gpart / TestDisk like the link says "There are utilities such as gpart or TestDisk which can make this task considerably easier"? – Xen2050 Dec 19 '18 at 14:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.