LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Disk Overview---Help Me Understand What I'm Seeing (https://www.linuxquestions.org/questions/linux-newbie-8/disk-overview-help-me-understand-what-im-seeing-771040/)

Subject16 11-23-2009 12:52 PM

Disk Overview---Help Me Understand What I'm Seeing
 
I hope someone can help me make sense of disks in Linux. I've read the articles and links and such. The problem is I'm having a hard time applying what I've read and "learned" so far with real world situations. I'm getting a little overwhelmed and confused, so I'm hoping someone can help me clarify things.

I think I understand that when you install Linux you have some partitioning and formatting options, like anything else. If you create only a swap and boot partition, your /etc/fstab might look something like this:

Quote:

/dev/sda1 / ext3 defaults 1 1
/dev/sda2 swap swap defaults 0 0
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
That means that all of the sub-directories under / (like /etc, /dev, etc) are all in one partition. So best practice, depending on the box you're building, suggests you separate out these things. So, you can create more partitions and give /usr its own, and /var its own, and so forth. Right so far?

Now, that's a fairly basic system. Let's say I run across an fstab that looks like this:
Quote:

Filesystem Size Used Avail Use% Mounted on
/dev/mapper/system-root
992M 372M 570M 40% /
/dev/mapper/system-var
3.9G 688M 3.1G 19% /var
/dev/md1 67G 43G 21G 69% /mywebsite
/dev/mapper/system-usr
7.8G 2.2G 5.2G 30% /usr
/dev/mapper/system-www
3.9G 3.7G 61M 99% /www
/dev/md0 67G 63G 2.7G 96% /var/lib/pgsql
/dev/mapper/system-tmp
992M 38M 904M 4% /tmp
/dev/sda1 99M 18M 77M 19% /boot
tmpfs 2.0G 0 2.0G 0% /dev/shm
fileserver1:/mycompany/somedata
646G 296G 317G 49% /somedata
My take on this is (without getting into too much about RAID and LVM, which is way over my head), is that there are virtual disks created (these /dev/mapper nodes), and this allows the directories that are typically found under / to be spread out over multiple disks. So if I'm concerned about running out of space on /www, I would do du -sh /www to find out what in that directory is taking up the bulk of the 3.9GB allocated?

So, even though an "ls /" would list all of these directories, they still technically live under / but not necessarily on the same drive or partition? Does this mean that all of the other directories usually found under / (/lib, /tmp, etc) are still under this main partition and contribute to the overall size of /?

Am I understanding disk layout properly in this context?

ozanbaba 11-23-2009 01:01 PM

without getting LVM, RAID and anything, here's my fstap

/dev/sda2 swap swap defaults 0 0
/dev/sda1 / ext4 defaults 1 1
/dev/sdb1 /home/ozan ext4 defaults 1 1
#/dev/cdrom /mnt/cdrom auto noauto,owner,ro 0 0
/dev/fd0 /mnt/floppy auto noauto,owner 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
proc /proc proc defaults 0 0
tmpfs /dev/shm tmpfs defaults 0 0

let's ignore the virtual systems like proc and sys, and we got:
/dev/sda2 swap swap defaults 0 0
/dev/sda1 / ext4 defaults 1 1
/dev/sdb1 /home/ozan ext4 defaults 1 1

my swap and root is on sda. my home is on sdb.
everything in / in in /dev/sda1 exept /home/ozan, because it is on /dev/sdb1.

you can do something like this;
/dev/sda1 is /
/dev/sda2 is /home/ozan
/dev/sda3 is /usr
/dev/sda4 is swap

in that case; sda1 is gets anything on / exept /home/ozan which is on sda2 and /usr which is on sda3.

Subject16 11-23-2009 02:16 PM

Okay, let me give another more concrete example of where my confusion stems from (a RL example that I just encountered).

I did df -h and part of the output was this:

Quote:

/dev/mapper/MainVG-var
4.9G 306M 4.3G 7% /var
/dev/mapper/MainVG-pgsql
51G 28G 22G 57% /var/lib/pgsql
I did du -sh /var and got:
28G /var

Now, up above it shows that /var is 4.9GB total. Soooo...how is is that du -sh on that same directory shows me that I am using 28GB? Is it that even though /var/lib/pgsql is actually mounted somewhere else it's still considered part of /var when I view disk usage? That doesn't make sense to me because...well, it just doesn't.

I'm probably over-thinking it because the base is that I know I can do a du -sh on the full pathname /var/lib/pgsql to see what's making up that 22GB that's in use, but I guess I want to understand the theory behind why it works like this. If this is too much to be tackling in this thread, let me know. I think part of the hang-up I have to learning Linux is getting caught up in semantics.

Chirel 11-23-2009 02:47 PM

In your example you have :

/dev/mapper/MainVG-var on /var using 306M
/dev/mapper/MainVG-pgsql on /var/lib/pgsql using 28G

so du that give you the actual disk usage will give you 306M+28G

that's the result you have.

Where is the problem for you, i don't understand ?

when you use df it give you
disk_size disk_usage disk_space_left percent_usage.

i92guboj 11-23-2009 03:08 PM

The confusion here is that du will count disk usage on that directory without caring at all about what device the info is into. That means it will traverse devices if needed, even if it's a network share mounted via nfs.

Check the du man page, scpecially the -x option.


All times are GMT -5. The time now is 08:04 AM.