Shrinking ext4 partition online.
Hello folks,
EXT4 file system cannot be shrunk online.This means you must either use live usb or dvd,or by another instance.
Another trick is to delete swapfile ,pacstrap Archlinux to it,update grub,boot from another instance.
These are the two methods to do, i knew until this day.Suddenly i got another idea.(I didn't put effort regarding this topic,maybe many use this method)
I did'nt try out,just asking if it is possible. Can't we add cfdisk or gdisk or gparted bianry to initramfs(mkinitcpio),so that we can edit live?
About this post
- Posted
- Archived
- Score
- 2 · 100% up
- Kind
- Text
- ID
- aze7pp
7 comments
I find it puzzling that EXT4, even on LVM, doesn't allow shrinking, while others like BTRFS does.
Yes. You can add any binary to initramfs, but the larger the program the slower the boot process as all of initramfs gets read to ram.
You will need to pull in the whole xserver and likely a window manager and I am not sure how hard it is to launch a graphical display from initramfs. Although I don't know anything that would prevent it I have never seen or heard of someone doing it.
Another option is to use a efi application that can partition things, someone has converted fdisk to run as an efi application but it does not look like it will handle filesystems.
This must be generic option,must also applicable to non-uefi systems(legacy boot).So,fdisk efi may not be the perfect solution.
If we add cfdisk or gdisk to initramfs,can we able to shrink ext4 online?can we unmount the partitions(including root filesystem)?
Initramfs is a ram filesystem. It contains everything needed to mount the root filesystem so when you first enter it the disk is not mounted. If you hijack the normal process you will end up in a minimal system with a ram only root and can thus do whatever you want to the systems disks. This is very similar to what a live usb does.
You could also use grub to boot into an ISO image located in the efi or boot partition (or anywhere not on the filesystem you want to resize).
you could do a custom "shrink this filesystem"-initcpio-hook, sure
but in the time it takes to write that, you can also boot a livecd, shrink, and reboot into arch
or if it's a (v)server, boot into the rescue system, shrink, reboot into arch
that leaves a server without rescue system but then I'd rather think about implementing a rescue system anyway than just some specific hack for one thing
Just use btrfs
I am using btrfs now.the point here is to shrink ext4 online.