Is there a way to run fsck when boot failed? #2104
-
Sometimes the VM failed to boot because of the filesystem crashed. Currently I have to delete the diffdisk and create a new instance, but there maybe some important data I want to keep. How can I run the fsck for the diffdisk to fix? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Hmm, maybe it would need some kind of emergency disk But I guess in the long run one would have to put important data on a separately created data disk. So that it can be mounted again, after the os disk has been recreated... |
Beta Was this translation helpful? Give feedback.
-
$ brew install e2fsprogs
$ qemu-img convert -O raw ~/.lima/default/diffdisk tmpdisk
$ diskutil image attach --noMount tmpdisk
/dev/disk2 GUID_partition_scheme
/dev/disk2s14 Bios Boot Partition
/dev/disk2s15 EFI
/dev/disk2s16 BC13C2FF-59E6-4262-A352-B275FD6F7172
/dev/disk2s1 Linux Filesystem
# NOTE: "disk2s1" may differ
$ $(brew --prefix)/opt/e2fsprogs/sbin/fsck.ext4 /dev/disk2s1
e2fsck 1.47.0 (5-Feb-2023)
cloudimg-rootfs: recovering journal
Setting free inodes count to 12900880 (was 12901145)
Setting free blocks count to 24753564 (was 24756346)
cloudimg-rootfs: clean, 75248/12976128 files, 1198431/25951995 blocks
$ diskutil eject /dev/disk2
Disk /dev/disk2 ejected
$ mv tmpdisk ~/.lima/default/diffdisk |
Beta Was this translation helpful? Give feedback.
BTW, recreating the instance with
--vm-type=vz
may increase the stability of the disk image (since Lima v0.19)