Announcement

Collapse
No announcement yet.

Converting a disk from a whole btrfs device to a partitioned drive with grub

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Converting a disk from a whole btrfs device to a partitioned drive with grub

    I have a 2TB drive that was for a year or so a full-device btrfs filesystem1. I decided to convert is back to a partitioned device so I could install grub on it as grub cannot install on a drive completely used by btrfs. I am planning on upgrading this year, so I decided to prep this drive properly and use a GPT table instead of the older MBR. So I deleted the btrfs filesystem on it and then partitioned it with gdisk and created a new btrfs partition in partition 1. All went swimmingly - or so I thought.

    Then when I tried to install grub, it failed with this message:
    grub-install: warning: Attempting to install GRUB to a disk with multiple partition labels. This is not supported yet..
    grub-install: error: filesystem `btrfs' doesn't support blocklists.
    which I thought was dumb because I had removed btrfs from the MBR area. So I wiped the first 5122 bytes with zeros and tried again. Same error. I then searched for many long hours looking for someone else who had encountered this; nada. I did find info on grub with GPT discs. It seems GPT and grub aren't really all that compatible on an older BIOS based PC using GPT on it drives. You have to create a special small partition for grub to use on a GPT disc called a "bios_boot" partition. OK, so I did that - still no go. Grub-install fails with the same error and grub did not seem to recognize the bios_boot partition at all.

    A few more hours mucking about and I pulled out the dd hammer and wiped the first 210MB with zeros. Well, this changed things, but not for better. Now grub-install says this:
    grub-install: error: unable to identify a filesystem in hostdisk//dev/sdi; safety check can't be performed.
    However, at least this as easier to fix. I went back into gdisk and created a new partition table with partitions - including the new bios_boot partition and saved it. Finally, success! grub-install found the bios_boot partition and installed without a hitch.

    Apparently, btrfs,GPT and grub use a lot of the same space and don't play all that well together. Since I could find little on this situation, I thought I had better document it.

    Here are the steps to convert a btrfs drive to a GPT drive with grub on a bios based (non-efi) computer:

    1. Backup your data.
    2. Wipe the old table and btrfs data with dd (how much is actually needed I will update when I find out):
    sudo dd if=/dev/zero of=dev/sdX bs=4M count=50
    3. Create a new GPT partition table and make your first partition 1M in size and type "ef02".
    4. Fill in the rest of your partitions and save the new table.
    5. Run grub-install.
    6. Format your new partitions.
    7. Adjust fstab as needed.

    1) For those who aren't familiar: btrfs can reside on an entire device without a partition table. As in: sudo mkfs.btrfs /dev/sdc Note the lack of a partition number!
    2) The first 512 bytes of your MBR disk hold the boot record and partition table info.

    Please Read Me

    #2
    Nice write up ,,,,,,,,this is good info.

    VINNY
    i7 4core HT 8MB L3 2.9GHz
    16GB RAM
    Nvidia GTX 860M 4GB RAM 1152 cuda cores

    Comment


      #3
      What Vinny said ... this could save somebody a lot of grief.

      Originally posted by oshunluvr View Post
      3. Create a new GPT partition table and make your first partition 1M in size and type "ef02".
      Is there a recommendation for the filesystem type for this partition?

      Comment


        #4
        No filesystem needed for grub2. Once I cleared the old partition tables completely off, grub-install found the ef02 partition and used it. Basically, it's purpose is to reserve space for grub's stage 1.5/2 files. With efi, you have the efi partition. With BIOS, you normally don't have a special partition so this one is needed.

        Interestingly; once booted the system doesn't see the partition at all - blkid doesn't report it. I suspect if I dump it's contents, it will look very similar to the MBR-grub portion of my other disks.

        It doesn't have to be 1M BTW, I just used that size because it aligns properly. This is a WD Red 2TB AF drive.

        Additional note: When it was all said and done, os-prober on 14.04 on another disk doesn't see the install on the GPT drive. Seems there's 2 versions of grub - one for BIOS PC's and one for efi. I don't know if I can switch to the efi version even though I'm on a BIOS pc. Still digging into this one...

        Please Read Me

        Comment


          #5
          I may have to try this. Want to move my 3Tb drive to an AIO with kubuntu installed if the 1Tb gets full (I store lots of stuff). Last time I tried, nothing worked, so I put the 3Tb in my win7/kubuntu/kali/fedora box, but it already has 2 1tb drives, so plenty of space

          Comment

          Working...
          X