2

I have a problem booting into my Ubuntu 20.04.5 partition (I have it installed in dual boot with Windows 10). Yesterday I was working on Ubuntu and I kept having messages saying that my disk space was low (about 60Kb), I had to switch to Windows but after that I was unable to reboot into Ubuntu. This is the error I have:

[FAILED] Failed to start **Load/Save Random Seed**

I'm on a btrfs file system. What can I do? Thanks

simone viozzi
  • 316
  • 1
  • 8

1 Answers1

0

Since you are on btrfs you can leverage the characteristics of this file system.

But first, a couple of things to not do:

  • try to delete files from the windows partition, by nature btrfs use CoW so no free space will be created
  • trying to interact with subvolumes without using the btrfs command

Now, what you can do:

  1. create a live usb with the latest Ubuntu or whatever you prefer
  2. boot from the live, select "try Ubuntu"
  3. now from the explorer you can mount the Ubuntu partition, you will see the subvolumes @ and @home, also if you use timeshift you will also see the timeshift folder. You can check the full list of subvolumes with btrfs subvolume list .. I will call the path where @ and @home are <btrfs-root>.
  4. if you have Timeshift you could try to delete some snapshot and maybe this will free enough space to boot into the system again: btrfs subvolume delete ./timeshift/<date>

If this didn't work or if you also want to expand the btrfs partition, you can use btrfs send / receive to temporarily move the @ and @home subvolumes to an external drive, then expand the partition and finally put the subvolumes back into their place.

  1. Get an external hdd big enough to store the data, so the size of the partition, and connect it. Open it with the explorer, create a folder and copy its path. Pay attention if the path contains spaces, in that case it will need to be used surrounded by ". I will call this path <ext-hdd>.
  2. Open a terminal and go to <btrfs-root>, now we are going to set the subvolumes as read only*: btrfs property set -ts ./@ ro true and btrfs property set -ts ./@home ro true. (* you could create a read only snapshot, but since we are out of space, I doubt this would work. )
  3. Now we can use btrfs send to convert the file system into a file: btrfs send ./@ > "<ext-hdd>/root.img" and btrfs send ./@home > "<ext-hdd>/home.img". You can check the progress by watching the properties of the files. If you want, you can repeat this process to the timeshift snapshots and save them too.
  4. At this point, you can detach the external hdd and reboot to windows and shrink its partition.
  5. Reboot into the live usb, and use gparted to:
    1. Delete the old btrfs partition (all the data is on the external hdd, you won't lose anything).
    2. Create a new btrfs partition that include the empty space left by shrinking windows.
  6. Open a terminal in the new btrfs partition, I will call this path <btrfs-root-new>.
  7. You can check that the space is effectively expanded with btrfs filesystem usage ..
  8. btrfs receive -f "<ext-hdd>/root.img" ./root and btrfs receive -f "<ext-hdd>/home.img" ./home. After the process complete, you will see the 2 folders in the <btrfs-root-new>. You can check that btrfs recognize the subvolumes with btrfs subvolume list ..
  9. The newly created subvolumes are read only, to make them rw we can create a snapshot: btrfs subvolume snapshot ./root ./@ and btrfs subvolume snapshot ./home ./@home
  10. Now we can delete the read-only subvolumes: btrfs filesystem sync ., btrfs subvolume delete ./root ./home
  11. At this point, the system is kinda back into its original place, but the UUID of the partition is changed and grub is broken. To fix this stuff, we are going to chroot into the btrfs system (following this answer).
    1. Let's create a folder where we are going to mount the @ subvolume: sudo mkdir -p /data/ubuntu
    2. We need to know the names of the btrfs and the efi partitions, we can get it with lsblk. Let's suppose the btrfs partition is /dev/<btrfs> and the efi one is /dev/<efi>. Double-check the names!
    3. Now you can start mounting stuff:
      sudo mount /dev/<btrfs>  /data/ubuntu -o subvol=@
      sudo mount /dev/<efi> /data/ubuntu/boot/efi
      sudo mount --bind /sys /data/ubuntu/sys
      sudo mount --bind /proc /data/ubuntu/proc
      sudo mount --bind /run /data/ubuntu/run
      sudo mount --bind /dev /data/ubuntu/dev
      
    4. sudo chroot /data/ubuntu. If this works, there are good possibilities that the system will work after a reboot. You are now chrooted into the btrfs partition.
    5. Let's fix fstab first. You can get the new UUID with lsblk -fs. Copy the one relative to <btrfs>. Then edit /etc/fstab with nano or vim, and replace the UUID for the lines relative to / and /home with the one copied before.
    6. Now we can repair grub: grub-install /dev/<efi> and update-grub
  12. Exit from the chroot environment and reboot the system. If things worked as intended you will have your system back as you left it!
simone viozzi
  • 316
  • 1
  • 8