You are not logged in.

#1 2025-10-24 12:03:03

pointerIs404
Member
Registered: 2025-09-15
Posts: 9

[SOLVED] How to compress disk in grub or in boot

Hello there.

This is my third, Arch installation, In the seconde I've add quite a few tweak up my system, one of em being 'btrfs' filesystem compression.

I made it work, but well did not understand the meaning of it, hence why I ended up shooting myself in the foot.

As for rule of thumb, btrfs's compression is You need a lot of space to save a lot of space.

Defrag, Balance, Copy on write, I painfully learned that they created new data and update the reference instead of morphing existing data

But that is problem when snapshot tool like snapper reference both new and old, refs.

Even worst as i had snapshot every hour, It silently ate away my drive, until it was to late to save (really I was too lazy to fix)

I won't dwell further, Back on topic I want an alternative, instead of managing drive on live environment, I wonder if not from grub or right before boot.

So that since none of my data is in use it can be compressed, balanced more easedly and original could be suppressed right away.

If I could just startup my pc, exec per file level compression and discard the original data it would be perfect

Last edited by pointerIs404 (2025-10-28 16:10:42)

Offline

#2 2025-10-24 12:41:04

Scimmia
Fellow
Registered: 2012-09-01
Posts: 13,724

Re: [SOLVED] How to compress disk in grub or in boot

I have no idea what you're asking

Offline

#3 2025-10-24 12:49:19

pointerIs404
Member
Registered: 2025-09-15
Posts: 9

Re: [SOLVED] How to compress disk in grub or in boot

Scimmia wrote:

I have no idea what you're asking

I want to compress my files, and decompress em in ram. I want the compression to happen while I'm in the grub or not on booted my main os

Last edited by pointerIs404 (2025-10-24 12:53:42)

Offline

#4 2025-10-24 14:01:52

cryptearth
Member
Registered: 2024-02-03
Posts: 2,092

Re: [SOLVED] How to compress disk in grub or in boot

I doubt that's possible because before an os loads and fully initialize the rest of the hardware the few resources available to early programs like bootloaders are not meant for such - let alone grub has even a capable btrfs driver to handle that

Offline

#5 2025-10-24 15:06:58

unixman
Member
Registered: 2015-03-12
Posts: 182

Re: [SOLVED] How to compress disk in grub or in boot

how about initrd. Put needed stuff into it.
Stay in there do what you want.

Offline

#6 2025-10-24 15:25:11

pointerIs404
Member
Registered: 2025-09-15
Posts: 9

Re: [SOLVED] How to compress disk in grub or in boot

unixman wrote:

how about initrd. Put needed stuff into it.
Stay in there do what you want.

I was heading, for a secondary os as recovery/maintenance mode, but your proposition seems right on the money.

From the description:

- It runs before any data or snapshot is active
- I can pack it with exactly what I need
- It's fully scriptable with hooks

PERFECT, HUNDRED THANKS

I'll Try and come back when I manage to make it real

Last edited by pointerIs404 (2025-10-24 15:26:56)

Offline

#7 2025-10-28 16:08:33

pointerIs404
Member
Registered: 2025-09-15
Posts: 9

Re: [SOLVED] How to compress disk in grub or in boot

unixman wrote:

how about initrd. Put needed stuff into it.
Stay in there do what you want.

After days,
Many attempt where I ended up breaking my kernel,
Many reinstall to the point where I can do it without the wiki, it works, or worked once at least,

Dunno, luck not being on my side, electricity betrayed during a `mkinitcpio -P`.

Well, point is it worked once, and I've learned a lot, thanks for the tips on `initrd`.
The brfs stuff, is off limit for me till, I got some vacation though,

Last edited by pointerIs404 (2025-10-28 16:13:24)

Offline

#8 2025-10-28 17:40:52

unixman
Member
Registered: 2015-03-12
Posts: 182

Re: [SOLVED] How to compress disk in grub or in boot

more tips:
* build a custom static kernel as initrd embedded & batteries included & needed modules builtin;  just use for this specific job.
    you can embed some default kernel cmdline too if you want.

* give up / dont bother mkinitcpio P instead:

     mount some unused /dev/xxx as /mnt then "pacstrap base foo bar /mnt"
     or  "pacman  root=/mnt base foo bar"  whatever like.
     then make an initrd of that /mnt. eg: cd /mnt; find . | cpio -oH newc -F ../initrd.cpio; cd ..; gzip initrd.cpio

     make sure some "init" exists under /mnt or you have to provide init=/foo/bar as kernel cmdline.

    kernel default looks  /init, /sbin/init and as last resort /bin/sh to execute as init.

if that init much wrt megabytes then remove garbage from there.

you can put an  init as dump as:

#!/usr/bin/sh
export PATH=/usr/bin
export TERM=linux
#export USER=root

exec sh
#exec sh -l

otherwise systemd is started as init and then it maybe crashed/not works because you forgot to enable something in kernel.(say cgroups)

Last edited by unixman (2025-10-28 17:53:12)

Offline

Board footer

Powered by FluxBB