Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: Can't boot after adding partition

  1. #1
    Join Date
    Feb 2019
    Beans
    7

    Can't boot after adding partition

    I'm hosting a LimeSurvey server using a Ubuntu VM. After some time I needed to add another partition adding 50GB to an existim LVM group. After adding the partition the structure looked like this:

    sda 100G
    ├─sda1 ext2 243M /boot

    ├─sda2 1K


    ├─sda3 LVM2_member 50G


    │ └─limesurvey--vg-root (dm-0) ext4 99.8G /


    └─sda5 LVM2_member 49.8G


    └─limesurvey--vg-root (dm-0) ext4 99.8G

    sda3 is the new added partition. All functioned fine until I restarted the VM after 3 months of usage:

    Gave up waiting for root device
    ALERT! /dev/mapper/limesurvey--vg-root does not exist. Dropping to a shell!

    So, it doesn't boot to ubuntu but stays in initramfsr. I can't use any backup for booting up except the ones before the partitioning.
    This is how I did the partitioning:




    Because of the partition adding the swap partition was removed so I added an additional swap file using this instructions:
    create a swap partition

    1. Create an empty file (1K * 4M = 4 GiB).

    sudo mkdir -v /var/cache/swap
    cd /var/cache/swap
    sudo dd if=/dev/zero of=swapfile bs=1K count=4M
    sudo chmod 600 swapfile

    1. Convert newly created file into a swap space file.

    sudo mkswap swapfile

    1. Enable file for paging and swapping.

    sudo swapon swapfile
    Verify by: swapon -s or top:
    top -bn1 | grep -i swap
    To disable, use sudo swapoff swapfile command.

    1. Add it into fstab file to make it persistent on the next system boot.

    echo "/var/cache/swap/swapfile none swap sw 0 0" | sudo tee -a /etc/fstab

    1. Re-test swap file on startup by:

    sudo swapoff swapfile
    sudo swapon -va


    Could anyone shed some light why after the restart of my VM, while it worked perfectly fine for 3 months, the partition broke down?

    Thank you!

  2. #2
    Join Date
    Jan 2019
    Location
    Moscow, Russia
    Beans
    50
    Distro
    Xubuntu 18.04 Bionic Beaver

    Re: Can't boot after adding partition

    fdisk -l /dev/sda output would be helpful.

    My guess is that you were creating partitions in this order:
    sda1 > sda2 > sda5 > sda3

    So initially it was:
    sda1 is primary
    sda2 is extended
    sda5 is logical (logical partition numbers are always 5+)

    MBR partition table is limited to 4 partitions, that's why they came up with the so-called extended partition.
    The extended partition is actually a primary partition that is used to store more partition records (so-called logical partitions).

    Then you probably have resized the VM disk, and the newly added space was appended to end of the disk. 100G total now. So, the extended partition still holds 50G. You create the new partition, but it cannot be added to your extended partition: no space left there. So the partitioning tool create a primary partition, giving it number 3.

    What you have then is the situation when partition numbers don't match their physical order:
    sda1 > sda2 > sda3 > sda5
    are actually physically ordered as
    sda1 > sda2 > sda5 > sda3

    Facilities used to mount LVM at boot probably don't expect that and fail.

    Fixing the logical order is not too hard: you just need to save fdisk -l output somewhere, delete wrongly numbered partitions and recreate them at the same sector positions they were and with the same types.

    You'd probably want something like this:
    sda1 is primary, 250M, /boot
    sda2 is extended, 100G
    sda5 is logical, 50G, LVM1
    sda6 is logical, 50G, LVM2

    For future VMs it would be better not to create a new partition for the newly added space, but just use pvresize to extend the size of the last partition:
    sda1 primary 250M /boot, sda2 primary 50G LVM
    to
    sda1 primary 250M /boot, sda2 primary 50G LVM, free 50G
    to
    sda1 primary 250M /boot, sda2 primary 100G LVM
    Last edited by dmnur; February 8th, 2019 at 05:23 PM.

  3. #3
    Join Date
    Feb 2019
    Beans
    7

    Re: Can't boot after adding partition

    Dmnur, thank you for your precise and knowledgeable answer. I can understand it clearly although I'm a Linux beginner.

    I would love to give you the fdisk -l /dev/sda output but I'm having problem doing that from the the initramfsr:



    Clearly I'm over my head in this but I'm ready to learn if you have the time to guide me through the process. Thank you kindly!

  4. #4
    Join Date
    Jan 2019
    Location
    Moscow, Russia
    Beans
    50
    Distro
    Xubuntu 18.04 Bionic Beaver

    Re: Can't boot after adding partition

    You're welcome, kristijanog.

    Quote Originally Posted by kristijanog View Post
    I would love to give you the fdisk -l /dev/sda output but I'm having problem doing that from the the initramfsr
    Yes, you won't be able to do this from initramfs, it's very minimalistic. I guess your VM is hosted by some VPS provider. They probably allow you to mount ISO images and boot from them.
    Boot from some kind of LiveCD, e.g. GParted Live or Ubuntu Desktop, and run the command from there.

  5. #5
    Join Date
    Feb 2019
    Beans
    7

    Re: Can't boot after adding partition

    Thanks a bunch!

    This is my fdisk -l output:



    The Extended (sda2) size confuses me. Shouldn't it be 100G considering the two LVM's, each with 50G space? If it should be like that (100G), what steps should I take to recreate the partitions after deleting them and recreating them (sda2, sda5 and sda3 -> sda2, sda5, sda6)? Should I, while recreating the sda2 partition, put the start at 501758 but the end at 209715199 where the newly created sda3 ends? Or am I not understanding the logic behind extended and LVM partitions?
    Last edited by kristijanog; February 9th, 2019 at 08:51 AM.

  6. #6
    Join Date
    Jan 2019
    Location
    Moscow, Russia
    Beans
    50
    Distro
    Xubuntu 18.04 Bionic Beaver

    Re: Can't boot after adding partition

    The extended partition must be of the size of all partitions it holds. Actually, its real size is just 1 KiB, as you could see in the lsblk output. The size the fdisk output shows is how much space that extended partition manages.

    First of all, back up your current partition table, just in case.
    Code:
    sudo dd if=/dev/sda of=sda-mbr.bin bs=512 count=1
    Save this sda-mbr.bin somewhere where you could get it later, like cloud storage.

    So, in your case you should do the following (I recommend using fdisk for partitioning, much easier to be precise in sector numbers):
    1. Delete partitions 2, 3, 5.
    2. Create a primary partition that starts at sector 501760 and ends at sector 104855551. Make sure its type is 8e (Linux LVM) (use the t command in fdisk). This will be your old sda5, new sda2.
    3. Create another primary partition: start 104900000, end 209715199. Again, make sure its type is 8e (Linux LVM). This will be your old sda3, new sda3.


    In this case you won't need the extended partition and logical partitions at all. Be careful though: only one slot remains! If you don't want to create more partitions, that's fine. As I said earlier, you won't need to create new partitions for extending your logical volumes. If, however, you need more, use this last slot to create the extended partition. Then, if you resize your VM disk, you would need to resize your extended partition for it to manage all new available space.

  7. #7
    Join Date
    Feb 2019
    Beans
    7

    Re: Can't boot after adding partition

    I'll try this method this afternoon and tell you the results.

    Spasibo dmnur!

    Kristijan

  8. #8
    Join Date
    Feb 2019
    Beans
    7

    Re: Can't boot after adding partition

    Hi,

    I followed your instructions but I get te same error while booting my Ubuntu VM. This is the current situation:






    I've made a backup of my VM prior doing this so nothing is lost. Is this maybe a LVM label problem?

    Thank you, I'm really novice at this After the problem is solved I'm getting myself a good Linux book before messing with partitions in the future.
    Last edited by kristijanog; February 9th, 2019 at 02:10 PM.

  9. #9
    Join Date
    Jan 2019
    Location
    Moscow, Russia
    Beans
    50
    Distro
    Xubuntu 18.04 Bionic Beaver

    Re: Can't boot after adding partition

    From the LiveCD, show the output of pvs, vgs and lvs commands.

    Also try to mount your logical volume and let's see what happens:
    Code:
    sudo mount /dev/mapper/limesurvey-vg-root /mnt
    Oh. I've actually noticed something else. Well, first things first.

  10. #10
    Join Date
    Feb 2019
    Beans
    7

    Re: Can't boot after adding partition

    pvs, vgs and lvs doesn't give me any output and I didn't succeed to mount


    Does the virtual group even exist in this case?

Page 1 of 2 12 LastLast

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •