0

On a deabian 8.2 system I made a new LVM partition with fdisk and wanted to issue a pvcreate command, but was constantly being called and then made this horrible horrible mistake. Before the call I checked if everything was ok:

Command (m for help): p
Disk /dev/sda: 50 GiB, 53687091200 bytes, 104857600 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x33eeab93

Device     Boot    Start       End  Sectors  Size Id Type
/dev/sda1  *        2046   1953791  1951746  953M  5 Extended
/dev/sda2        1953792  19531775 17577984  8.4G 8e Linux LVM
/dev/sda3       19531776  41940991 22409216 10.7G 8e Linux LVM
/dev/sda4       41940992 104857599 62916608   30G 8e Linux LVM
/dev/sda5           2048   1953791  1951744  953M 8e Linux LVM

Partition table entries are not in disk order.

After the call I thought I finished with fdisk:

Command (m for help): sudo pvcreate /dev/sda4
Created a new partition 1 of type 'Linux native' and of size 50 GiB.
Created a new partition 2 of type 'Linux swap' and of size 47.1 MiB.
Created a new partition 3 of type 'Whole disk' and of size 50 GiB.
Created a new Sun disklabel.

But it was still running and to make things worse I saved the changes.

Made a database dump and stored it on another machine. And now I am searching for a good solution hoping to implement tomorrow.

A option is to roll out another server and set it up and import the DB dump there, but that does not feel efficient and the database will be unreachable for a short moment.

Started searching the web and found http://tldp.org/HOWTO/Partition/recovering.html which would be a last resort option without rolling out another server. With testdisk I can see all the partitions and data I need, but the program is not that clear to me.

So I would like to ask, is testdisk a good option in this situation?

If so, please read the following:

When I start the program a list of disks is presented, here I can choose /dev/sda, but it also lists /dev/mapper/vg... & /dev/dm-... As I feel I messed with the whole disk I chose /dev/sda it finds the new 'Whole disk' partition, so I wont choose write here.

But when I pick /dev/mapper/vg-srv-lv-srv it detects a none type partition and I do get my ext4 partition under advanced and can copy files or make an image, change type or locate Superblock, but when I choose Analyse I can't write as the table type None is selected.

Should it be as simple as changing the partition type back with fdisk or selecting ext4 in testdisk, and write back the old partitions after analysing? Any extra details to be mindful of in case of LVM?

The program looks hopeful, but I don't feel confident enough to just go try and see what happens. Please advice. Also other solutions are welcome.

Thanks in advance from a person that will never answer the phone again when running fdisk.

4
  • Can i ask you, why you have all those partitions from sda2 to sda5 where you could have only sda2 and create logical volumes inside of it?
    – user34720
    May 10, 2016 at 16:42
  • @nwildner during the installation a few ext4 partitions were made and then I thought why not LVM, then set the partitions as LVM instead of ext4, of course big LVM partition could have been made. I don't think it has any advantage over a single large one per disk. Perhaps a few MB is lost because of this. May 11, 2016 at 8:39
  • I see. In my point of view, is not about megabytes but, easy management since this is why LVM was created. You add one partition of your disk, and then, you starts adding entire physical disks to a virtual group, being more easy to manage than having 5 partitions per disk...
    – user34720
    May 11, 2016 at 10:41
  • @nwildner True. It is easier and more logical and this is the result of a quick decision during install as stated above. May 11, 2016 at 14:29

1 Answer 1

0

I'm not sure what LVM did to the data on disk, but I once had some success using gpart on a disk that had its whole partition table wiped out. testdisk seems to be a similar tool.

I'd make a full disk-level backup first.

Good luck. :)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .