0

I'm working on a SBC6845 card with Linux on it: I have 4 partitions installed:

Creating 5 MTD partitions on "atmel_nand":
0x000000000000-0x000000100000 : "Factory"
0x000000100000-0x000000300000 : "Kernel1"
0x000000300000-0x000000500000 : "Kernel2"
0x000000500000-0x000008280000 : "Rootfs1"
0x000008280000-0x000010000000 : "Rootfs2"

I want to make a shell script that display which partition is currently used but I don't see how.

the command "df -h" returns:

# df -h
Filesystem                Size      Used Available Use% Mounted on
/dev/root               178.8G     65.4G    104.3G  39% /
tmpfs                    61.7M         0     61.7M   0% /dev/shm
tmpfs                    61.7M     36.0K     61.7M   0% /tmp

and also fdisk doesn't work on this system.

Anyone have an idea how to resolve this?

4

1 回答 1

1

所以您想知道您的脚本当前位于哪个分区?df可以帮助你!您只需将脚本的路径作为参数提供给它:

#!/bin/sh
df $0  | tail -1 | awk '{print $1}'

sh myscript.sh给我:/dev/sda1

说明:

  • df $0myscript.sh输出其中的分区
  • tail -1df忽略(列名)的第一行
  • awk '{print $1}'返回 的第一列df,即分区

我希望这是你所期望的!

于 2014-06-03T11:56:34.640 回答