You are not logged in.

#1 2019-02-05 01:02:44

angrysomoan
Member
Registered: 2016-12-18
Posts: 3

Recovering LVM on LUKS after deleting partitions table

Well, what have I done..

Accidentally I removed my partition table (my SD card was inside the reader, and device names changed after the reboot). Testdisk was partially successful at bringing back part of it, except the one (most important) partition. What I've got after looks like that:

sdb                        8:16   0 167.7G  0 disk  
├─sdb1                     8:17   0   512M  0 part  
└─sdb2                     8:18   0 167.2G  0 part  
  └─backuparch           254:4    0 167.2G  0 crypt 
    ├─archlinux_lvm-swap 254:5    0     8G  0 lvm   
    └─archlinux_lvm-root 254:6    0    32G  0 lvm   

But, going back to the beginning:
After getting this output from testdisk:

     Partition               Start        End    Size in sectors
>D FAT32                    0  32 33    65 101 36    1048576 [NO NAME]
 D Linux                   25 126 38  9118 105 11  146077696
 D Linux                   65 101 37    65 166 37       4096

I've added the partition:

>P Linux                   65 101 37 21888 254 63  350596161

After, lvscan does show missing partition

  WARNING: Device /dev/mapper/backuparch has size of 350592065 sectors which is smaller than corresponding PV size of 350597120 sectors. Was device resized?
  One or more devices used as PVs in VG archlinux_lvm have changed sizes.
  ACTIVE            '/dev/archlinux_lvm/swap' [8.00 GiB] inherit
  ACTIVE            '/dev/archlinux_lvm/root' [32.00 GiB] inherit
  inactive          '/dev/archlinux_lvm/home' [<127.18 GiB] inherit

But by calling

vgchange -ay

gives the same error as above:

  WARNING: Device /dev/mapper/backuparch has size of 350592065 sectors which is smaller than corresponding PV size of 350597120 sectors. Was device resized?
  One or more devices used as PVs in VG archlinux_lvm have changed sizes.
  device-mapper: reload ioctl on  (254:7) failed: Invalid argument
  2 logical volume(s) in volume group "archlinux_lvm" now active

So 5055 sectors are missing. While creating that partition I've included that 4096 sector-sized partition (LUKS header, i guess), but it's still too small.

I'm out of ideas, does anybody know what's going on and would be willing to help please?

Offline

#2 2019-02-05 02:09:32

frostschutz
Member
Registered: 2013-11-15
Posts: 1,658

Re: Recovering LVM on LUKS after deleting partitions table

`parted /dev/sdb unit s print free` ?

Online

#3 2019-02-05 09:06:31

angrysomoan
Member
Registered: 2016-12-18
Posts: 3

Re: Recovering LVM on LUKS after deleting partitions table

frostschitz, thank you for taking interest.

parted /dev/sdb unit s print free

Model: ATA INTEL SSDSCKKW18 (scsi)
Disk /dev/sdb: 351651888s
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags: 

Number  Start       End         Size        Type     File system  Flags
        63s         2047s       1985s                Free Space
 1      2048s       1050623s    1048576s    primary  fat32        boot
 2      1050624s    351646784s  350596161s  primary
        351646785s  351651887s  5103s                Free Space

Now I see some trailing sectors, and that area is a bit bigger than the missing one. How can I resize that partition? Testdisk won't l let me take any more sectors than I already did?
P. S. Parted says, that this is msdos partition table, but I had GPT. Does that change sectors a bit?

Offline

#4 2019-02-05 11:05:06

frostschutz
Member
Registered: 2013-11-15
Posts: 1,658

Re: Recovering LVM on LUKS after deleting partitions table

in parted, `resizepart 2 351651887s`, then check again with `unit s`, `print free` that it's correct

alternatively `resizepart 2 -1`

Last edited by frostschutz (2019-02-05 11:05:54)

Online

Board footer

Powered by FluxBB