If you did not migrate your account yet, visit https://idp-portal-info.suse.com/
SDB:Basics of partitions, filesystems, mount points
When it comes to installation of openSUSE or the adding/removing of disks to an existing system people start talking about (un)mounting, filesystems and partitions. Often one has no real idea what all these words mean in a Unix/Linux environment. This again means that discussing problems in this area is full of painfull misunderstandings.
A lot of people do have some knowledge based on other Operating Systems they used. That increases the possibility of confusion.
The real procedure to cope with this situation is to spend some time in reading some documentation. This SDB hopes to be a primer and a starting point for further reading.
All examples shown below were made by the superuser (
At least in this document we will use the word disk as a generic term for all things that are seen as disks by the system. No need to talk about HDD (Hard Disk Drives) because that is only interesting when Floppy Disk Drives would be very different, seen from the point of view of the system. They are not. Nowadays they are hardly used. And the normal (hard) disk is much older. Also newer types of mass storage devices present themselves to the system as disks and fall in this category. The systems can not see if a disk is inside the system enclosure, beside it on a table or on another shelf, so there is no difference between what some people call internal and external disks.
Disks are normally preformatted by the manufacurer. That means that damaged tracks are marked and replacements used, sector numbers are written. This is done to interface with the controler hard-/firmware. This type of formatting is also know as low-level formatting.
Unix systems always have had the possibility to split disks into several partitions. Each disk has at least one partition, but often there are more. We will limit ourselves here to the partitioning as done on disks in a PC environment.
In the beginning there was the idea that four partitions would be enough for all possible usage (which it was not). The data about the partioning is written in the partition table. It is on a special place on the disk and the BIOS knows all about it. As usual a downward compatible solution was found: by making one of the four a special partition, which can hold more partitions. Newer BIOSes (nowadays all BIOSes) know about it. Thus we have 3 types of partitions:
- primary partitions, these are the partitions of old, there can be four of them (numbered 1, 2, 3, 4);
- extended partition (in fact also a primary partition), there can only be one, it has normally the number after the highest created primary partition (3 or 4) and should contain all of the remaining space of the disk (else space is spoiled);
- secondary partitions, they are created inside the extended partition, their numers are always 5 and higher
(the maximum is debatable, but enough for most people).
Some people are bewildered by the extended partition, it seems to be of no use and takes a lot of disk space and that space seems also to belong to other useful partitions. Reading the above might reassure them.
An example of a disk with partitions of all three types goes here:
beneden:~ # fdisk -l Disk /dev/sda: 200.0 GB, 200049647616 bytes 255 heads, 63 sectors/track, 24321 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk identifier: 0x1c841c84 Device Boot Start End Blocks Id System /dev/sda1 1 574 4604008+ c W95 FAT32 (LBA) Partition 1 does not end on cylinder boundary. /dev/sda2 * 575 8967 67416772+ 7 HPFS/NTFS /dev/sda3 8968 24321 123331005 f W95 Ext'd (LBA) /dev/sda5 8968 9229 2104483+ 82 Linux swap / Solaris /dev/sda6 9230 11840 20972826 83 Linux /dev/sda7 11841 24321 100253601 83 Linux beneden:~ #
- Partition 1 is a restore partition put there by the manufacturer.
- Partition 2 contains a Windows XP system (this system calls it it's
- Partition 3 is the extended partition it runs until the end of the disk and holds the following three:
- Partition 5 is the openSUSE swap partition.
- Partition 6 is the openSUSE root partition.
- Partition 7 is the openSUSE /home partition.
In the partition table partitions are simply numbered as we saw above.
A special warning here about GRUB. Grub has its own naming/numbering schema and the most important thing to know is that GRUB starts all disk and partition counting at 0 and not at 1!
When the Linux system starts, it scans the hardware and when it finds disks and partitions it gives them names. These names are to be found as the names of the device special files in
/dev/. Disk will have names like
... and partitions of
hda will be
... and those of
sda will be
... where the number is the partition number.
What are these device special files? A special type of file that is associated with hardware. I/O to the hardware is done by reading from / writing to this file. This is the file metaphor in Unix/Linux. There are two types of these files: character device special file and block device special file. For disks we do I/O in blocks. Of course this is too long to pronounce so most people talk about device files. Normally they are created in the
/dev/ directory (nowadays dynamically by
udev). Here is what they look like when you list them:
boven:/dev # ls -l sda* brw-r----- 1 root disk 8, 0 Apr 27 09:45 sda brw-r----- 1 root disk 8, 1 Apr 27 09:45 sda1 brw-r----- 1 root disk 8, 2 Apr 27 09:45 sda2 brw-r----- 1 root disk 8, 3 Apr 27 09:45 sda3 boven:/dev #
Most things will be familiar to you. The
b says it is a block device special file. Normal users are not allowed to read/write direct from/to the disk, else all security would be futile. The numbers
8 (called the major number) is the number the kernel uses internal for the driver that works with these devices (so it will not send tape commands to disks) and the
3 (the minor number) tell them apart from each other inside that driver.
Until not long ago these
/dev/sdb2, etc. were used to mount the partitions and when you give the command
mount (shows what is mounted) you will see them used.
boven:~ # mount /dev/sda2 on / type ext3 (rw,acl,user_xattr) /dev/sda3 on /home type ext3 (rw) ... boven:~ #
This is based on the fact that on every boot the system finds the disks in the same sequence. When not, sda and sdb may be exchanged and the wrong partitions mounted! This can not only happen at boot, but when a disk is connected to the already running system it will get the 'next' name (e.g. sdc). What we need is a unique identifier of the disk. And there is. There are even more. Look at
/dev/disk/. There are several directories there:
boven:~ # ls -l /dev/disk total 0 drwxr-xr-x 2 root root 360 Jul 5 2008 by-id drwxr-xr-x 2 root root 100 Jul 5 2008 by-label drwxr-xr-x 2 root root 220 Jul 5 2008 by-path drwxr-xr-x 2 root root 80 Jul 5 2008 by-uuid boven:~ #
Look inside these directories. Every one of them has some or all of the partitions, identified in a different way. And all these files are not device special files, but link to the device special files we saw earlier. When you look in
boven:~ # cat /etc/fstab /dev/disk/by-id/scsi-SATA_Hitachi_HDT7250_VFJ201R23XUEXW-part2 / ext3 acl,user_xattr 1 1 /dev/disk/by-id/scsi-SATA_Hitachi_HDT7250_VFJ201R23XUEXW-part3 /home ext3 defaults 1 2 /dev/disk/by-id/scsi-SATA_Hitachi_HDT7250_VFJ201R23XUEXW-part1 swap swap defaults 0 0 ... boven:~ #
You will see that openSUSE nowadays uses the
/dev/disk/by-id/ names to see that the correct partitions are mounted:
boven:~ # ls -l /dev/disk/by-id lrwxrwxrwx 1 root root 9 Jul 5 2008 scsi-SATA_Hitachi_HDT7250_VFJ201R23XUEXW -> ../../sda lrwxrwxrwx 1 root root 10 Jul 5 2008 scsi-SATA_Hitachi_HDT7250_VFJ201R23XUEXW-part1 -> ../../sda1 lrwxrwxrwx 1 root root 10 Jul 5 2008 scsi-SATA_Hitachi_HDT7250_VFJ201R23XUEXW-part2 -> ../../sda2 lrwxrwxrwx 1 root root 10 Jul 5 2008 scsi-SATA_Hitachi_HDT7250_VFJ201R23XUEXW-part3 -> ../../sda3 ... boven:~ #
文件系统 (缩写: fs)
Now we have one or more partitions and we want to use them. Well, there are some programs who can use the raw partition as it is, but mostly we want to put data organised in directories/files on it or use it for swap. For the usage as a filesystem (or swap) an empty filsystem must be created on the partition. Many people call this formatting, but in Unix/Linux you create or make a filesystem and the tool is
mkfs. We will not go into details here, but what goes into an empty filesystem (inodes, etc.) depends on the filesystem type. A ReiserFS is different from an ext2 or ext3 fs. You have to make the choice.
You do not need to call the
mkfs of the fs type you want yourself. YaST wil do this for you.
What is important here is that Linux can not only access filesystem types that are designed for it, but also types that are used by MS/DOS ... Vista sytems like FAT and NTFS. But there are restrictions. FAT has restrictions on filename length. Both do not have the Unix/Linux permission bits and this means that sometimes access is restricted without proper handling (filesystem options at mount time).
Before we start to use the partitions, first some explanation about the terminology and concepts used in Unix/Linux in this area.
All of the data stored om mass storage devices in a Unix/Linux system consists of only one hierarchic tree starting from the root (
/). This is contrary to the MS/DOS .... Vista concept where every disk (partition) has it own hierarchic tree (starting at
A directory is a special type of file that holds the descriptions of other files. All directories are nodes in the hierarchic tree. From other OSs and from the desktop metaphor words like map and folder are also used by end users, but the Unix/Linux word is directory.
The root of the hierarchic tree is thus also a directory. It is called the root directory or short root. (This is the same word, but not the same entity as the
root user). When used on its own, the root directory is written
The mount point is the place in the hierarchic tree where a filesystem is mounted. This point can be anywhere in the (already mounted) tree (no need to keep oneself restricted to mount points in
/media/). It is a directory. Every directory can be used as a mount point. But be carefull. When a directory already has files, the mounting of an fs on it will make these files unreachable! Only after unmounting they will be reachable again (they stay where they were and still occupy space on the disk).
Some system managers make use of this. When creating a mountpoint they will make a file in it with a useful name:
mkdir mountpoint touch mountpoint/The-fs-is-not-mounted mount /dev/... mountpoint ls mountpoint
I will now show the contents belonging to the mounted fs. When the fs is not mounted, the same
ls will show the file
A lot of mounting is done high in the hierarchy. e.g. On the highest level there can (and must) only be one:
/(this is mounted readonly very early in the startup sequence, else no tools would be available, not even
mount, later it is re-mounted read/write)
One level down:
/home(very often done)
/bin(mounted over the network for a very small system)
/sbin(NO, do not try this one,
/sbin/contains those things like
mountneeded at system startup before the rest of the mounting is done!)
/mnt/...(nice place for a system manager to mount things during maintanance)
/media/...(conventional place for CDs, DVDs and the like)
And according ones needs:
/home/movielover/Documents/movies/archive(A partition for this user only. When it is full he is on his own. Let him pay for the Gigs).
Remark that you can not mount the last one unless you have mounted
The very act of (un)mounting is of course done by the kernel. The tool that the system manager uses to interact with the kernel for this is
man mount for more info. The tool needs basicaly four things:
- which fs type to mount (with the
- options that influence the fs, they are different for each fs type (with the
- what to mount (for a local mount this is the block special device file of the partition)
- where to mount (the mount point directory)
That can be a lot of typing when you are doing some tests, but
/etc/fstab comes handy here. When you specify all those parameters in
/etc/fstab, mount only needs either the mount point or the device special file. What is not specified is found in
But the real usage of
/etc/fstab is that it is used at system startup to mount all those partitions that you always need. And do not put the line for
/home/movielover/Documents/movies/archive before the line for
/etc/fstab 在您的系统上（或互联网上）都有Man手册页，以方便您的参阅。 Yast > System > Partitioner 是个非常有用的图形界面，您也许必须回到CLI命令行，在运行级别3或单用户模式的时候（因为您可能需要在分区的时候卸载一部分文件系统）。 由于部分原因，您可能甚至需要从救援CD／DVD上运行
/根分区)。 考虑更多的话可能就是可引导的图形界面比如 Gparted ，这些工具对文件系统的集成或改变其大小的技术很成熟，但超出了本文的讨论范围。