1

I have a project that requires me to shrink the root and home volumes on an existing CentOS 6 install to make room for a CentOS 7 install on a customer's bare metal host. Yes, I know what a bad idea this is. We ought to be shipping our customer a brand new, fully configured server.

Anyhow, I'm wondering if there's any magic utility that can scan unmounted disk volumes and report back how much free space or (or what percentage) can be used when I eventually run lvreduce. Anaconda must do this but how to I use anaconda in the %pre section of my kickstart config file?

Thanks.

5
  • 2
    Trying to automate this should scare you senseless. I wouldn't. On that note, why don't you just upgrade it? Apr 24, 2019 at 17:25
  • Boss is more afraid of upgrading than of this dual install scheme. I think he's nuts.
    – mr.zog
    Apr 24, 2019 at 17:41
  • @anx Mounting the volume is an extra step, and incurs some (small amount of) extra risk.
    – mr.zog
    Apr 24, 2019 at 17:43
  • 2
    you can mount it read-only or even without journal reply. Finally, you can use more complex approach, as creating a dm-snapshot overlay over the base volumes. That said, please be aware that shrinking a filesystem is much more riskier than simply mounting it. For ext filesystem, check Zoredache answer below
    – shodanshok
    Apr 24, 2019 at 20:12
  • 1
    Mounting with -o ro shouldn't add risk. Still backup & upgrade seems ways less risky than an automated resize of a data filled file system on top of lvm.
    – hargut
    Apr 24, 2019 at 20:14

1 Answer 1

5

If the filesystem was ext[234] I would guess you could probably do something like tune2fs -l /dev/devicename.

# tune2fs -l /dev/sda3 | grep -i 'block'
Block count:              9865984
Reserved block count:     493299
Free blocks:              8871467
First block:              0
Block size:               4096
Reserved GDT blocks:      1024
Blocks per group:         32768
Inode blocks per group:   511
Flex block group size:    16
Reserved blocks uid:      0 (user root)
Reserved blocks gid:      0 (group root)
Journal backup:           inode blocks
1
  • Free blocks is all I need, probably.
    – mr.zog
    Apr 24, 2019 at 20:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .