Jack Bee
Jack Bee

Reputation:

How to know each solaris zone is occupying how much disk space?

IF I use the df command, I can only see in the Solaris server how much disk space is being used up. But I want to know how much diskspace a particular solaris zone is occupying

Upvotes: 3

Views: 10666

Answers (6)

Eric
Eric

Reputation: 41

The problem I found with these solutions is that they do not take into account directory inheritance. Yes, you will find out how much "space" is under a certain directory. But if you want to actually find out how much extra space a zone is taking, you have to go a different route. Do a

zonecfg -z zonename info

where zonename is the name of the zone. And look at each inherit-pkg-dir line.

inherit-pkgdir-dir:
      dir: /lib
inherit-pkgdir-dir:
      dir: /sbin

Any line that has inheritance is hard-linked to the zone. So you will be double counting against the global zone if you simply do a

du -sh /zonepath/zonename

Basically you have to count only the directories (excluding /proc, and maybe /tmp) that aren't listed in any inherit-pkg-dir lines.

cd /zonepath/zonename/root

du -sh /bin /dev /etc /home /kernel opt /system /var etc....

Upvotes: 4

Ray
Ray

Reputation: 21

Yes - definitely su to root to do this.

I was able to run: /usr/xpg4/bin/du -sk -h -x /zonepath/zonename to get the space that was used in a UFS root partition of a zone.

For example, /usr/xpg4/bin/du -sk -h -x /zonepath/zonename
returned the following: 3.5G /zonepath/zonename

The -x option when evaluating file sizes, evaluates only those files that have the same device as the file specified by the file operand.

The -x operand only seems to work when calling du with this path: /usr/xpg4/bin/du

This also worked to display the used space of the zfs attached drives in the zone! We mounted one zfs lun to the path /zoneepath/zonename/data and running this matched the output of "zfs list" for the data file:

# /usr/xpg4/bin/du -sk -h -x /zonepath/zoneneame/data
11G /zonepath/zoneneame/data

If you run #/usr/xpg4/bin/du -sk -h -x /zonepath/zoneneame
then you should get an overall total of the used space in the zone such as:
53G /zonepath/zonename

It will not include NFS attached drives, nor will it include directories that root is not the owner of.

I hope this helps!

Upvotes: 2

Chris Miles
Chris Miles

Reputation: 7526

If you install the zone on a zfs volume then you can use the zfs tools ("zfs list") to quickly see how much space has been used.

Otherwise you'll have to use "du" as you already discovered (which will be much slower).

Upvotes: 0

VonC
VonC

Reputation: 1327784

Since I tried both John's solution and Pierre-Luc solution, what works for me is:

  • list all the zone (from the global zone)

:

tcsh>zoneadm list -civ
  ID NAME             STATUS     PATH                           BRAND    IP
   0 global           running    /                              native   shared
   1 myZone1          running    /export/zones/myZone1          native   shared
   2 myZone2          running    /export/zones/myZone2          native   shared
  • du -sk as root
    (since local zones are not readable from global zone, I had to du -sk them as root)

:

 tcsh>s du -sk /export/zones/myZone1  
 9930978 /export/zones/myZone1

Upvotes: 1

Pierre-Luc Simard
Pierre-Luc Simard

Reputation: 2721

According to Solaris Operating System Managing ZFS in Solaris 10 Containers the following command would give you the information you require.

zfs list 

Upvotes: 0

user36457
user36457

Reputation:

try the du command

Upvotes: 2

Related Questions