Jump to content

HOWTO Installation: Filesystem Layout


aru
 Share

Recommended Posts

 

static

Moderator

Joined: 16 Apr 2002

Posts: 313

Location: Canada

 

Posted: Thu Apr 25, 2002 12:52 pm Post subject: Installation:

Filesystem Layout

_________________________________________________________________

 

 

Filesystem Layout Partitioning

by static - small edit by afrosheen

 

Your filesystem is the base of your computer. It is a structure in which all your files are kept, ranging from files that run the operating system to files such as e-mails or mp3 music files. Rather than keep every file in one giant mess, they've been sorted out into groups of files that belong together and kept in "directories", or folders as they're called in other operating systems. (Think of it this way, if you went fishing and caught a salmon, a pike, a bass, and a minow, you wouldn't want to keep them all in one tub, would you? OF Course Not! That would be insane! You want a different tub for each fish. The fish are the files, and the tubs are the directories.)

 

Without going into too much detail (we'll cover directories more later), here's what you need to know to install linux.

 

/ - the root directory - every other directory is contained within / (and that is why we usually write their names preceeded with a / - it's the root of the filesystem)

 

/bin - This isn't a bin for trash! This is where system binaries are kept. Binaries are executable files that you can run, and they are for programs that run the operating system.

 

/boot - All the files for booting up your computer and loading the OS are kept in here. Some may choose to make this a seperate partition rather than branching from the / directory for safety. If you choose to create this partition, it must be the first partition you create for linux. It doesn't need to be larger than 10 megs.

 

/dev - All your devices, like CDROMs and floppy drives, are in here

 

/etc - this is where the system configuration files are kept (the way the OS is setup, so to speak)

 

/home - Within home, there is always a directory for each user. If your name is Joe, you are only allowed to download and save files (or change existing files) in /home/joe (sometimes called ~)

 

/usr - this is where applications go. Inside /usr looks very much like a mini / but the difference is instead of OS binaries or configs, it's the binaries or configs for applications not vital to the OS such as office or games. All users are allowed to run apps in /usr, but they aren't allowed to alter or delete the files there in any way.

 

- /usr/bin - binaries for apps like office or games

- /usr/etc - configs setup for them

- /usr/src - source code for the apps (preinstalled packages)

 

/sexygirls - I can't tell you what I keep in here (but I can tell you they don't think I'm funny when I tell them I'd "give them access to my harddrive")

 

/var - If you're running a server, the files that you are serving other people on the internet (like music or webpages) would be contained in here.

 

When installing linux, you have the option of dividing up the space on your hard drive into separate sections (or parts) called partitions. This can be handy, as it can improve the stability and security of your system. Here's an example: Your operating system tends to begin operating poorly if it's running out of space. You could, therefore, take say a 10 Gig hard drive and divide it into 2 partitions (5 gigs each), one for / and one for /home. Now, if you download music like crazy into /home/joe, you aren't using the space given to /! If you try to download more than 5 gigs of music, you'll be told you're out of space, but the operating system is still as happy as a pig in the mud, because his space hasn't been invaded by your gigs of Amish dance music.

 

To take that example and apply it to your own linux let's consider a few things. First of all, downloading music won't be the only thing you'll want to do with your PC. You will want to install applications and games, and these get put into /usr if you recall. We still don't want the OS's space being invaded (and some applications won't run too well if you're out of space, also). So, to keep your shiny new Klingon Wheel of Fortune Game AND your OS running smooth, it's a great idea to have a separate partition for / (for the OS), /usr (for the Klingons), and /home (for the Amish dance music).

 

Also, linux (like other OS's) uses Swap space - which is just used like imaginary RAM. The difference with linux is linux likes to keep a partition solely for the Swap. Another OS, we'll call it wino-dows, just uses a swapfile on the same partition as the OS. This can make things unstable, though, if the swapfile needs more space but that space is already used up by the OS, the wino-dows version of Klingon Wheel of Fortune, and your Amish dance music! So you see why multiple partitions is a very smart idea (thank you linux, thank you).

 

So when installing linux, you must decide how big to make these partitions. One of the most common partitioning practices is to have 4 partitions: / , swap, /home, and /usr (usually in that order). If you're running a server, you'd want one for /var as well, but we'll assume you're not just yet.

 

 

/ usually needs around 300MB, and the swap should be 400-500MB. After that, the remaining space should be divided between /usr and /home according to how you think your PC will be used most. Will the PC only be for the ten kids to download music? If So, make /home bigger. Will it just be one or two people playing lots of games and installing apps? Make /usr bigger. I like to have /usr bigger, because almost anything I put into /home/static I end up burning onto a CD anyway, and I'd like to have the space for installing apps games.

 

 

Sam French

Newbie

Joined: 27 Jun 2002

Posts: 14

Posted: Fri Jun 28, 2002 2:16 am Post subject:

_________________________________________________________________

 

 

Hey I a newbie and I just priinted your page out. THANKS for the info. Maybe on of these decades I will get this thing working.

 

 

Maciek

Frequent user

Joined: 04 Jul 2002

Posts: 86

Location: Perth

Posted: Thu Jul 04, 2002 12:14 pm Post subject: Different hdds

_________________________________________________________________

 

 

IMHO it's also good to spread the partitions over different hard drives.

 

For example I have my swap partition on separate harddrive, and I noticed significant speed increase (especially while using VMware with WindowsXP), my hard disks don't "grind" so much anymore. Accessing two hard drives at the same time is much faster than accessing one (I think up to twice as fast).

 

 

Hinsight4

Frequent user

Joined: 12 Jul 2002

Posts: 45

Posted: Fri Jul 12, 2002 9:58 pm Post subject: Thanks!

_________________________________________________________________

 

 

This partitioning doesn't sound so scary anymore. Now if someone could explain the different types of formatting the partitions, it would be all set. Thanks a lot, this helps more than you know!

 

 

Afrosheen

Moderator

Joined: 16 Apr 2002

Posts: 197

Location: Dallas, TX

Posted: Sat Jul 13, 2002 4:53 am Post subject:

_________________________________________________________________

 

 

I'll try to explain the filesystem types briefly.

 

First I need to subdivide the fs types into two categories: journaling and non-journaling.

 

Journaling filesystems include: xfs, jfs, reiserfs, and ext3. There might be one more but these are the major ones.

 

Non-journaling filesystems include: ext2, swap. The swap is a special partition type so I don't know if it really counts or not, just threw it in for completeness. It IS, however, it's own fs type, whether you use reiser or whatever, swap is swap.

 

The difference between journaling and non-journaling filesystems is that journaling fs's keep a log, or a journal, of bits written to the disk. This is also called a meta-data system, because in effect, data is stored about the rest of the data on the disk. The benefit of keeping a log/journal of the rest of the info on the disk is for safety. Look at it this way:

 

Newbie lets his server run all day and all night. Once in awhile the power goes out and resets his computer. With a non-journaling fs like ext2 he may lose data and may experience filesystem corruption when the machine resets because the disk isn't properly finalized and unmounted safely. With a journaling filesystem, the filesystem compares the dates on the log with other info on the drive, replaying the log to repair/replace lost data. Did I mention it's really, really fast too? Ext2, in the event of a crash, forces fsck to run. Fsck is the filesystem checker utility that checks/repairs partitions much like scandisk on windows. Journaling filesystems don't require a fsck very often, if at all. They replay their logs and keep going.

 

Now that you understand the benefits, let's examine (very, very lightly) the advantages/disadvantages of each journaling filesystem. You'd be wise to choose one based on what you need.

 

Reiserfs:

A. Benefits

1. A very efficient filesystem that journals metadata. It also uses very small blocks so it's even more efficient, because if a tiny text file is just a few bytes, and there are many, they'll all get packed into one block rather than written as separate blocks.

2. Journals metadata. This can be considered a partially true journaling filesystem, because it's not redundant. A true journaling filesystem actually mirrors the data in a sense. Reiser does not.

3. Very fast with huge files. Because of the way it journals, it merely moves pointers in the log rather than physically moving gigantic (1gb or more) files. I'm not 100% sure about this but you can do your own research Smile

4. Better than ext2 for the filesystem performance and journaling alone.

5. Large maximum file size. Ext2 is limited to 2gb, Reiser is limited to 4gb.

 

B. Disadvantages

1. Not a true journaling filesystem, so it doesn't protect you 100% from losing data.

2. Not good with lots of medium-sized files.

3. Not 110% stable with older 2.4.x series kernels. Personally I have never had a problem with it but other people with other distros have.

Edit: ReiserFS can now be considered "stable" and is the recommended filesystem

4. Not easy to recover data from like ext2, there just aren't any tools.

 

JFS:

A. Benefits

1. A true journaling filesystem. Not only does it log but it more or less mirrors data (jounals).

2. Large filesize support. Again, ext2 can only handle a 2gb file, JFS can handle between 512 terabytes to 4 petabytes. That's a big file. Wink

3. Developed and supported by IBM, used for many years across many systems and there are lots of server people familiar with it, but...

 

B. Disadvantages

1. Although it's mature on other systems, some linux people believe it's still too cutting-edge. Not a great idea for a primetime server. Still needs work under linux.

2. While it's a true journaling FS, that journal comes at a price. Performance isn't as quick as Reiser or EXT2.

 

XFS:

A. Benefits 1. Very, very fast. SGI has been using XFS on their IRIX boxes for years, and considering what they do for a living, they need filesystem speed above all else. This has made it popular for linux as well.

2. Very large files supported. Again, EXT2 is stuck with a 2gb limit while XFS can handle between 16-64 terabytes. Gigantic. In the future when linux adopts 64bit disk I/O, this number scales to over 1 million terabytes.

3. Dump/restore tools come with XFS and they work as expected.

 

B. Disadvantages

1. Not a true journaling filesystem. Like Reiser, it sacrifices true journaling for speed. Not a bad tradeoff actually.

2. Some people believe SGI isn't serious about Open Source, or at least not as serious as IBM. Their motives are questionable at this point. Not really a disadvantage but support for XFS in the future may/may not continue.

 

I've used Reiser for a couple of years now and have grown to trust it and enjoy it's performance, even on crappy older computers. I've never experienced corruption like others have mentioned on the net so personally I recommend it. I've also used XFS and JFS, and I'm torn on which one to put above the rest. They're all pretty equal IMHO but I've used Reiser for the longest so I can testify to it's reliability.

 

For your own research and sanity, here are links to the filesystems I mentioned:

 

XFS info at

 

JFS info at

 

Reiserfs info at

 

Reiser4 looks so sweet.

 

Edit: ReiserFS can now be considered "stable" and is the recommended filesystem

 

 

ramfree17

Moderator

Joined: 18 Apr 2002

Posts: 1262

Location: Philippines

Posted: Sat Jul 13, 2002 7:14 am Post subject:

_________________________________________________________________

 

 

i was reading afro's great light comparison but he didnt mention about ext3 which is basically a ext2 filesystem with a journalling layer on top. this makes is slower than ext2 but its great enough for my use (i also have reiserfs partitions. Wink )

 

another not well known filesystem is tmpfs. its not really a filesystem but 2.4.x kernels have one but generally unused. why is this so? well because this filesystem is your memory (RAM+swap). if you will use this filesystem then you will be storing files on your memory instead of the harddisk. the pro of this is that its great for /tmp or other temporary directories as the files writtent there will be deleted with every reboot. the disadvantage is that this takes up your memory. let me give an example.

 

ex. you have 64MB RAM + 128MB swap. you decided to make /tmp as tmpfs and you copied a 160MB file to /tmp. this will make your system memory drop to 32MB (not taking into consideration those taken up by services and other apps). you opened an application that needs 40MB of memory. since you have a 8MB deficit, the kernel will aggressively kill the application hugging the most resources, which is usually your X Windows Server. Sad

 

but dont fret as you could use tmpfs and specify the maximum amount of MB that it will take up. btw, your systems tmpfs system is usally designated as /dev/shm or something like that (type mount and you will see what i mean).

 

ciao!

 

 

Hinsight4

Frequent user

Joined: 12 Jul 2002

Posts: 45

Posted: Sat Jul 13, 2002 11:26 pm Post subject: Thanks!

_________________________________________________________________

 

 

Thanks a lot for the information. That makes a lot more sense now and I think that I can get it all starightened out. Thanks again, that was very helpful! Thanks, Hinsight4 Laughing

 

 

sminons

Newbie

Joined: 13 May 2002

Posts: 20

Posted: Sat Oct 05, 2002 8:04 pm Post subject: One filesystem to another?

_________________________________________________________________

 

 

Once set, can the filesystem be changed ?,say ext2 to ext3?..of for that matter anyfilesystem to any other?. Thanks in advance.

 

 

arusabal

Moderator

Joined: 17 Apr 2002

Posts: 836

Location: Spain

Posted: Sun Oct 06, 2002 1:00 am Post subject:

_________________________________________________________________

 

 

Check this thread at tips&tricks There I explain the worst scenario in how to migrate from one filesystem to another. If you just want to migrate from ext2 to ext3, then that's as easy as using "tune2fs -j /dev/partition" and change "ext2" to "ext3" in /etc/fstab (But before doing nothing, please read man tune2fs). Also you need to have support in the kernel for the new fs (which is quite probable)

 

 

 

Editor's note: This thread was originally posted at the old MUB (Mandrake User Board at club-nihil). This post is the result of a 99% automatic backup, so due to its nature some text may be lost (improbable but possible).

Link to comment
Share on other sites

  • 5 months later...

Without covering every directory, here's a metaphor to help you understand the way the filesystem, or directories (folders), are laid out.

 

/, there can be (and will be) different directories (rooms) for the different people who live in the house.

 

Let's say joe, the owner of the computer, is going to let his little sister jen use his computer. There's a room in the house for both joe and jen; /home/joe, belongs to somebody. We'll see how great this can be for security and stability later.

 

The directory /dev (for your floppy drive), and so on. However, these are more like files that define the device drive rather than what is on the cdrom in the drive, say.

 

/mnt.

 

So let's recap the filesystem layout:

 

/ (and that is why we usually write their names preceeded with a / - it's the root of the filesystem.)

 

/bin - This isn't a bin for trash! This is where system binaries are kept. Binaries are executable files that you can run, and they are for programs that run the operating system.

 

/boot - All the files for booting up your computer and loading the OS are kept in here.

 

/dev - All your devices, like CDROMs and floppy drives, are in here

 

/etc - this is where the system configuration files are kept (the way the OS is setup, so to speak)

 

/home)

 

/usr, but they aren't allowed to alter or delete the files there in any way.

 

- /usr/bin - binaries for apps like office or games

- /usr/etc - configs setup for them

- /usr/src - source code for the apps (preinstalled packages)

 

/var - If you're running a server, the files that you are serving other people on the internet (like music or webpages) would be contained in here.

 

 

OK, now onto command line fun. And it is fun, so don't leave now! It may take more than one reading to grasp it all, but a million mile journey starts with a single step. Throughout this tutorial, I will give commands in quotes; You don't type the quotes, I just do to avoid confusion between command text and tutorial text, capice?

 

When we talk about going "into" a directory, like opening a folder in a graphical user interface (GUI) with your mouse, we will be able to view the contents of it. "ls" (for list) will list the files and directories within your current working directory (CWD), that is, the directory you are currently sitting in. When you first log onto the computer, or when you first open a "terminal" in X windows (X windows is a GUI incredibly similar to microsoft's GUI called windows), you are at the command line, and your working directory is usually /home/joe to start (if your name is joe - and for now IT IS >:| )

 

Let's look at the command line. It looks kinda funny, doesn't it?

[joe@joes.computer joe]$

looks really funny! What this is telling you is joe is logged into (joe@) the computer, which happens to have "joes.computer" for a name. joe@joes.computer makes sense, doesn't it. The last joe is telling you the current working directory, /home/joe (it always only shows the last directory name of your CWD.) Not so funny anymore, is it? The command "pwd" will print your working directory to the screen. It will look like this:

[joe@joes.computer joe]$ pwd

/home/joe



[joe@joes.computer joe]$ _

 

O.K. joe, your home directory /home/joe)

[joe@joes.computer joe]$ cd ..

[joe@joes.computer home]$ _

 

"cd .." again would take you up a directory to /[joe@joes.computer home]$ cd ..

[joe@joes.computer /]$ _[/code]

 

Every directory has two special directories in them; "." and ".." - "." means "this directory" and ".." means "the directory above me" or "my parent directory". The only exception is / has no parent directory there is no /.. to "cd" to.

 

Remember ~, you could type "cd home" and do an "ls" just to see

[joe@joes.computer /]$ cd home

[joe@joes.computer home]$ ls

./

../

jen/

joe/



[joe@joes.computer home]$ _

Directories are shown in blue and have a forward slash after their name. Executable binaries are shown in green, installable rpms are red, text and unknown types are white, links (like shortcuts) are a light aqua, etc.

 

Now lets cover some basic commands that you would use everyday. In X windows, people often right click to select cut, copy or paste, to make a directory or link (shortcut), or to move or remove (delete) a file. Believe it or not, these tasks go faster using the command line interface (CLI)! Some commands take arguments to understand exactly what you want to do, like "ls -l". The "-l" is the argument and tells "ls" to list the files in the directory using the long, detailed format, showing you the file sizes and attributes.

 

Quick Reference

 

[*]ls = list directory contents

 

[*]cp = copy

 

[*]mv = move/rename

 

[*]rm = remove/delete. Use "-R" argument to remove an entire directory and all of it's contents. Use with Caution!

 

[*]su = switch user (without an argument means switch to root, the superuser/administrator)

 

[*]pwd = print working directory

 

[*]mkdir = make a directory

 

[*]ln -s = make a soft link (shortcut)

Examples

cp song.mp3 ~ = Copy song to /home/joe

mv ~/song.mp3 ~/newname.mp3 = rename song in /home/joe to newname

cd ~ = change directory to /home/joe

mkdir downloads = make a new directory "downloads" within the current working directory.

ln -s is awesome. It works like a shortcut in windows. Let me explain how I use this to my major advantage.

 

I use some applications (well, games :oops:) in both windows and linux, so instead of having the files installed twice, I can link to the windows files.

ln -s /mnt/windows/KlingonWOF/gamedata /usr/games/KlingonWOF/gamedata

 

Now everytime my linux looks at /usr/games/KlingonWOF/gamedata it's actually following the link and looking at the file in windows!

 

========================================

DRAFT*********MORE**ON**THE**WAY!!**********DRAFT

Link to comment
Share on other sites

"]Also, linux (like other OS's) uses Swap space - which is just used like imaginary RAM. The difference with linux is linux likes to keep a partition solely for the Swap. Another OS, we'll call it wino-dows, just uses a swapfile on the same partition as the OS. This can make things unstable, though, if the swapfile needs more space but that space is already used up by the OS, the wino-dows version of Klingon Wheel of Fortune, and your Amish dance music! So you see why multiple partitions is a very smart idea (thank you linux, thank you).

 

I don't know about other versions, but Windows XP lets you manage your own swap settings. You just have to make the partition first. At one point, I had a 600MB swap on my secondary drive; yes, I noticed the performance increase. Plus, I statically set the size so it wouldn't fragment with the rest of my things. (I was not yet smart enough to see that it should get its very own partition.)

Link to comment
Share on other sites

[happy now :D] lol

 

I said that because although you could fiddle until you had windows that way - most users have no idea at all... In linux, swap is a filesystem type designed to interact with memory (because memory doesn't store info the same way a normal filesystem does) and so you use a different partition to allow for a different filesystem type. This increases performance compared to windows needing to store the swap data on a file allocation table system.

Link to comment
Share on other sites

Oh, makes sense. Yeah, and Linux doesn't let you be ignorant of all that, even when installing Mandrake! :)

 

you use a different partition to allow for a different filesystem type

That answers a question of mine: Can you have different filesystems on one drive/multiple partitions? I'm just posting about that now, thanks to your great tutorial!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...