1

Is it safe to use fstransform?

tng
  • 61
  • 2
    Maybe easier to switch back to the old UUID with the help of tune2fs. However, this question should be splitted into a question and an answer to fit the format of a Q@A site, thanks. – mook765 Jun 30 '24 at 21:26
  • Thanks for the great tip with tune2fs, I didn't notice it. I'd like to create a how-to guide (not a question) to share so other can fix it quicky. How can I do that here at askubuntu? – tng Jun 30 '24 at 21:33
  • 1
    Just make it a question (How to convert OS partition from XFS to ext4) and the post an answer to your own question, shouldn't be to complicated. you can copy most of your current question into an answer. Hint: make use of the edit-button under your question. – mook765 Jun 30 '24 at 22:05

1 Answers1

1

The following steps are for a Kubuntu 24 release with a XFS file system on a 60GB NVMe partition (/dev/nvme0n1p3). I booted Kubuntu from a USB drive (by selecting 'Try Ubuntu') with a network cable connected, and then converted the file system to ext4:


apt install fstransform
lsblk -f  (This step is added based on Mook765's suggestion in comment; save the UUID for later) 
fstransform /dev/nvme0n1p3 ext4 

fstransform works smoothly; however, it generates a new UUID for nvme0n1p3, which does not match the old GRUB settings on the Linux system AND the grub.cfg file in the EFI System Partition (ESP; /boot/efi/EFI). This means the boot process gets stuck at

grub>

Here is some output from fstransform:

21:09:07 fstransform: unmounting device '/dev/nvme0n1p3' and remounting it read-write
21:09:07 fstransform: connected loop device '/dev/loop9' to file '/tmp/fstransform.mount.4641/.fstransform.loop.4641'
21:09:07 fstransform: formatting loop device '/dev/loop9' with file-system type 'ext4'...
21:09:07 fstransform: mounting loop device '/dev/loop9' on '/tmp/fstransform.loop.4641' ...
21:09:07 fstransform: loop device '/dev/loop9' mounted successfully.
21:09:07 fstransform: preliminary steps completed, now comes the delicate part:
21:09:07 fstransform: fstransform will move '/dev/nvme0n1p3' contents into the loop file.
21:09:07 fstransform: WARNING: THIS IS IMPORTANT! if either the original device '/dev/nvme0n1p3'
                      or the loop device '/dev/loop9' become FULL,
                       
                       YOU  WILL  LOSE  YOUR  DATA !
                       
                      fstransform checks for enough available space,
                      in any case it is recommended to open another terminal, type
                        watch df /dev/nvme0n1p3 /dev/loop9
                      and check that both the original device '/dev/nvme0n1p3'
                      and the loop device '/dev/loop9' are NOT becoming full.
                      if one of them is becoming full (or both),
                      you MUST stop fstransform with CTRL+C or equivalent.
                       
21:09:07 fstransform: moving '/dev/nvme0n1p3' contents into the loop file.
21:09:07 fstransform: this may take a long time, please be patient...

Before booting from GRUB, the new UUID of /dev/nvme0n1p3 needs to be updated in three files. However, updating these files alone will not resolve the GRUB issue. We also need to run 'update-grub' in a later step when /dev/nvme0n1p3 is mounted with read/write access..

MODIFY: Mook765 recommends using tune2fs to update /dev/nvme0n1p3 with the OLD UUID, so you can skip changing the UUID in step 1 below. However, you still need to update the file system type from XFS to ext4 in /mnt/etc/fstab. https://www.tecmint.com/change-uuid-of-partition-in-linux/

  1. Boot from USB and mount /dev/nvme0n1p3 at /mnt
root@kubuntu:/mnt/boot/grub# lsblk -f
nvme0n1                                                                                     
├─nvme0n1p1                                                                                 
├─nvme0n1p2 ntfs           nvm2        01DAC93D729A3DF0                                     
└─nvme0n1p3 ext4     1.0               3a55348c-1c97-46d7-824f-6957787fc22b     46G    22% /mnt

NB: the old xfs nvme0n1p3 had 459997d8-1ef6-4258-9af4-d268f0e02603

Replace ALL the old UUID with the new one for those three files /mnt/etc/fstab (and also change xfs to ext4), /mnt/boot/grub/grub.cfg and /boot/efi/EFI/ubuntu/grub.cfg

  1. umount /mnt, reboot and remove the USB.

  2. At the GRUB prompt (grub>), I use this guide to proceed, utilizing commands like ls, cat, and TAB completion to check the files on the linux partition. https://www.linuxfoundation.org/blog/blog/classic-sysadmin-how-to-rescue-a-non-booting-grub-2-on-linux

  3. Setup my linux device and kernel parameters before boot nb: replace nvme device with /dev/sdX if using SSD disk

  4. If you have followed step 4 correctly, your old Linux system will boot up with the new ext4 file system

  5. Run "update-grub" to update the grub menu, don't need to run "grub-install". Reboot

THANKS!!!!

ps: I just issued a comment about the UUID to fstransform developer Massimiliano Ghilardi on Github.

tng
  • 61