Register a domain and help support LQ
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 11-23-2009, 01:52 PM   #1
Registered: Nov 2009
Posts: 46

Rep: Reputation: 1
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:

/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:
Filesystem Size Used Avail Use% Mounted on
992M 372M 570M 40% /
3.9G 688M 3.1G 19% /var
/dev/md1 67G 43G 21G 69% /mywebsite
7.8G 2.2G 5.2G 30% /usr
3.9G 3.7G 61M 99% /www
/dev/md0 67G 63G 2.7G 96% /var/lib/pgsql
992M 38M 904M 4% /tmp
/dev/sda1 99M 18M 77M 19% /boot
tmpfs 2.0G 0 2.0G 0% /dev/shm
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?
Old 11-23-2009, 02:01 PM   #2
Registered: May 2003
Location: Tengiz
Distribution: Slackware64 14.1
Posts: 672

Rep: Reputation: 94
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.
Old 11-23-2009, 03:16 PM   #3
Registered: Nov 2009
Posts: 46

Original Poster
Rep: Reputation: 1
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:

4.9G 306M 4.3G 7% /var
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. 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.
Old 11-23-2009, 03:47 PM   #4
Registered: Nov 2009
Posts: 55

Rep: Reputation: 19
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.
Old 11-23-2009, 04:08 PM   #5
Gentoo support team
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,063

Rep: Reputation: 381Reputation: 381Reputation: 381Reputation: 381
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.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
vpn: overview? abolishtheun Linux - Networking 1 04-16-2009 01:49 AM
Most secure, best overview... Zuul Linux - Distributions 3 08-24-2005 03:15 PM
command overview? TranceDude Linux - Software 4 08-12-2005 07:48 PM
overview of Arch? b0uncer Arch 4 01-20-2004 09:14 AM
Quick Overview dnfrantum Linux - Networking 1 06-26-2003 07:37 PM

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

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration