1

I'm pretty new to linux.

When I installed this system I chose to use the LVM and apparently made a 256 mb boot partition, which soon became full. I tried to shrink /dev/sdb5, which was contained in /dev/sdb2, using gparted, which wouldn't work.

I decided to check out the options under the disks utility and changed the partition type of /dev/sdb2 to something else, since I tend to learn about things by messing with them. I did not expect the changes to take effect immediately, like when using gparted, but they did.

Is there any way in which I can get /dev/sdb2 and /dev/sdb5 back to the way it was? I will gladly provide any further required information.

Edit: I went and ran boot-repair and got a pastebin which contains a lot more information: http://paste.ubuntu.com/23060938/

Edit2: I ran boot-repair and told it to repair. It now calls /dev/sdb2 the boot drive while gparted still lists the file system as unknown. I have no idea whats going on and am considering just getting a fresh ubuntu install. The pastebin from the repair: http://paste.ubuntu.com/23061013/

Edit3: Since the drive with /dev/sdb was not my main data disk, in reinstalled Ubuntu (this time without LVM) and this question is therefore no longer as necessary. I am still interested in whether this was even possible.

Xizam
  • 113
  • 4

1 Answers1

1

I realize you've re-installed Ubuntu, so the below is largely moot; however, in case somebody else has a similar problem, I'll respond fully. You may want to skip to the last paragraph for advice on avoiding this sort of problem in the future....

It sounds like /dev/sdb2 had been an extended partition that held the logical partition, /dev/sdb5. Ordinarily, partitioning tools don't let you change the type of an extended partition, since doing so is almost always a Bad Idea. It sounds like you used some badly-written software that didn't impose such a sensible restriction, though -- or perhaps you used a low-level disk editor, which you should never do unless you're an expert on whatever you're trying to edit. In any event....

The first thing you should do is to perform a low-level backup of the entire disk, or at least of /dev/sdb2. Something like this should do the trick:

sudo if=/dev/sdb of=/path/to/lots/of/space/sdb-backup.img

This command backs up /dev/sdb to /path/to/lots/of/space/sdb-backup.img, which as the name implies should be a directory with lots of free space -- at least 119.2 GiB, in your case, since that's the size of /dev/sdb. Having a backup will enable you to recover to the current state, in case something further goes wrong -- as it might well, since any recovery attempt runs the risk of creating new and worse problems.

With the backup made, the best recovery approach is probably to delete /dev/sdb2 using Linux's fdisk. I emphasize the use of fdisk because I know it won't write into /dev/sdb2, just delete the data structures that define it. I don't know if whatever you used to change the type of /dev/sdb2 might do more than this.

With that done, use TestDisk to recover your lost partition(s). This tool scans a disk for signs of filesystems and other data structures that reside in a partition, such as LVM definitions. Note that you want TestDisk to recover your LVM, not the logical volumes that reside inside it. Thus, if TestDisk gives you the option of recovering an LVM or (say) an ext4fs partition, tell it to recover the LVM. With any luck, when you reboot you'll see your LVM restored.

Using an LVM can simplify filesystem changes within the LVM, but if you need to reallocate space outside of the LVM, the LVM actually complicates matters. Some versions of GParted won't touch an LVM physical volume (partition), since it doesn't know how to resize it. To resize an LVM setup, you must jump through some extra hoops, which are described (among other places) here and here. I generally prefer creating two or three LVM partitions of varying size so that I can move logical volumes off of one of them, delete it, and re-allocate space outside of the LVM as necessary.

Rod Smith
  • 44,284
  • 7
  • 63
  • 105
  • I was still curious as to what I could have done, thanks for letting me know. Always good to learn more. – Xizam Aug 20 '16 at 09:16