Help me fix my partition (Linux)


  • BINNED

    So, I dun goofed a bit... I was rejiggering my disk and OS layout (dual boot of Debian and Windows 10 on a 128GB SSD just doesn't work out with Windows being a greedy disk space hog), and went about setting up LVM for my Linux install. Initial disk layout was something like:

    2.3 TB ext4 partition mounted as /home
    700 GB NTFS partition mounted as whatever
    

    This was on my 3TB spinning rust drive, obviously. So, I reduced the large ext4 partition by about 60GB to fit in my install. I also wanted to make that part use LVM to give me more flexibility if needed (the 2.3TB one was not set up as LVM because I want to be able to access it from Windows using ext2fsd).

    In the end, this worked out. BUT. Somewhere along the line I managed to "convert" my large ext4 partition to LVM. I put "convert" in quotes because it didn't format anything, really, it just messed with the partition table.

    So, after realizing my fuckup, I went about and took the following steps:

    1. I checked that the files were still accessible in some form at least since photorec was able to pull files no problem.
    2. Using gdiskI set the partition type to 8300 which is Linux Filesystem according to its list
    3. Ran fsck.ext4 on the partition. This recovered the superblock and it's now mountable if I explicitly give it the type (so, mount -t ext4 /dev/sdb1 /media/ohshit works fine)

    So yeah, I can access my data, all fine... ish.

    ❯ sudo blkid | grep /dev/sdb1
    /dev/sdb1: UUID="LAzbzz-B8fD-7c3h-dinr-zp8S-TR9W-GaVAuU" TYPE="LVM2_member" PARTUUID="fe82d7f0-a255-430b-906d-0a22ad219eee"
    

    As you can see, it still shows LVM2_member in the TYPE field. There are errors being spewed at boot due to that, and, more importantly, trying to add this partition as an fstab entry fails, meaning I can't just simply mount it as /home using that method.

    Anything I can do about this? I don't have a spare drive with enough space to swallow a format as a viable option. I'm buttuming I could cram some arcane arguments into fstab to force it to mount, but I'm still not too happy about it. If there's a proper fix, I'm all ears.



  • @onyx If you successfully converted it, I think grub still wants a non-lvm boot partition, or so it happened last time I was messing with this stuff.


  • BINNED

    @sockpuppet7 boots fine from LVM actually. Our standard deployments at work are Debian installs with full LVM layout, works fine. I think your /boot/uefi partition needs to be a plain primary partition though, if you're using UEFI boot that is. I actually don't, seems like my system was set to "Legacy, then UEFI" and Windows installed in legacy mode as the result. Since I didn't want to reinstall it again, I just stuck with legacy boot for now.



  • What does /etc/fstab have for that? I've got this:

    0_1516830423719_fc6c07cd-779c-4279-a739-9cbdad4cb2c6-image.png


  • BINNED

    @ben_lubar

    ❯ sudo cat /etc/fstab
    [sudo] password for onyx: 
    # /etc/fstab: static file system information.
    #
    # Use 'blkid' to print the universally unique identifier for a
    # device; this may be used with UUID= as a more robust way to name devices
    # that works even if disks are added and removed. See fstab(5).
    #
    # <file system> <mount point>   <type>  <options>       <dump>  <pass>
    /dev/mapper/vg--debian-vg--root /               ext4    errors=remount-ro 0       1
    /dev/mapper/vg--debian-vg--home /home           ext4    defaults        0       2
    /dev/mapper/vg--debian-vg--swap none            swap    sw              0       0
    

    No, no separate /boot, I'm not doing shit crazy enough to need it.



  • @onyx if the partition having problems is /home, I guess you could try making that also use errors=remount-ro.


  • BINNED

    @ben_lubar said in Help me fix my partition (Linux):

    @onyx if the partition having problems is /home, I guess you could try making that also use errors=remount-ro.

    Those are the current entries, I created a small temporary partition for /home during install because I didn't want it messing with the partition and doing something silly. I tried adding the actual UUID into fstab and rebooting, it complained and failed to mount it due to "Unknown type: LVM2_member" or similar, apparently logrotate is set up in a way where it deletes old syslogs completely so I can't check right now.

    The thing is, that's what mount tells me as well, it's just that I can mount it by forcing the type to ext4



  • @onyx I Googled LVM2_member and the first result was this:

    Is that something you've already tried?


  • BINNED

    @ben_lubar That's about mounting an actual LVM volume. In my case, it's just a plain ext4, but the partition table got messed up and it's now marked as an LVM volume, which it is not. The gdisk step I described above half-solved it (it wouldn't mount at all before that), but it's still half-wrong (it's marked as LVM even though it's not).

    So yeah, no jiggy, the only part that makes sense on there is formatting it to ext4, but that's the thing I'm trying to avoid.



  • @onyx said in Help me fix my partition (Linux):

    @ben_lubar That's about mounting an actual LVM volume. In my case, it's just a plain ext4, but the partition table got messed up and it's now marked as an LVM volume, which it is not. The gdisk step I described above half-solved it (it wouldn't mount at all before that), but it's still half-wrong (it's marked as LVM even though it's not).

    So yeah, no jiggy, the only part that makes sense on there is formatting it to ext4, but that's the thing I'm trying to avoid.

    Have you tried mkfs.ext4 -n (-n means "just tell me what you're going to do and then don't actually do it")?


  • BINNED

    @ben_lubar not on my system, apparently

    ❯ sudo mkfs -h
    
    Usage:
     mkfs [options] [-t <type>] [fs-options] <device> [<size>]
    
    Make a Linux filesystem.
    
    Options:
     -t, --type=<type>  filesystem type; when unspecified, ext2 is used
         fs-options     parameters for the real filesystem builder
         <device>       path to the device to be used
         <size>         number of blocks to be used on the device
     -V, --verbose      explain what is being done;
                          specifying -V more than once will cause a dry-run
     -V, --version      display version information and exit;
                          -V as --version must be the only option
     -h, --help         display this help text and exit
    
    For more details see mkfs(8).
    

    Either way...

    ❯ sudo mkfs -t ext4 -VV /dev/sdb1
    mkfs from util-linux 2.29.2
    mkfs.ext4 /dev/sdb1
    

    Not very helpful, damned thing...



  • @Onyx I think you're looking at the wrong command:

    ben@australium:~$ ls -l /sbin/mkfs.ext4
    lrwxrwxrwx 1 root root 6 Oct 30  2015 /sbin/mkfs.ext4 -> mke2fs
    

  • BINNED

    @ben_lubar Fuck me, I always buttumed those are just aliases... Anyway, it's not happy with me trying that while mounted, I'll have to either reboot or mount the backup /home partition instead, but I think it'll wait until tomorrow since it's pretty much bedtime now.


  • Notification Spam Recipient

    @onyx Is it tomorrow? Did it work?



  • According to libblkid source code, LVM2 partitions are recognised by finding LABELONE in them. For some reason, you have a somewhat valid LVM header on your ext4 partition. Try to find that LABELONE with a hex editor (hexedit /dev/sdb1 should be okay, but watch out for slightly weird key mappings described in man page) and replace any of the letters, maybe?


  • BINNED

    @tsaukpaetra said in Help me fix my partition (Linux):

    @onyx Is it tomorrow? Did it work?

    It is. I'm at work though, no fiddling until I get home.

    @aitap said in Help me fix my partition (Linux):

    According to libblkid source code, LVM2 partitions are recognised by finding LABELONE in them.

    Wow, that's... creative. I'll take a look, cheers.


Log in to reply