首页 > 代码库 > Linux File Systems
Linux File Systems
This is a beginner‘s course and one of the concepts that newcomers to Linux find different is the idea of a file system in Linux. That is to say, the way data is stored and managed in Linux. Most users are familiar with Files. In the simplest terms possible, one can say that files are just a collection of data items which are stored on a disk. However, the way that those files are stored on a disk can vary depending on several different factors. Speed, security, data redundancy etc...
Linux Supports lots of different types of File System formats. Here are just a few...
Ext2: This is like UNIX file system. It has the concepts of blocks, inodes and directories.
Ext3: It is backwards compatible with the ext2 file system, except that it has added journal ing capabilities. Journalling allows fast file system recovery. Includes support for Access Control Lists (ACL).
Isofs: Used by CDROM file system (iso9660).
Procfs: The proc file system acts as an interface to internal data structures in the kernel. It can be used to obtain information about the system and to change certain kernel parameters at runtime using sysctl command.
Mounting file systems
In this part of the lesson about file systems we‘ll learn how to use the commands mount and umount
We‘ve mentioned previously that there‘s a different idea in Linux as to what constitutes a floppy disk drive, a CD-ROM drive and another partition of your hard disk (the Windows partition, for example). Though some windows managers for Linux have provisions for clicking on an icon to access a floppy drive, for example, the method behind this is quite different from other OSes. In Linux the floppy drive or other device must be "mounted". That means basically, incorporating it temporarily into your Linux file system or, in other words, telling Linux that it is a file to be written to or copied from.
You can use the mount command to copy to and from other devices.
If you would like to get some files from a CD-ROM, the standard command to do this is:
The type, iso9660 is the standard file system for a CD. The device (/dev/hdb) is the non-SCSI type of CD-ROM and the mount point (/cdrom) should exist. If it doesn‘t, you should create it in the root directory with ‘mkdir‘, just as you may have done with the /floppy directory.
Remember that the concept of CD-ROM is read only. You won‘t be able to write to this type of CD-ROM drive. A message will tell you that when you mount this type of device.
Mounting another partition of the hard disk.
Many people may have preferred to install Linux along with another operating system. You may have Linux and Windows installed in the same computer. If you would like to access files on the Windows partition you would type the following command:
Windows is always in the primary partition, so that‘s why we‘ve used the device /hda1 (hard disk partition 1). The choice for /mnt is the standard mount point in this case. You may use the /mnt directory to mount the other devices (floppies, CDs) as well. I use the different empty directories (/floppy /cdrom /mnt) to avoid confusion.
If you change to the mount directory (cd /mnt) and then type: ls and you‘ll see something interesting. The directories are blue but the files are green (or red - depending on your distribution of Linux). You won‘t have the various color combinations as you do in Linux. That‘s because Windows‘ file system doesn‘t distinguish file types. Everything looks like it‘s a program (binary) instead of a regular file.
When you copy files from the Windows partition to the Linux partition you should bear this in mind. For example, if you wanted to copy an mp3 file from the Windows partition to the Linux partition to test out your sound configuration, it would show up as a executable program and not just a standard file under Linux. This doesn‘t effect your playing it, but for a more accurate accounting of what you have on your system, you may want to change the permissions of the file so that it shows up as a regular file in your color scheme. We‘ll talk about file permissions and and making changes to them shortly.
Unmounting
Mounting file systems that aren‘t part of the standard Linux system is considered a temporary condition in Linux. Now that we know how to mount these outside file systems in Linux, the important thing now is to learn how to unmount it when we‘re finished using it.
In the early days of Linux, you could do serious damage to your system if you didn‘t unmount manually after you were finished. Nowadays if you have mounted a system and you shut down the computer without unmounting, the chances are pretty slim that you‘re going to trash a file system. Slim, however, isn‘t good enough for me. I‘d rather not take a chance. I always take the time to unmount these external file systems when I‘m finished with them.
The command for this is:
In the examples I used in this lesson, the mount points were:
Remember also to NOT be accessing the disk. when you use umount or it will give you a drive busymessage. If you get this, you may have left a terminal open where you were using to copy or write to the particular drive. Check your terminals if you get this error.
I just wanted to point out another thing too. You are ‘unmounting‘ but the command is umount (that is, without theN of un) Being u(n)familiar with the mount concept when I started with Linux, I typed unmount instead of umountand much to my surprise, I got the message: command not found. U(n)deniably, I had done something wrong. It took me a while to figure out that the command didn‘t include an N. I haven‘t really done a survey on how many people have actually done this. For all I know, I may be the only person who has, but I just thought it best to warn you.
Well, now you can use the standard devices that most PC users need. Later in our advanced class we‘ll talk about installing and using other devices like scanners, CD writers, Zip drives and matter/anti-matter flow inducers. (well, maybe we‘ll save that last one for the super-advanced classes!)
Linux Supports lots of different types of File System formats. Here are just a few...
Ext2: This is like UNIX file system. It has the concepts of blocks, inodes and directories.
Ext3: It is backwards compatible with the ext2 file system, except that it has added journal ing capabilities. Journalling allows fast file system recovery. Includes support for Access Control Lists (ACL).
Isofs: Used by CDROM file system (iso9660).
Procfs: The proc file system acts as an interface to internal data structures in the kernel. It can be used to obtain information about the system and to change certain kernel parameters at runtime using sysctl command.
Mounting file systems
In this part of the lesson about file systems we‘ll learn how to use the commands mount and umount
We‘ve mentioned previously that there‘s a different idea in Linux as to what constitutes a floppy disk drive, a CD-ROM drive and another partition of your hard disk (the Windows partition, for example). Though some windows managers for Linux have provisions for clicking on an icon to access a floppy drive, for example, the method behind this is quite different from other OSes. In Linux the floppy drive or other device must be "mounted". That means basically, incorporating it temporarily into your Linux file system or, in other words, telling Linux that it is a file to be written to or copied from.
You can use the mount command to copy to and from other devices.
If you would like to get some files from a CD-ROM, the standard command to do this is:
Code:
mount -t iso9660 /dev/hdb /cdrom
Remember that the concept of CD-ROM is read only. You won‘t be able to write to this type of CD-ROM drive. A message will tell you that when you mount this type of device.
Mounting another partition of the hard disk.
Many people may have preferred to install Linux along with another operating system. You may have Linux and Windows installed in the same computer. If you would like to access files on the Windows partition you would type the following command:
Code:
mount -t vfat /dev/hda1 /mnt
If you change to the mount directory (cd /mnt) and then type: ls and you‘ll see something interesting. The directories are blue but the files are green (or red - depending on your distribution of Linux). You won‘t have the various color combinations as you do in Linux. That‘s because Windows‘ file system doesn‘t distinguish file types. Everything looks like it‘s a program (binary) instead of a regular file.
When you copy files from the Windows partition to the Linux partition you should bear this in mind. For example, if you wanted to copy an mp3 file from the Windows partition to the Linux partition to test out your sound configuration, it would show up as a executable program and not just a standard file under Linux. This doesn‘t effect your playing it, but for a more accurate accounting of what you have on your system, you may want to change the permissions of the file so that it shows up as a regular file in your color scheme. We‘ll talk about file permissions and and making changes to them shortly.
Unmounting
Mounting file systems that aren‘t part of the standard Linux system is considered a temporary condition in Linux. Now that we know how to mount these outside file systems in Linux, the important thing now is to learn how to unmount it when we‘re finished using it.
In the early days of Linux, you could do serious damage to your system if you didn‘t unmount manually after you were finished. Nowadays if you have mounted a system and you shut down the computer without unmounting, the chances are pretty slim that you‘re going to trash a file system. Slim, however, isn‘t good enough for me. I‘d rather not take a chance. I always take the time to unmount these external file systems when I‘m finished with them.
The command for this is:
Code:
umount [/mount point]
Code:
floppy: /floppy - therefore umount /floppy CD: /cdrom - umount /cdrom Windows partition - umount /mnt
I just wanted to point out another thing too. You are ‘unmounting‘ but the command is umount (that is, without theN of un) Being u(n)familiar with the mount concept when I started with Linux, I typed unmount instead of umountand much to my surprise, I got the message: command not found. U(n)deniably, I had done something wrong. It took me a while to figure out that the command didn‘t include an N. I haven‘t really done a survey on how many people have actually done this. For all I know, I may be the only person who has, but I just thought it best to warn you.
Well, now you can use the standard devices that most PC users need. Later in our advanced class we‘ll talk about installing and using other devices like scanners, CD writers, Zip drives and matter/anti-matter flow inducers. (well, maybe we‘ll save that last one for the super-advanced classes!)
Linux File Systems
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。