-1

Currently in our code we check for disk space usage to stop doing something if the filesystem is above 95% in disk space usage. The way I'm checking for that is :

diskusage=$(df -P | grep "/dev/mtdblock\\|/video" | awk '{ print $5 }' | sed 's@%@@g')

The problem is we are trying to upgrade to a new hardware and the new df returns a different "main storage" path, stored on /dev/mmcblk0p2 instead of /dev/mtdblock

df
Filesystem     1K-blocks    Used Available Use% Mounted on
udev               10240       4     10236   1% /dev
tmpfs             204848     236    204612   1% /run
/dev/mmcblk0p2   7268964 1289904   5609808  19% /

My question is, is there a way to rename the /dev/mmcblk0p2 to /dev/mtdblock? I'd like to have a consistent codebase without having 2 different code bases on each system so during updates it's less mind-boggling to manage.

I've attempted using e2label but that doesn't seem to actually change where the partition name under df. Any help would be greatly appreciated and please be as verbose as possible (backend code writer dabbing into sys-admin!)

David Ma
  • 1
  • 1

1 Answers1

2

Can't you just expand your grep expression a bit like so

grep "/dev/mtdblock\\|/dev/mmcblk0p2\\|/video"

This would match both variants.

Sven
  • 98,649
  • 14
  • 180
  • 226
  • So that's a possibility to explore, but we would have to do a manual update on the existing 15k boxes that we have to ensure that the code base stays consistent between the new boxes and old boxes. I was kind of hoping that we could change the imaging process on the new boxes to match the architecture to avoid confusion in the future. Thanks for your suggestion and any further input is appreciated – David Ma Dec 14 '16 at 17:43
  • If your environment uses `udev`, it might be possible to alter the naming scheme for the device in question on the new system, or even add an alias/link to it, but I know a lot less about `devfs`/`udev` then I'd want to know so I'll just point you in that direction to investigate. – Sven Dec 14 '16 at 18:00