Linux - NewbieThis 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!
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
Here is my stock answer on partitions. It's quite long and maybe you know most of the material, but it also explains your question.
What are partitions?
Modern hard disks are very big, capable of storing hundreds of gigabytes of software, personal datafiles, music etc... Because of their huge size, hard disks are typically partitioned to make them more usable as multiple smaller disks - as there is really no need to have such large disks for any practical purpose. Partitions give advantages in backing up data, using disks that have bad sectors, saving space by preventing the need for large allocation units, and more... But most importantly for Linux users - partitions also allow one to install more than one operating system on the same computer, and each OS will respect the data of the other OS and not try to use it as a disk of its own. Partitions can be pictured as being strict "borders" that mark the beginning and ending of each OS allocated space.
The hard disk can be partitioned to 4 partitions, also called the 4 "primary" partitions. That is usually enough for most people, but sometimes being able to partition the disk to only 4 parts can be a limitation, so to work around that limitation and allow more than 4 partitions - a partition can be created for the sole purpose of containing more partitions inside of it. A partition that holds partitions inside it is called an "extended" partition, and the partitions inside it are called "logical" partitions. Each extended partition can hold 4 logical partitoions.
In Linux, the first hard disk is usually called sda (which stands for SCSI disk 'a' or SATA disk 'a') and the 4 primary partitions on it will be called sda1, sda2, sda3 and sda4. If the computer has another hard disk in it (or also if you plug in a USB external hard disk for example) you will see it as sdb and the partitions on disk b will be called sdb1, ..., sdb4. Logical partitions get numbers higher than 4, so for example sda5 is a logical partition (a partition inside an extended partition), and also sda6 would be a logical partition, but sda2 is one of the primary partitions. By the way, in Windows partitions get drive letters (C:, D:, E: ... and so on) **BUT** that's true only if those partitions are formatted as NTFS or FAT. In other words, Windows only "sees" partitions that it can read, and it completely ignores and doesn't give access to other drives and partitions (so you won't see Linux files when you are running a Windows session).
How to view partitions from Windows?
You can see the current layout of your disk partitions from Windows XP. It is usually advisable to do so before starting a Linux installation - in order to plan the installation and see what is the best way to back up the data before booting the Linux installation. Be very careful, though; when performing these steps you can easily delete a partition by accident and lose all data in it. It doesn't hurt to backup important data to an internet storage or CD before starting these steps.
From Windows XP:
1) Right-click on "My Computer" and choose "Manage" (and don't choose "properties" like you're always used to)
2) Click on the disk manager
You will see, on the right side of the window, a graphical layout of the disks and partitions on them. The important points to look for are:
*) How many partitions does the disk currently have? Is it all 1 gigantic partition or is it split to 2 or more parts?
*) Is there free, unallocated disk space, which is currently not assigned as an NTFS, FAT or any other partition? Note that this is not the same as the free space you have on C: or D: ... We are talking about unallocated space which **does not belong to** any partition that currently exists.
*) Linux needs at least 2 partitions to install. Will it be possible to create those partitions as primary partitions or will we have to use extended partitions?
Most people at home, who bought their PC with Windows already installed on it, will typically find that they have 2 partitions and no free (unallocated) space. Having no unallocated space means that we will have no choice but to delete one of the existing partitions, and recreate it but this time make it smaller. We may also decide to delete and never recreate a partition (for example if we never used it for anything and it was empty anyways). The situation gets more complicated if the entire disk is currently allocated to just 1 partition, and deleting it means having to reinstall everything after we create it again. You have to make the decision now - which partition will you delete? Where will you back up the data to? Do you have the needed installation disks and skills to reinstall if you plan to delete your current OS?
There is another alternative which I hate to discuss - but I will mention it so that you will know about it. Many Linux distributions give you the option to resize existing partitions and shrink them instead of deleting them to make room for the Linux partitions. This can help as a last resort if your entire disk is already allocated and you can't afford to delete partitions. There are also commercial softwares that can resize and move partitions without losing the data in them. However - moving and resizing partitions is considered a very dangerous operation that should only be used as a last resort. What these programs do is in fact rewrite the entire file system on the partition that they resize - and if anything goes wrong during the process you end up with a trashed partition. I've seen it happen. There is never any guarantee - so always have backups for your most important data (and don't store those backups on the hard disk). In addition to that, if you plan to resize a Windows partition - make sure you defrag it first.
What partitions Linux needs
Linux is quite an exception in that it requires 2 partitions for itself as a minimum, and not just 1. The main Linux partition will be formatted as an ext3 filesystem (ext3 stands for "3rd extended" which is the latest incarnation of the most widely used filesystem in Linux). The second partition you'll need is a swap partition. Swap is a specially allocated disk space used to extend the available memory on your computer, in order to allow modern multitasking operating systems such as Linux to run many applications in the background, while the total amount of memory requirements for all the running applications together exceeds the total installed RAM that you have. Windows operating systems also use swap for the same reason - but they use a swap file for that. The advantage of having a swap partition instead of a file is that it is a lot faster (no need to read and write into a file etc), and the disadvantage is that the partition can't grow like a file does (and we have a 4 partition limitation...).
The minimum size for a Linux partition is 1-4GB, depending on the distro that you are installing. However, the more the better and I recommend at least 20 GB for a full-featured Linux that you can play around with and install lots of software. The size of the swap partition, on the other hand, is very small and should just be big enough for Linux to swap all memory out of the RAM and back in. In other words - make the swap partition size equal twice the amount of RAM you have. If you have 1GB of RAM, make a 2GB swap partition (more than that will take space that could have been used for software and less than that might not be enough for some Linux features).
When you run the installation program of your Linux distribution, you will quickly reach the stage where you are asked to partition your drive. Take a look at the partition layout that is displayed and make sure you correctly identify which partition is used by which OS, and which is the one you planned to delete (or if you can find free space to use). This is the critical installation step where most new users end up trashing their Windows XP... It is worth to note that if you do mess up, or not sure if you did the right thing, Linux has the comforting feature that it doesn't immediately write the changes to disk, and you can just go back and start the partitioning step again without committing any permanent damage.
In a typical Linux distribution partitioning program, to delete a partition - select the partition and click on "Delete". To create a new partition, select the free unallocated space and click on the "New" button. When you create a new partition, a dialog will typically pop up and ask for the partition size, type and mount point (mount points will be explained very soon). First create the small swap partition - to do that, you select "swap" as the partition type and give it a fixed size equal to twice the amount of RAM you have. Next, click on the remaining unallocated space and use it for the root Linux partition. You will use all available space for that and mark the partition type as "ext3". The mount point of this partition will be "/" - that's what marks the beginning of the filesystem in Linux. Also be sure to mark the "format" checkbox so that this new Linux partition will be formatted for you (if you don't - doesn't matter, because the installer will actually format the "/" partition automatically even if you don't choose to).
After creating the swap and root partitions, you are basically done and you can move on to the next step in the Linux installation program and not read the rest of this section. If you want, though, you can also choose mount points at this stage for all the other partitions you have. Mount points are used in Linux to access disks and filesystems such as CDROM drives and Windows partitions. Linux doesn't give these drives any drive letters such as C: or D: etc like in Windows, instaed it mounts them somewhere under the root "/" filesystem and you can browse to them like you browse to any other directory. For example, you can choose to mount your Windows partition under /mnt/windows or /mnt/drive_c or anything else you want to call it. Be careful when choosing mount points, not to accidentally allow Linux to format them and not to change their current format (NTFS or whatever the format is currently). Besides, it might also be a much better idea not to choose any mount points in the Linux partitioner because most Linux distributions mount partitions on-the-fly, and leave those partitions unmounted the rest of the time when they are not needed. Linux beginners should do the minimum - only create a swap partition and a root partition.