Documente Academic
Documente Profesional
Documente Cultură
You can generally view the partitions that system recognized via fdisk -l. If LVM is
used it produced a lot of extra junk messages that need to be filtered, but still
information is usable. .
On the desktop PC among the typical reasons that the disk is not visible is that you
forget to attach power or interface cable or both :-).
During installation, you are asked which partitioning method to use. You can remove
linux partitions on selected drives and create the default layout, remove all partitions
on selected drives and create the default layout, use free space on selected drives and
create the default layout, or create a custom layout.
Linux uses DOS partitioning scheme with up to four primary partitions. Instead of one
primary partitions an extended partition can be created and it can be as many sub
partitions on extended partitions as you wish. That is actually the standard partitioning
scheme: three primary partitions and one extended.
The key idea of right partitioning from the performance point of view is balancing the
key partitions near the middle of the drive, for example
boot
home
/
================ middle of the drive
/var
/tmp
swap
/backup
Some excellent Windows partitioning and backup tools like Ghost, Acronis True
Image, Partition Magic understand and can work with Linux partitions.
Three primary partitions are usually created directly (boot, root partition and swap).
For extended partition traditionally the Logical Volume Manager (LVM) is used to
divide the hard drive, and then the necessary Linux mount points are created. Please
note that this is a mixed blessing: in case of corruption recovery is more difficult.
On desktops for reliability you can use hardware (for example in external USB 3.0 or
eSCSI enclosure) or (more problematic) software RAID.
LVM: to use or not use
LVM offer an important benefit: the ability to resize partitions dynamically as well as
combining multiple logical hard drives into logical physical devices (the latter
function typically is also provided by disk controller so it is not really important.
It is not recommended for root partition unless you understand LVM really well, as it
complicates recovery of unbootable system.
To view a list of partitions on the system, use the fdisk -l command as root. If the
system uses LVM or RAID, the fdisk -l output will reflect it.
During installation, the hard drives can be partitioned, given a filesystem type for
formatting, and assigned a mount point. If hard drives are added to the system after
installation or a hard drive has to be replaced, it is important to understand how to
perform these functions post-installation.
Caution
If you use multipath it is better to use LVM. Otherwise you device names will be /dev/dm-0, dev/dm-1 and
so on.
Perform all these actions in rescue mode without the filesystem mounted or ensure the entire device is
not mounted before manipulating the partition table for it. Most changes to the partition table require a
reboot. When you exit rescue mode, the system will reboot.
Creating Partitions
A partition can be created only from free space on a hard drive. If there is no free
space one or several partitions should be deleted before new can be created. You
might also add a new hard drive to the system.
There are two partitioning utilities in Red Hat Enterprise Linux: parted and fdisk.
The parted utility includes a resize utility and is a bit more user-friendly. But most
admin still use fdisk. It has support for BSD disk labels and other non-DOS partition
tables. For more information see the man page.
Fdisk usage
Fdisk usage is well described in Linux Partition HOWTO ( Partitioning with fdisk)
and Novell article Manually Partitioning Your Hard Drive with fdisk.
Examples:
fdisk is started by typing (as root) fdisk device at the command prompt. device might be something
like /dev/hda or /dev/sda (see Section 2.1.1). The basic fdisk commands you need are:
Changes you make to the partition table do not take effect until you issue the write (w) command. Here is
a sample partition table:
The first line shows the geometry of your hard drive. It may not be physically accurate, but you can accept
it as though it were. The hard drive in this example is made of 32 double-sided platters with one head on
each side (probably not true). Each platter has 621 concentric tracks. A 3-dimensional track (the same
track on all disks) is called a cylinder. Each track is divided into 63 sectors. Each sector contains 512
bytes of data. Therefore the block size in the partition table is 64 heads * 63 sectors * 512 bytes
er...divided by 1024. (See 4 for discussion on problems with this calculation.) The start and end values
are cylinders.
5.2. Four primary partitions
The overview:
Decide on the size of your swap space (see Section 4.4) and where it ought to go (see Section 4.4.3).
Divide up the remaining space for the three other partitions.
Example:
# fdisk /dev/hdb
which indicates that I am using the second drive on my IDE controller. (See Section 2.1.) When I print the
(empty) partition table, I just get configuration information.
I knew that I had a 1.2Gb drive, but now I really know: 64 * 63 * 512 * 621 = 1281982464 bytes. I decide
to reserve 128Mb of that space for swap, leaving 1153982464. If I use one of my primary partitions for
swap, that means I have three left for ext2 partitions. Divided equally, that makes for 384Mb per partition.
Now I get to work.
Command action
e extended
Command action
e extended
I set up the remaining two partitions the same way I did the first. Finally, I make the first partition bootable:
Side topics:
Section 10.2
Section 10.1
Section 10.3
The overview: create one use one of the primary partitions to house all the extra partitions. Then create
logical partitions within it. Create the other primary partitions before or after creating the logical partitions.
Example:
# fdisk /dev/sda
which indicates that I am using the first drive on my SCSI chain. (See Section 2.1.)
First I figure out how many partitions I want. I know my drive has a 183Gb capacity and I want 26Gb
partitions (because I happen to have back-up tapes that are about that size).
183Gb / 26Gb = ~7
so I will need 7 partitions. Even though fdisk accepts partition sizes expressed in Mb and Kb, I decide to
calculate the number of cylinders that will end up in each partition because fdisk reports start and stop
points in cylinders. I see when I enter fdisk that I have 22800 cylinders.
> The number of cylinders for this disk is set to 22800. There is
> nothing wrong with that, but this is larger than 1024, and could in
> certain setups cause problems with: 1) software that runs at boot
> time (e.g., LILO) 2) booting and partitioning software from other
So, 22800 total cylinders divided by seven partitions is 3258 cylinders. Each partition will be about 3258
cylinders long. I ignore the warning msg because this is not my boot drive (Section 4).
Since I have 4 primary partitions, 3 of them can be 3258 long. The extended partition will have to be (4 *
3258), or 13032, cylinders long in order to contain the 4 logical partitions.
I enter the following commands to set up the first of the 3 primary partitions (stuff I type is bold ):
Command action
e extended
Next I segment the extended partition into 4 logical partitions, starting with the first logical partition, into
3258-cylinder segments. The logical partitions automatically start from /dev/sda5.
Finally, I issue the write command (w) to write the table on the disk. To make the partitions usable, I will
have to format (Section 10.1) each partition and then mount (Section 10.3) it.
I'd like to submit my partition layout, because it works well with any distribution of Linux (even big RPM
based ones). I have one hard drive that ... is 10 gigs, exactly. Windows can't see above 9.3 gigs of it, but
Linux can see it all, and use it all. It also has much more than 1024 cylenders.
I test new kernels for the USB mass storage, so that explains the large /boot partition. I install LILO into
the MBR, and by default I boot windows (I'm not the only one to use this computer).
I also noticed that you don't have any REAL examples of partition tables, and for newbies I HIGHLY
suggest putting quite a few up. I'm freshly out of the newbie stage, and partitioning was what messed me
up the most.
Usage of parted
As root, issue the parted command followed by the device name such as
parted /dev/sda
You are now in an interactive parted shell, in which the commands executed manipulate
the device specified.
Once again, the output will differ depending on the partitioning scheme being used.
To create a partition in parted, issue the following command at the interactive parted
prompt:
The ext3 filesystem is the default filesystem for Red Hat Enterprise Linux. It is the
ext2 filesystem plus journaling. To create an ext3 filesystem, use ext2 as the <fs-
type> and then use the -j option to mke2fs to make the filesystem ext3 as described in the
next section.
After creating the partition, use the print command again to verify that the partition was
created. Then type quit to exit parted.
Next, create a filesystem on the partition. To create an ext3 filesystem (default used
during installation), as root, execute the following, where <device> is the device name
for the partition such as /dev/sda1:
mke2fs -j <device>
If the partition is to be a swap partition, format it with the following command as root:
mkswap <device>
While labeling is not required, partition labels can be useful. For example, when
adding the partition to /etc/fstab, the label can be listed instead of the partition device
name. This proves useful if the partition number is changed from repartitioning the
drive or if the partition is moved.
If the e2label command is used with just the partition device name as an argument, the
current label for the partition is displayed.
Creating a Mount Point
Now that the partition is created and has a filesystem, as root, create a directory so it
can be mounted:
mkdir <dir-name>
such as:
Access the directory and make sure you can read and write to it.
Finally, add the partition to the /etc/fstab file so it is mounted automatically at boot time.
For example:
If a new swap partition is added, be sure to use swap as the filesystem type instead:
Resizing Partitions
The parted utility can also be used to resize a partition. After starting parted as root on the
desired device, use the following command to resize a specific partition:
To determine the <minor-num> for the partition, look at the partition table with
the print command. The <start> and <end> values should be the start and end points of the
partition, in megabytes.
Removing Partitions
To use parted to remove a partition, start parted on the desired device as root, and issue
the following command at the interactive prompt:
rm <minor-num>
The minor number for the partition is displayed when you execute the print command
to list partitions. The data on the partition will no longer be accessible after the
partition is removed, so be sure to back up any data you want to keep before removing
the partition.
References
The Linux System Administrator's Guide contains several chapters on this theme:
4. Hardware, Devices, and Tools
4.1. Hardware Utilities
4.2. Kernel Modules
5. Using Disks and Other Storage Media
5.1. Two kinds of devices
5.2. Hard disks
5.3. Storage Area Networks - Draft
5.4. Network Attached Storage - Draft
5.5. Floppies
5.6. CD-ROMs
5.7. Tapes
5.8. Formatting
5.9. Partitions
5.10. Filesystems
5.11. Disks without filesystems
5.12. Allocating disk space
Linux Newbie Guide by Stan, Peter and Marie Klimas contains chapter 4.2 about
drives
Part 4.2: Drives
Where are my drives, how to access them, configure user access, get the zip drive recognized, set 32-bit
hard drive IO, increase the limit on the number of opened files, add a new hardrive, manage the swap
space ...
Top visited
Google Search
Past Past
Bulletin Latest
week month
A block device is an abstraction layer for any storage device that can be formatted in fixed-size blocks;
individual blocks may be accessed independently of access to other blocks. Such access is often
called random access.
The abstraction layer of randomly accessible fixed-size blocks allows programs to use these block
devices without worrying about whether the underlying device is a hard drive, floppy, CD, solid-state
drive, network drive, or some type of virtual device such as an in-memory file system.
Examples of block devices include the first IDE hard drive on your system (/dev/sda or /dev/hda) or the
second SCSI, IDE, or USB drive (/dev/sdb). Use the ls -l command to display /dev entries. The first
character on each output line is b for a block device, such as floppy, CD drive, IDE hard drive, or SCSI
hard drive; and c for a character device, such as a or terminal (tty) or the null device. See the
examples in Listing 1.
Partitions
For some block devices, such as floppy disks and CD or DVD discs, it is common to use the whole media
as a single filesystem. However, with large hard drives, and even with USB memory keys, it is more
common to divide, or partition, the available space into several different partitions.
Partitions can be different sizes, and different partitions may have different filesystems on them, so a
single disk can be used for many purposes, including sharing it between multiple operating systems. For
example, I use test systems with several different Linux distributions and sometimes a Windows® system,
all sharing one or two hard drives.
You will recall from the article, "Learn Linux 101: Learn Linux, 101: Hard disk layout," that hard drives
have a geometry, defined in terms of cylinders, heads, and sectors. Even though modern drives
uselogical block addressing (LBA), which renders geometry largely irrelevant, the fundamental allocation
unit for partitioning purposes is usually still the cylinder.
The fdisk command with the -l option is used to list partitions. Add a device name, such as /dev/sda, if
you want to look at the partitions on a particular drive. Note that partitioning tools require root access.
Listing 2 shows the partitions on the primary hard drives of two of my systems.
.... ....
Notes:
1. The header information shows the disk size and geometry. Most large disks using LBA
have 255 heads per cylinder and 63 sectors per track, making a total of 16065 sectors, or
8225280 bytes per cylinder.
2. In the second example, the first primary partition (/dev/sda1) is
marked bootable (or active). This enables the standard DOS PC master boot record to
boot the partition. This flag has no significance for the LILO or GRUB boot loaders. The
first example uses GRUB as the boot loader, and the fact that /dev/sda3 is marked
bootable is probably an accident of the history of my use of this drive.
3. The Start and End columns show the starting and ending cylinder for each partition.
These must not overlap and should generally be contiguous, with no intervening space.
4. The Blocks column shows the number of 1K (1024 byte) blocks in the partition. For most
disks in use at the time of writing, the sector size is 512 bytes, so the maximum number
of blocks in a partition is therefore half of the product of the number of cylinders (End + 1
- Start) and the number of sectors per cylinder. A trailing + sign indicates that not all
sectors in the partition are used.
5. The Id field indicates the intended use of the partition. Type 82 is a Linux swap partition,
and type 83 is a Linux data partition. There are approximately 100 different partition types
defined. The second disk is shared between several operating systems, including
Windows/XP, hence the presence of Windows NTFS (and possibly FAT32) partitions.
You have just seen how to display partition information using the fdisk command. This command also
provides a menu-driven environment for editing the partition table to create or remove partitions.
Warnings
Before you start modifying partitions, there are some important things to remember. You risk losing
your existing data if you do not follow these guidelines.
1. Back up important data before you start, as with any operation that may
cause data loss.
2. Do not change partitions that are in use. Plan your actions and execute them
carefully. Booting a live distribution from CD, DVD, or USB is one good way to ensure
that no hard drive partitions are in use.
3. Know your tool. The fdisk command does not commit any changes to your disk until
you tell it to. Other tools, including parted, may commit changes as you go.
4. Stop if you do make a mistake. Partitioning tools write the partition table. Unless
the tool you are using also includes the ability to move, resize, format, or otherwise write
to the data area of your disk, your data will not be touched. If you do make a mistake,
stop as quickly as possible and seek help. You may still be able to restore your previous
partition table definitions and thus recover your partitions and data.
Start fdisk
To start fdisk in interactive mode, simply give the name of a disk, such as /dev/hda or /dev/sdb, as a
parameter. The following example boots a Knoppix live DVD. You will need root authority, and you will
see output similar to Listing 3.
There is nothing wrong with that, but this is larger than 1024,
Most modern disks have more than 1024 cylinders, so you will usually see the warning shown in Listing 3.
Type m to display a list of available one-letter commands as shown in Listing 4.
Command action
d delete a partition
Use the p command to display the existing partition on this particular disk; Listing 5 shows the output.
This particular disk is a 1TB disk with a Windows/XP partition of a little under 80GB. It is a primary
partition, and it is marked bootable, as is typical for a Windows system.
Adding partitions
Let's now use part of the free space to add some partitions.
1. We will create a swap partition as /dev/sda4. This will be a primary partition, filling the
521 cylinder gap between the end of /dev/sda1 and the start of /dev/sda2. Don't even
begin to wonder what crazy things cause this gap to exist; I created the gap deliberately
so I could write this article.
2. We will create a 40GB logical partition as /dev/sda8.
3. Finally, we will create a small 2000MB logical partition for sharing data between the Linux
and Windows systems. This will eventually be formatted as FAT32 (or vfat). It will be
/dev/sda9.
Let's start by using the n command to create a new partition; see Listing 6.
Command action
l logical (5 or over)
Selected partition 4
We took the default for the first cylinder and specified the value of +521 for the number of cylinders. You
can see from Listing 6 that our partition is approximately 4GB in size. Since it is a primary partition, it must
be numbered from 1 through 4. It is a good idea to assign partition numbers sequentially; some tools
complain if this is not done and fdisk warns us that our partition table entries are no longer in disk order.
Notice also that our new partition was assigned a type of 83, for a Linux data partition. Think of this as an
indicator to the operating system of the intended use of the partition. The eventual use should match this,
but at this point we don't even have the partition formatted, let alone have any data on it. We'll create out
other partitions first, then look at how to change the partition type.
You may have noticed that when we entered the n subcommand to create a new partition, the only
choices were 'l' for logical and 'p' for primary. You will only see options for the remaining possible types of
partitions. You would see 'e' for extended if the drive did not already have an extended partition. Also note
that our extended partition (/dev/sda3) is type 5.
Now let's define the 40GB Linux partition and the 2000MB FAT32 partition. This time we will simply
specify sizes of +40G and +2000M, indicating 40GB and 2000MB, respectively. We let fdisk calculate the
number of cylinders for us. The results are shown in Listing 7.
Before we leave fdisk, we will change the partition types for the swap and vfat partitions. We do this using
the t subcommand to set the partition type. We set /dev/sda4 to type 82 (Linux swap) and /dev/sda9 to
type 9 (FAT32). If you want to see the full list of supported types, enter L as you see in Listing 8.
So far, we have just been doing an in-memory edit of a partition table. We could use the q command to
quit without saving changes. If something is not how you want it, you can use the d command to delete
one or more partitions so you can redefine them. If you are happy with your setup, use the v command to
verify your setup, and then the w command to write the new partition table and exit. See Listing 9. If you
run fdisk -l again, you will see that Linux now knows about the new partitions. Unlike in some operating
systems, it is not always necessary to reboot to see the changes. A reboot may be required if, for
example, /dev/hda3 became /dev/hda2 because the original /dev/hda2 was deleted. If a reboot is
needed, fdisk should tell you to do so.
information.
Syncing disks.
More on fdisk
You may notice that we did not change the bootable flag on any partition. As our disk stands now, it still
has the Windows Master Boot Record (MBR) and will therefore boot the first primary partition that is
marked bootable (the NTFS partition in our example).
Neither LILO nor GRUB uses the bootable flag. If either of these is installed in the MBR, then it can boot
the Windows/XP partition. You could also install LILO or GRUB into your /boot partition (/dev/hda2) and
mark that partition bootable and remove the bootable flag from /dev/hda1. Leaving the original MBR can
be useful if the machine is later returned to being a Windows-only machine.
You can also use fdisk to fix the partition order in the partition table if you need to. This will usually
change the partition numbers, so you may have other work to do to restore your system to a working
system. To make this change, use the f subcommand to switch to expert mode and then
the f subcommand to fix the partition order, as shown in Listing 10. If you just want to see what the new
partition order would be without changing it, you can use the q subcommand to quit as we have done in
this example, rather than writing the updated partition table to disk.
Done.
You have now seen one way to add partitions to a Linux workstation. Other choices you might make are
covered in the article, "Learn Linux, 101: Find and place system files."
Filesystem types
Linux supports several different filesystems. Each has strengths and weaknesses and its own set of
performance characteristics. One important attribute of a filesystem is journaling, which allows for much
faster recovery after a system crash. Generally, a journaling filesystem is preferred over a non-journaling
one when you have a choice. You may also want to consider whether your chosen filesystem
supports Security Enhanced Linux (or SELinux). Following is a brief summary of the types you need to
know about for the LPI exam. See Resources for additional background information.
The ext2 filesystem (also known as the second extended filesystem) was developed to address
shortcomings in the Minix filesystem used in early versions of Linux. It has been used extensively on
Linux for many years. There is no journaling in ext2, and it has largely been replaced by ext3.
The ext3 filesystem adds journaling capability to a standard ext2 filesystem and is therefore an
evolutionary growth of a very stable filesystem. It offers reasonable performance under most conditions
and is still being improved. Because it adds journaling on top of the proven ext2 filesystem, it is possible
to convert an existing ext2 filesystem to ext3 and even convert back again if required.
Swap space must be formatted for use as swap space, but it is not generally considered a filesystem.
This filesystem (also known as FAT32) is not journaled and lacks many features required for a full Linux
filesystem implementation. It is useful for exchanging data between Windows and Linux systems as it can
be read by both Windows and Linux. Do not use this filesystem for Linux, except for sharing data
between Windows and Linux. If you unzip or untar a Linux archive on a vfat disk, you will lose
permissions, such as execute permission, and you will lose any symbolic links that may have been stored
in the archive.
The ext3 filesystem is mature and is used as the default filesystem on a number of distributions. The
ReiserFS filesystem was used for many years as the default on some distributions, including SUSE, but is
less used today.
Creating filesystems
Linux uses the mkfs command to create filesystems and mkswapcommand to make swap space.
The mkfs command is actually a front end to several filesystem-specific commands such as mkfs.ext3 for
ext3 and mkfs.reiserfs for ReiserFS.
What filesystem support is already installed on your system? Use the ls /sbin/mk* command to find out.
An example is shown in Listing 11.
You will notice various forms of some commands. For example, you will usually find that the files mke2fs,
mkfs.ext2, and mkfs.ext3 are identical, as are mkreiserfs and mkfs.reiserfs. Filesystems that may be
needed to boot the system will use multiple identical files with different names. Filesystems that cannot be
used for the / filesystem in Linux, such as vfat or msdos, may use symbolic links instead.
There are a few common options for all mkfs commands. Options that are specific to the type of
filesystem being created are passed to the appropriate creation command, based on the type of
filesystem specified in the -type option. Our examples use mkfs -type, but you may use the other forms
directly with equal effect. For example, you may use mkfs -type ext2, mk2fs, or mkfs.ext2. For the manual
pages for a specific filesystem, use the appropriate mkfs command as the name, for example, man
mkfs.ext3. Many of the values displayed in the output examples below can be controlled by options
to mkfs.
Now that we have created all our partitions, we will reboot the Fedora 12 system and format the
filesystems using that rather than the somewhat slower live Knoppix DVD. Of course, you could continue
to use the Knoppix system if you wished. Remember that you need root authority to create filesystems.
Let's format the /dev/sda8 partition as ext3 using the mkfs command as shown in Listing 12.
Filesystem label=
OS type: Linux
4096000, 7962624
Note that a journal is created with ext3. If you wish to add a journal to an existing ext2 system, use
the tune2fs command with the -j option.
A useful option for ext2 and ext3 filesystems is the -L option with a name, which assigns a label to the
partition. This can be used instead of the device name when mounting filesystems; it provides some level
of insulation against changes that may need to be reflected in various control files. To display or set a
label for an existing ext2 or ext3 filesystem, use the e2label command. Labels are limited to a maximum
size of 16 characters.
A more recent development is to use a Universally Unique Identifier, or UUID, rather than a label. A UUID
is a 128-bit identifier usually displayed as 32 hexadecimal digits and four hyphens. Most Linux filesystems
generate an UUID automatically when the filesystem is formatted. Use the blkid command (which does
not need root authority) as shown in Listing 13 to see the UUID for the partition we just formatted. UUIDs
are more likely to be unique than labels and are especially useful for hot-plugged devices such as USB
drives.
Now let's create some swap space on the /dev/sda4 partition using the mkswap command as shown in
Listing 16.
no label, UUID=8f5a3a05-73ef-4c78-bc56-0e9b1bcc7fdb
Note that recent versions of mkswap show you the generated UUID.
Unlike regular filesystems, swap partitions aren't mounted. Instead, they are enabled using
the swapon command. Your Linux system's startup scripts will take care of automatically enabling your
swap partitions.
Red Hat
Unless you have a reason for doing otherwise, we recommend that you create the following partitions for
x86, AMD64, and Intel® 64 systems:
A swap partition (at least 256 MB) — swap partitions are used to support virtual memory.
In other words, data is written to a swap partition when there is not enough RAM to store
the data your system is processing.
If you are unsure about what size swap partition to create, make it twice the amount of
RAM on your machine. It must be of type swap.
Creation of the proper amount of swap space varies depending on a number of factors
including the following (in descending order of importance):
So, if:
If M < 2
S = M *2
Else
S=M+2
Using this formula, a system with 2 GB of physical RAM would have 4 GB of swap, while
one with 3 GB of physical RAM would have 5 GB of swap. Creating a large swap space
partition can be especially helpful if you plan to upgrade your RAM at a later time.
For systems with really large amounts of RAM (more than 32 GB) you can likely get away
with a smaller swap partition (around 1x, or less, of physical RAM).
A /boot/ partition (100 MB) — the partition mounted on /boot/ contains the operating
system kernel (which allows your system to boot Red Hat Enterprise Linux), along with
files used during the bootstrap process. Due to limitations, creating a native ext3 partition
to hold these files is required. For most users, a 100 MB boot partition is sufficient.
A root partition (3.0 GB - 5.0 GB) — this is where "/" (the root directory) is located. In this
setup, all files (except those stored in /boot) are on the root partition.
A 3.0 GB partition allows you to install a minimal installation, while a 5.0 GB root partition
lets you perform a full installation, choosing all package groups.
[Nov 14, 2008] Cool Solutions Manually Partitioning Your Hard Drive with
fdisk
20 Jul 2007 | Novell.com
Creating partitions via the command line interface is simple and quick, also having the kernel
acknowledge the partition table has been modified and having the partition scheme take effect without
having to reboot your workstation/server and without having to use the parted utility.
The first step to this guide is to see what hard drives are available and what hard drive you would like to
partition. If you have multiple hard drives in your machine, fdisk will report them to you as shown in Figure
1. There are two hard drives shown in Figure 1 "sda" and "sdb".
The fdisk command with the -l qualifier ("fdisk -l") will display the current partition tables along with the
hard drives that are attached to your workstation/server as shown in Figure 1.
linux-1reo:~ # fdisk -l
Once you have determined which hard drive you want to partition you can issue the fdisk command
followed by the hard drive ("fdisk /dev/sda"), in this article we will use the first hard drive (sda).
There is nothing wrong with that, but this is larger than 1024,
Once fdisk has been executed your command prompt will change to "Command (m for help):" and you
are ready to examine and partition your hard drive. The commands that are supported by fdisk can be
displayed by pressing the "m" character followed by the return key. The commands that we will be using
are "p" for printing the partition table, "n" for creating a new partition and "w" for saving the changes and
exiting.
The output shown in Figure 3 shows that we have 1809 cylinders available (9729 ? 7920 = 1809) and
with this we can use the calculation (1809 * 16065 * 512 = 14879531520 Bytes) which is roughly about 14
gigabytes. (The 16065 and 512 were taken from the "Units =" statement and may differ on you're system,
so you may be require to substitute them if necessary).
Once the partition has been created, using the "p" character we can display our new partition table which
will show the newly created partition, as shown in Figure 5.
Syncing disks.
Figure 6: Writing the new partition table to disk.
linux-1reo:~ # partprobe
Figure 7: Creation of a new mount point and a re-read of the partition table.
Now that a new mount point has been created and the partition table has been re-read by the kernel you
can now format the partition and place a file system of your choice on it. (ext2, ext3, ResierFS etc) In our
example we have chosen the ResierFS file system as shown in Figure 8.
A pair of credits:
sponsors it.
Blocksize: 4096
UUID: e20e2dc1-7277-4ab1-930c-038e54548540
Continue (y/n):y
Syncing..ok
linux-1reo:~ #
Once the partition has been formatted with the file system of your choice you can mount and use you're
newly created partition, Figure 9 shows the newly created partition being mounted.
Final thoughts
Once you have mounted your newly created and formatted partition you can store your files on the
partition without having any problems, you may also add your new partition to the "/etc/fstab" file so that
the partition will be mounted after every reboot.
Tested on:
SUSE Linux Enterprise Desktop 10
SUSE Linux Enterprise Server 10
/dev/dm-0 - LinuxQuestions.org
fdisk -l output in case you are using LVM contains many messages like
When the programs fdisk and sfdisk are run with the option -l and no argument, e.g.
# /sbin/fdisk -l
they look for all devices that can have cylinders, heads, sectors, etc.
If they find such a device, they output that information to standard output and they output the partition
table to standard output. If there is no partition table, they have an error message (also standard output).
One can see this by piping to 'less', e.g.
# /sbin/fdisk -l | less
I know if you startup the partitioner it gives you a warning but as long as do not change any think every is
oke
If according to the partitioner sdb is unused then you can do every think with it for instance to create a
second primary partition for a second OS If you put GRUB of the second OS in the second primary
partition Suse is still there and must it be possible to change suse boot loader in that way that she also
load the second OS
I have heard of folks playing games to get Linux to boot off a FAT filesystem. But you really don't want to
start off playing with that. So, you are going to need at least one partition. Probably two. Possibly more.
The partitioning of your drive can and should be done during the installation of Linux. However, if you
don't currently have any unpartitioned disk space, or if you don't have any disk partitions that you want to
wipe out and dedicate to linux, then you have a problem.
There are tools that will allow you to shrink your current (most likely Windows) partitions. I've never used
them. If you do use them, be sure to back up your system thoroughly first. (And double-check [test] your
backups before you begin!)
Alternatively, you can add another IDE hard drive for $125-$300. If you add another harddrive, be careful.
In Windows, if you add a new Windows partition after running your system for a while, you tend to get
hosed badly. Your drive letters get renumbered. Your registry no longer contains accurate data. In plain
and simple terms: You can find yourself up mister creek without mister paddle.
Linux, in contrast, won't really give a damn. In part because Linux, like other flavors of Unix, doesn't have
drive letters. Instead there is one master partition--the root partition which is known as "/". Additional
partitions can be mounted as subdirectories inside the root partition. So /tmp, /home, and/or /usr could
be separate partitions in Linux--the equivalent of D:, E:, or F: in Windows. But there is no requirement
that you have more than that one master root partition (plus swap--we'll get to swap in a minute). And with
this arrangement, it's quite trivial to add new partitions to a Linux system later on as your needs change.
If I may digress here for a moment: A few months ago I added a new hard drive to my dual-boot
(Win95/Linux) home box. Under Linux I partitioned the drive (/sbin/fdisk), formatted the partitions
(/sbin/mke2fs), added them to the /etc/fstab file so they'd automount the next time I rebooted, mounted
the partitions (/bin/mount), and I was done. Windows, on the other hand, decided that there had to be a
Windows partition somewhere in my newly created extended partition. And Windows tried, desperately, to
find that nonexistent Windows partition. Eventually it would time out and conclude that there was a zero-
length windows partition (drive) on my new extended partition. But that wouldn't stop it from trying to find
that nonexistent partition again a few seconds later. It rendered Windows unusable until I figured it out
and created a DOS FAT partition inside my new extended partition. A classic example of plug-and-pray!
So even though you may not be adding Windows partitions, Windows can still get upset with you.
Microsoft just does not play nicely with the other children.
Anyway, back to partitions. Red Hat gives all sorts of interesting advice regarding partitions in their
manual. See the Red Hat Linux 5.2 installation guide.
My two cents on this is that, if you are playing around in a non-professional environment on a PC-based
(Intel/i386) system, allocate a single 1-gig partition and put everything (excluding swap) on it. Even if you
are working in a professional environment, you may still want to consider doing something similar
depending upon your circumstances.
The only advantage to splitting up your directory structure across multiple partitions is that, if one partition
gets filled up, the rest of the system can keep going. (Specifically, log files and such can still be written to
the unfilled partitions.)
Now, if you've got users who are really obnoxious. Let's say they fill up /tmp or /usr/tmp with large files,
or they like to fill up their home directories in the same fashion. Then using multiple partitions can become
really useful. But with Linux, it's easy enough to add more partitions later, so why make things more
difficult when you're first starting out?
In a related vein: don't feel obliged to use up all your disk space at once. Who knows, next week you
might decide that you'd really rather not share a partition with Joe Sixchip who, for some strange reason,
seems to have a rather large collection of gifs of questionable morality.
Or you might decide that you'd like a second Linux installation containing older (or newer) software that's
independent of your work system. Perhaps you will join the experimental ranks. Or perhaps you have
some legacy code that wants an older version of libc.
On the other hand, consider that repartitioning a drive is a hazardous operation. So be sure to back it up
before repartitioning. Alternatively, I commonly partition my drive up in 1 or 2 gig chunks. But I don't use
those partitions until I need them. Which gives me some space to play around with.
Also, try not to create partitions that are substantially larger than your backup media. It can be done. And
there are a lot of people doing it. But doing so just tends to make life that much more unpleasant when
you're first starting out. (You would eventually need to spread your backups across multiple tapes.)
Partition Constraints: I have only used IDE, because they're cheap. SCSI is also supported. Linux won't
care if your partitions are primary partitions or inside an extended partition (AKA: logical drives).
However, if you are using LILO, the /boot directory needs to be located on the first 2 IDE drives (if you
have only IDE), on the first 2 SCSI drives (ID-0 / ID-1) (if you have only SCSI), or on the first IDE or first
SCSI (ID-0) (if you have IDE & SCSI). See the Red Hat manual for further reference.
Also, if you are using LILO, /boot must be located below cylinder 1023 of your hard disk. If you have only
one partition, that entire partition should be located below cylinder 1023. One common trick to overcome
this limitation is to create a separate /boot partition. If you do this, make it at least a couple of megs. (You
want to leave a little extra room in /boot so you can recompile the kernel and still keep an old kernel or
two lying around.)
LILO, for those who are unfamiliar with it, is the LInux LOader. It lives outside the operating system. And it
is commonly used as a means of starting Linux at boot time. (It can also be used to start Windows, which
is convenient for dual-boot systems.)
Swap: it is possible, except on very small systems, to use a swap file. I do not recommend swap files.
Swap files tend to have slower access times than swap partitions.
You can have more than one swap partition. Red Hat 5.2 uses the older, 2.0.36 kernel. As such, space in
swap partitions above 128 megabytes will not be used. Thus leading folks to utilize multiple swap
partitions. I believe that this limitation has been removed in the newer 2.2.x kernels that Red Hat 6.x uses.
How much swap? I usually figure about twice my RAM. My reasoning is that if I use more than twice my
RAM in swap, my Linux box will be thrashing (spending most of its time swapping) far too hard to make it
worth my while. Of course, if you're running legacy code that has a core leak (i.e., that leaks memory),
extra swap may buy you some more running time.
On the other hand, if I'm working with a really tiny bit of RAM (less than 16 MB), I'll generally figure 32
Megabytes as a minimum amount of swap.
Recommended Links
RHEL 5 nstallation Guide
Reference
Partitioning with fdisk
Partitioning with fdisk redhat.com
fdisk - Wikipedia, the free encyclopedia
Fdisk Tutorial Removing and Creating Partitions Windows installation Tech-
Recipes
Copyright © 1996-2012 by Dr. Nikolai Bezroukov. www.softpanorama.org and its softpanorama.info and sofpanorama.net
mirrors were created as a service to the UN Sustainable Development Networking Programme (SDNP) in the author free
time. This document is an industrial compilation designed and created exclusively for educational use and is
distributed under the Softpanorama Content License. Site uses AdSense so you need to be aware of Google privacy policy.
Original materials copyright belong to respective owners. Quotes are made for educational purposes only in
compliance with the fair use doctrine. This is a Spartan WHYFF (We Help You For Free) site written by people
for whom English is not a native language. Grammar and spelling errors should be expected. The site contain
some broken links as it develops like a living tree...
Disclaimer:
The statements, views and opinions presented on this web page are those of the author and are not endorsed by, nor do
they necessarily reflect, the opinions of the author present and former employers, SDNP or any other organization the
author may be associated with.
We do not warrant the correctness of the information provided or its fitness for any purpose
Last modified: November 04, 2012