1
<?xml version="1.0" encoding="UTF-8"?>
2
<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" "http://docbook.org/xml/4.2/docbookx.dtd">
4
<title>Ubuntu Desktop</title>
6
<title>Partitioning and Booting</title>
7
<para><emphasis role="strong">Objectives</emphasis></para>
8
<para>In this lesson, you will learn:
10
<listitem><para>The benefits of partitioning (having more than one OS on your computer)</para></listitem>
11
<listitem><para>How to create partitions.</para></listitem>
12
<listitem><para>Configure start-up options.</para></listitem>
16
<title>Advantages of Partitioning</title>
17
<para>Hard disk partitioning refers to the creation of multiple logical divisions,
18
called partitions, within one physical hard disk. You can use the partitions on a hard disk
19
as multiple, isolated hard drives. Partitioning is especially useful if you want to run multiple file systems on a
20
computer. For example, you may want to reserve one partition for Microsoft Windows
21
and run Ubuntu on another. You can then have a 'dual-boot' mechanism where you can choose which operating
22
system you would like to run when loading your computer.</para>
23
<para>Ubuntu allows you to have a single partition containing the entire operating system, applications and your personal
24
files. However, many users feel that a separate swap partition, which is scratch
25
space for an operating system, is required. A swap partition allows the system to
26
use disk storage as virtual memory. By placing a swap on a separate partition, Linux
27
can make much more efficient use of the swap space. Consequently, most users decide
28
to use multiple partitions with Ubuntu.</para>
29
<para>Additional advantages of partitioning include:
31
<listitem><para>Minimising data loss: If one of the file systems on
32
your computer is corrupted accidently, more often than not only one
33
partition is affected. As a result, you don't have to replace the data of
34
the entire hard disk, you will only need to replace the data in the
35
affected portion of the hard drive.</para>
37
<listitem><para>Enhancing security: You can provide enhanced security to
38
your system by creating a separate root partition that contains the most
39
essential components of the operating system. Doing this allows you to boot
40
into your Ubuntu to fix the system even when all other partitions are
43
<listitem><para>Enhancing performance: Multiple partitioning helps reduce
44
disk head travel(???), resulting in improved performance.</para>
48
<screen><para><emphasis role="strong">Caution:</emphasis></para>
49
<para>You may run out of hard drive space in your home partition due to the
50
sub-division of the drive into fixed-size partitions. This may occur even if
51
the other partitions have plenty of usable space. A good implementation of
52
partitioning requires you to predict how much space each partition needs.</para></screen>
53
<para>For new users, home users and other single-user set-ups, a single root
54
(/) partition with a swap partition would be the easiest and the most convenient
55
to create and use. However, for multi-user systems or computers with lots of disk
56
space, it is best to have the /home, /tmp, /usr and /var directories as individual
57
partitions separate from the root (/) partition.</para>
58
<para>However, before partitioning your hard drive, you should consider the
59
following regarding directories and partitions:
61
<listitem><para>root: Also called the slash directory, it is the highest
62
directory of the directory tree. When creating the root partition, you
63
need to ensure that the root should contain the /etc, /bin, /sbin, /lib
64
and /dev directories; else, you will not be able to boot-up the system.
65
You also need to ensure that the root partition is allocated at least
66
150-250 MB of disk space.</para></listitem>
67
<listitem><para>/home: This directory contains all user-specific files and data.
68
On a multi-user system, every user will store personal data in a subdirectory
69
of this directory. The size of this directory would depend on the number of users
70
using the system and the files they store in this directory. Ideally, you should
71
plan the disk space for this partition based on your planned usage. In general,
72
about 100-MB disk space can be allocated for each user. However, you may need to
73
reserve a lot more space if you are planning to save a lot of multi-media files
74
in your home directory.</para></listitem>
76
<screen><para><emphasis role="strong">Nice to Know:</emphasis></para>
77
<para>It is good practice to have /home on a separate partition because
78
it allows for a smoother transition from one distribution to another.</para></screen>
80
<listitem><para>/var: This directory contains variable data, such as news
81
articles, e-mails, Web sites, databases and the packaging system cache. The
82
size of this directory also depends on system usage. Most probably, the size
83
of this directory would be dictated by your usage of the Ubuntu package
84
management utilities. If you plan to install all the packages that Ubuntu
85
offers, you need to allocate 2 to 3 GB of space for the /var directory. However,
86
if you want to save hard disk space and do not plan any major software updates,
87
you can get by with as little as 30- or 40-MB disk space for the /var
88
directory.</para></listitem>
89
<listitem><para>/tmp: This directory contains temporary data created by programs.
90
Some applications, including archive manipulators, CD/DVD authoring tools and
91
multi-media software also use this directory to temporarily store image files.
92
Based on your usage of these applications, you need to plan space allocation
93
for this directory.</para></listitem>
94
<listitem><para>/usr: This directory contains all user programs (binaries),
95
their documentation and supporting libraries. This directory tends to use the
96
maximum space on the hard disk. Therefore, you should provide at least 500-MB
97
disk space for this directory. But, you need to increase this space depending
98
on the number and types of software packages you plan to install. Based on your
99
planned usage and the available disk space, you may allocate 1.5 to 6 GB of disk
100
space for this directory.</para></listitem>
102
<screen><para><emphasis role="strong">Nice to Know:</emphasis></para>
103
<para>The /usr partition is sometimes referred to as User System
104
Resources and not user as was originally intended.</para></screen>
106
<para>Next, you will learn how to create new partitions on your computer's hard
107
drive and access other operating systems and partitions from Ubuntu.</para>
110
<title>Creating a Partition</title>
111
<para>As mentioned earlier, multiple partitions are very useful especially in cases
112
where a partition is corrupted, as it enables you to boot into GNU/Linux to fix the system,
113
without having to reinstall the system. To so this, a root partitionis required. This partition should contain
114
the essential components of the system.</para>
115
<screen><para><emphasis role="strong">Caution:</emphasis></para>
116
<para>The hard disk drive that you are formatting should not contain any
117
data. If you have already formatted the drive and it contains data, skip
118
the partitioning step and move to the next step - mounting.</para></screen>
119
<para>If the hard disk drive that you want to format is blank and unformatted,
120
you can use either of the following tools to partition it:
122
<listitem><para>GNOME Partition Editor (GParted): GParted is the GNOME
123
Partition Editor application. GParted is useful for creating space for
124
new operating systems, reorganising disk usage, copying data residing
125
on hard disks and mirroring one partition with another (disk
126
imaging).</para></listitem>
127
<listitem><para>Command Line: Command Line Interface (CLI) is a method
128
of interacting with an operating system by using a command-line interpreter.
129
The command line is faster and more powerful than GParted. When navigating
130
through the file system, you can use the command line to jump from one
131
directory to another in a split second. Use the command-line interface if
132
you are comfortable using the Terminal.</para></listitem>
135
<para>If you want to create a partition using GParted, you need to first install
136
GParted by using <emphasis role="strong">Add/Remove Applications</emphasis> or
137
<emphasis role="strong">Synaptic Package Manager</emphasis>.</para>
139
<title>Installing GParted by Using Synaptic Package Manager</title>
140
<para>To install GParted by using Synaptic Package Manager:
141
<orderedlist numeration="arabic">
142
<listitem><para>On the <emphasis role="strong">System</emphasis> menu,
143
point to <emphasis role="strong">Administration</emphasis> and then click
144
<emphasis role="strong">Synaptic Package Manager</emphasis>. The
145
<emphasis role="strong">Synaptic Package Manager</emphasis> window
149
<imagedata fileref="./images/Chapter11_Image_001.png" format="PNG"/>
153
<listitem><para>When the <emphasis role="strong">Synaptic Package
154
Manager</emphasis> window opens for the first time, it displays a
155
list of all the software packages available in the Ubuntu software
156
repositories. The left pane lists the various software categories.
157
You can select a specific category to view the available software
158
packages listed in that category. Alternatively, you can use the
159
<emphasis role="strong">Search</emphasis> functionality provided in
160
the <emphasis role="strong">Synaptic Package Manager</emphasis> to
161
locate specific software in the list.</para>
162
<para>Click the <emphasis role="strong">Search</emphasis> button to
163
search the package you want to install. The
164
<emphasis role="strong">Find</emphasis> dialogue box appears.</para>
165
<para><emphasis role="strong"><emphasis role="italic">Instructor Notes:</emphasis></emphasis></para>
166
<para><emphasis role="italic">If students want to know more about
167
software repositories, you can give them the following
168
information:</emphasis></para>
169
<para><emphasis role="italic">A software repository is a location
170
from where users can download and install packages over the Internet.
171
The Ubuntu software repository contains thousands of packages that are
172
freely available for installation over the Internet. It is easy to
173
install these packages because they are specially built for
174
Ubuntu.</emphasis></para>
177
<imagedata fileref="./images/Chapter11_Image_002.png" format="PNG"/>
181
<listitem><para>In the <emphasis role="strong">Search</emphasis> field
182
of the <emphasis role="strong">Find</emphasis> dialogue box, type the
183
name of the package, <emphasis role="strong">Gnome Partition Editor</emphasis>,
184
and click the <emphasis role="strong">Search</emphasis> button. The
185
package, gparted, is now displayed in the right pane of the
186
<emphasis role="strong">Synaptic Package Manager</emphasis> window.</para>
189
<imagedata fileref="./images/Chapter11_Image_003.png" format="PNG"/>
193
<listitem><para>Right-click the package name to select an action that
194
you want to perform on it. Notice that various options are available
195
to perform a number of actions on the selected package. If the selected
196
package is not installed currently, you can mark it for installation.
197
Inversely, if the selected package is already marked for installation,
198
you can unmark it to clear the selection. Similarly, if the package is
199
already installed, you may select <emphasis role="strong">Upgrade</emphasis>
200
to upgrade the package and <emphasis role="strong">Mark for Removal</emphasis>
201
or <emphasis role="strong">Mark for Complete Removal</emphasis> to delete
202
the package from your computer.</para>
203
<para>To install the package, select the <emphasis role="strong">Mark for
204
Installation</emphasis> check box. This displays the
205
<emphasis role="strong">Mark additional required changes?</emphasis>
209
<imagedata fileref="./images/Chapter11_Image_004.png" format="PNG"/>
213
<listitem><para>The <emphasis role="strong">Mark additional required
214
changes?</emphasis> dialogue box displays a list of other associated
215
software programs that need to be installed to install the selected
216
package. Click the <emphasis role="strong">Mark</emphasis> button to
220
<imagedata fileref="./images/Chapter11_Image_005.png" format="PNG"/>
224
<listitem><para>The gparted package is now selected for installation.
225
To continue with the installation, click <emphasis role="strong">Apply</emphasis>.
226
This displays the <emphasis role="strong">Summary</emphasis> dialogue
230
<imagedata fileref="./images/Chapter11_Image_006.png" format="PNG"/>
234
<listitem><para>The <emphasis role="strong">Summary</emphasis> dialogue
235
box prompts you to perform a final check before implementing the marked
236
changes. Click the <emphasis role="strong">Apply</emphasis> button to
237
apply the marked changes. The <emphasis role="strong">Downloading package
238
files</emphasis> window opens.</para>
241
<imagedata fileref="./images/Chapter11_Image_007.png" format="PNG"/>
245
<listitem><para>Wait for all the required files to download.
246
After all the required files in the package are downloaded,
247
the <emphasis role="strong">Changes applied</emphasis> dialogue
251
<imagedata fileref="./images/Chapter11_Image_008.png" format="PNG"/>
255
<listitem><para>The <emphasis role="strong">Changes applied</emphasis>
256
dialogue box notifies you that all the requested changes have been
257
applied. Click <emphasis role="strong">Close</emphasis> to exit the
261
<imagedata fileref="./images/Chapter11_Image_009.png" format="PNG"/>
265
<listitem><para>The Gnome partition editor is installed on your computer.
266
You can now partition the hard disk drive.</para>
269
<imagedata fileref="./images/Chapter11_Image_010.png" format="PNG"/>
277
<title>Partitioning Using Gparted</title>
278
<para>To partition the hard drive by using Gparted:
279
<orderedlist numeration="arabic">
280
<listitem><para>On the <emphasis role="strong">System</emphasis> menu,
281
point to <emphasis role="strong">Administration</emphasis> and then click
282
<emphasis role="strong">GNOME Partition Editor</emphasis>. The
283
<emphasis role="strong">GParted</emphasis> window opens.</para>
286
<imagedata fileref="./images/Chapter11_Image_011.png" format="PNG"/>
290
<listitem><para>In the top-right corner of the <emphasis role="strong">GParted</emphasis>
291
window is the drive drop-down box. You can use this box to select the hard
292
drive that you need to partition by specifying the logical name you noted
293
earlier. The Gparted window refreshes and shows you a representation of
294
the selected drive.</para>
295
<para>If the existing partitions on the drive have not yet been used, a
296
white bar would run across the window. However, if the existing
297
partitions contain some data, the data will be represented by a pale
299
<para><emphasis role="strong"><emphasis role="italic">Instructor Notes:</emphasis></emphasis></para>
300
<para><emphasis role="italic">Explain how to read the specifications of
301
the current partitions and file systems.</emphasis></para>
304
<imagedata fileref="./images/Chapter11_Image_012.png" format="PNG"/>
308
<listitem><para>You can either resize an existing partition or create a
309
new partition in the unallocated space of the hard drive. Before resizing
310
an existing partition, you must make sure that you unmount it by
311
right-clicking the partition and then selecting <emphasis role="strong">Unmount</emphasis>.
312
Remember that you cannot resize a partition to be smaller than the yellow
313
area, which represents the data on the partition.</para>
314
<para>To create a new partition in the unallocated drive space,
315
right-click the area and select <emphasis role="strong">New</emphasis>
316
on the short-cut menu. The <emphasis role="strong">Create new
317
Partition</emphasis> dialogue box appears.</para>
320
<imagedata fileref="./images/Chapter11_Image_012.png" format="PNG"/>
324
<listitem><para>The <emphasis role="strong">Create new Partition</emphasis>
325
dialogue box allows you to select specifications for the new partition.
326
Apart from defining the size of the new partition, you can also select
327
the partition type, whether primary or logical, for the new partition.
328
In addition, you can even define the file system to be used on the new
329
partition. By default, Ubuntu uses the ext3 partitions. However, if you
330
want the new drive to be readable by both Windows and Ubuntu without
331
installing anything extra, you can format it as Fat 32.</para>
332
<screen><para><emphasis role="strong">Note:</emphasis></para>
333
<para>If you are creating a partition on a new hard drive, select
334
Primary Partition. A SCSI or S-ATA hard disk can have a maximum of
335
4 primary partitions and 11 logical partitions while an integrated
336
development environment (IDE) hard drive can have up to 63 partitions
337
overall. The primary partition used to house the logical partitions
338
is called an extended partition. Unlike primary partitions, logical
339
partitions must be contiguous.</para></screen>
342
<imagedata fileref="./images/Chapter11_Image_013.png" format="PNG"/>
346
<listitem><para>In the <emphasis role="strong">New Size (MiB)</emphasis>
347
field, specify the size of the partition by using the up or down arrow
348
key. You can also define the size by dragging the black bold arrows on
349
the top white bar.</para></listitem>
350
<listitem><para>Select Primary, Logical or Extended partition from the
351
<emphasis role="strong">Create as</emphasis> drop-down list.</para>
353
<listitem><para>Next, specify the file system by selecting from the
354
<emphasis role="strong">Filesystem</emphasis> drop-down list.</para>
356
<listitem><para>Click the <emphasis role="strong">Add</emphasis> button
357
to complete the partition. The white bar updates to show a new partition
358
on the disk.</para></listitem>
359
<listitem><para>You can create multiple partitions at this stage by
360
following the above-mentioned procedure and then clicking
361
<emphasis role="strong">Apply</emphasis> to add them to the hard drive.
362
The <emphasis role="strong">Apply operations to harddisk</emphasis>
363
dialogue box appears.</para>
366
<imagedata fileref="./images/Chapter11_Image_014.png" format="PNG"/>
370
<listitem><para>The <emphasis role="strong">Apply operations to harddisk
371
</emphasis> dialogue box recommends that you back up data before
372
performing the changes and seeks your final confirmation before applying
373
the changes to the hard disk. Click the <emphasis role="strong">Apply
374
</emphasis> button to partition and format the hard disk according to
375
your specifications.</para>
378
<imagedata fileref="./images/Chapter11_Image_015.png" format="PNG"/>
382
<listitem><para>The system starts applying the changes to the hard disk.
383
The duration of the operation will depend on the size of the new
384
partition. When the operation is still running, you can click the
385
<emphasis role="strong">Details</emphasis> button to view more information
386
about where and how the changes are being made.</para>
389
<imagedata fileref="./images/Chapter11_Image_016.png" format="PNG"/>
393
<listitem><para>After you receive a message that all the specified
394
operations have been successfully completed, you can safely close
395
the window by clicking the <emphasis role="strong">Close</emphasis>
396
button. However, if something goes wrong and the process does not
397
complete successfully, you can save the process output for future
398
reference by clicking the <emphasis role="strong">Save Details</emphasis>
399
button.</para></listitem>
400
<listitem><para>The newly created partition is now visible in the
401
<emphasis role="strong">GParted</emphasis> window. You will also
402
notice that your system automounts the newly created partition.</para>
403
<para>Mounting refers to the process of attaching the newly created
404
partition or drive to an existing directory to make it accessible.
405
The directory where the new partition is attached is called the mount
406
point. After the partition is mounted, you can access the files on
407
that partition by accessing the mount point for the new partition.
408
Early Linux distributions did not allow the auto-mounting of new partitions
409
or drives. However, Ubuntu 7.04 and above allow you to easily access
410
the new partitions by auto-mounting the partitions. When you create a new
411
partition, the new partition opens as a separate window and the
412
partition appears as a disk icon on the desktop.</para>
415
<imagedata fileref="./images/Chapter11_Image_017.png" format="PNG"/>
419
<listitem><para>When you no longer want to access the new partitions,
420
you can unmount them by right-clicking the <emphasis role="strong">disk</emphasis>
421
icon on the desktop and selecting the <emphasis role="strong">Unmount
422
Volume</emphasis> option from the short-cut menu.</para>
425
<imagedata fileref="./images/Chapter11_Image_018.png" format="PNG"/>
429
<listitem><para>If you want to stop Ubuntu from auto-mounting all
430
the partitions when you boot into your operating system, you can do
431
so by changing the default configuration settings. To access the
432
configuration settings for the partitions, on the System menu, point
433
to <emphasis role="strong">Preferences</emphasis> and click
434
<emphasis role="strong">Removable Drives and</emphasis>
435
<emphasis role="strong">Media</emphasis>. The
436
<emphasis role="strong">Removable Drives and Media Preferences</emphasis>
437
dialogue box opens.</para>
440
<imagedata fileref="./images/Chapter11_Image_019.png" format="PNG"/>
444
<listitem><para>To prevent Ubuntu from auto-mounting all the drives,
445
clear the first three check boxes on the <emphasis role="strong">Removable
446
Drives and Media Preferences</emphasis> dialogue box and click
447
<emphasis role="strong">Close</emphasis>.</para>
450
<imagedata fileref="./images/Chapter11_Image_020.png" format="PNG"/>
454
<listitem><para>After making the required changes in the
455
<emphasis role="strong">Removable Drives and Media Preferences</emphasis>
456
dialogue box, you will notice that Ubuntu does not automount all the
457
partitions and drives at boot-up.</para>
463
<title>Partitioning Using the Command Line</title>
464
<para>As you already know, you can divide a hard disk into multiple logical disks
465
called partitions. The description of these partitions is stored in a partition
466
table, which is found on sector 0 of the disk.</para>
467
<para><emphasis role="strong"><emphasis role="italic">Instructor Notes:</emphasis></emphasis></para>
468
<para><emphasis role="italic">Depending on the profile of the learners, you may
469
need to explain the concept of disk sectors. You can ask the learners to check
470
the following URL to know more about disk sectors:</emphasis></para>
471
<para><emphasis role="italic"><ulink url="http://en.wikipedia.org/wiki/Disk_sector">http://en.wikipedia.org/wiki/Disk_sector</ulink></emphasis></para>
472
<para>To create a partition using the command line, you need to use the fdisk
473
command. fdisk is a menu-driven program for the creation and manipulation of
474
partition tables. The fdisk program needs the hard disk name to manipulate
475
partition tables. Depending on the disk interface type, a hard disk may
476
use one of the following names:
478
<listitem><para>IDE disks: /dev/hd[a-h]</para></listitem>
479
<listitem><para>SCSI disk: /dev/sd[a-p]</para></listitem>
480
<listitem><para>ESDI disks: /dev/ed[a-d]</para></listitem>
481
<listitem><para>XT disks: /dev/xd[ab]</para></listitem>
484
<screen><para><emphasis role="strong">Note:</emphasis></para>
485
<para>Visit <ulink url="http://www.pcguide.com/ref/hdd/perf/perf/ext/if-c.html">http://www.pcguide.com/ref/hdd/perf/perf/ext/if-c.html</ulink>
486
to know more about disk interface types.</para></screen>
487
<para>You need to use the Terminal to use the fdisk command. To access the
489
<orderedlist numeration="arabic">
490
<listitem><para>On the <emphasis role="strong">Applications</emphasis>
491
menu, point to <emphasis role="strong">Accessories</emphasis> and then
492
click <emphasis role="strong">Terminal</emphasis>. The Terminal window
496
<imagedata fileref="./images/Chapter11_Image_021.png" format="PNG"/>
500
<listitem><para>The sudo command allows authorised users to run certain
501
programs as root. Root is equivalent to an Administrator of Windows.
502
This means that to run commands requiring root privileges, you need to
503
pre-pend sudo to the commands.</para>
504
<para>Before partitioning a hard drive using a command line, you need to
505
determine the number of partitions that you need to create and the path
506
that your system has assigned to the hard drive.</para>
507
<para>To determine the path, type the following command in the
509
<screen><para>$ sudo lshw -C disk</para></screen>
512
<imagedata fileref="./images/Chapter11_Image_023.png" format="PNG"/>
515
<screen><para><emphasis role="strong">Note:</emphasis></para>
516
<para>When you use the sudo command for the first time in a session,
517
it asks you for your password. You need to provide your user account
518
password to proceed.</para>
519
<para>To know more about a root user and the sudo command, visit:
520
<ulink url="https://help.Ubuntu.com/6.06/Ubuntu/desktopguide/C/linux-basics.html#root-and-sudo">https://help.Ubuntu.com/6.06/Ubuntu/desktopguide/C/linux-basics.html#root-and-sudo</ulink></para></screen>
521
<para><emphasis role="strong"><emphasis role="italic">Instructor Notes:</emphasis></emphasis></para>
522
<para><emphasis role="italic">You can also use the following command to
523
determine the path:</emphasis></para>
524
<screen><para>$ sudo fdisk -l</para></screen>
526
<listitem><para>The above command should produce an output similar to
530
<imagedata fileref="./images/Chapter11_Image_024.png" format="PNG"/>
533
<para>Make a note of the logical name for future reference.</para>
535
<listitem><para>To initiate partitioning, in the Terminal Window,
536
run the fdisk command:</para>
537
<screen><para>$ sudo fdisk /dev/sda</para></screen>
538
<para>Replace /dev/sda with the logical name of your hard drive.</para>
541
<imagedata fileref="./images/Chapter11_Image_025.png" format="PNG"/>
544
<screen><para><emphasis role="strong">Caution:</emphasis></para>
545
<para>Proceed with caution while performing fdisk steps. If you
546
follow the fdisk steps on a hard disk that is not empty, all the
547
data may get damaged. It is therefore, recommended that you back
548
up the data before following these steps.</para></screen>
550
<listitem><para>The output of the fdisk command shows that there are
551
9,726 cylinders for the disk. However, an older Basic Input Output
552
System (BIOS) can access only the first 1,024 cylinders of the disk
553
to boot-up the system. Therefore, users that have computers with large
554
disks often create another partition, just a few MB large, typically
555
mounted on boot. This partition stores the kernel image and a few
556
auxiliary files needed at boot time. Therefore, it is important to
557
make sure that these files are accessible to the BIOS.</para>
558
<screen><para><emphasis role="strong">Note:</emphasis></para>
559
<para>To know more about cylinders, heads and
560
tracks, visit the following sites:
561
<ulink url="http://en.wikipedia.org/wiki/Cylinder-head-sector">http://en.wikipedia.org/wiki/Cylinder-head-sector</ulink>
562
<ulink url="http://www.pcguide.com/ref/hdd/geom/tracksDifference-c.html">http://www.pcguide.com/ref/hdd/geom/tracksDifference-c.html</ulink></para></screen>
563
<para><emphasis role="strong"><emphasis role="italic">Instructor Notes:</emphasis></emphasis></para>
564
<para><emphasis role="italic">You can also use the following
565
commands:</emphasis></para>
566
<screen><para>$ sudo sfdisk /dev/sda</para></screen>
567
<para><emphasis role="italic">When using the sfdisk command to
568
partition, the logical device should not be active.</emphasis></para>
569
<screen><para>$ sudo cfdisk /dev/sda</para></screen>
570
<para><emphasis role="italic">The cfdisk command provides
571
a curser interface.</emphasis></para>
572
<para>You can use the following commands for frequently performed tasks:</para>
575
<colspec colname="col1" align="left"/>
576
<colspec colname="col2" align="left"/>
579
<entry><para><emphasis role="strong">Command</emphasis></para>
581
<entry><para><emphasis role="strong">Command Action</emphasis>
585
<entry><para>d</para></entry>
586
<entry><para>Deletes a partition</para></entry>
589
<entry><para>l</para></entry>
590
<entry><para>Lists known partition types</para></entry>
593
<entry><para>n</para></entry>
594
<entry><para>Adds a new partition</para></entry>
597
<entry><para>p</para></entry>
598
<entry><para>Prints a partition table</para></entry>
601
<entry><para>q</para></entry>
602
<entry><para>Quits without saving changes</para></entry>
605
<entry><para>w</para></entry>
606
<entry><para>Writes a table to disk and exits</para></entry>
609
<entry><para>m</para></entry>
610
<entry><para>Help</para></entry>
616
<listitem><para>To add a new partition, type <emphasis role="strong">n</emphasis>
617
and press <emphasis role="strong">Enter</emphasis>.</para>
620
<imagedata fileref="./images/Chapter11_Image_026.png" format="PNG"/>
624
<listitem><para>Next, choose the partition type. Type
625
<emphasis role="strong">l</emphasis> for a logical partition
626
or p for a primary partition and press
627
<emphasis role="strong">ENTER</emphasis>.</para>
630
<imagedata fileref="./images/Chapter11_Image_027.png" format="PNG"/>
634
<listitem><para>Type <emphasis role="strong">p</emphasis> to print the
635
partition table. The output shows that a new partition has been
639
<imagedata fileref="./images/Chapter11_Image_028.png" format="PNG"/>
642
<para><emphasis role="strong"><emphasis role="italic">Instructor Notes:</emphasis></emphasis></para>
643
<para><emphasis role="italic">The new partition is assigned the Linux
644
file system type by default.</emphasis></para>
646
<listitem><para>Now that the partition is created, type
647
<emphasis role="strong">w</emphasis> to write the partition
648
table to the disk and press <emphasis role="strong">ENTER</emphasis>.</para>
651
<imagedata fileref="./images/Chapter11_Image_029.png" format="PNG"/>
655
<listitem><para>If all went well, you now have a partitioned hard drive
656
that is ready to be formatted. You will need to reboot your computer for
657
the changes to take effect.</para></listitem>
658
<listitem><para>If you want to delete a partition, type
659
<emphasis role="strong">d</emphasis> and press <emphasis role="strong">Enter</emphasis>.
660
Type the partition number that you want to delete and press
661
<emphasis role="strong">Enter</emphasis> again.</para>
664
<imagedata fileref="./images/Chapter11_Image_030.png" format="PNG"/>
668
<listitem><para>Type <emphasis role="strong">p</emphasis> to print the
669
partition table; you can check if partition <emphasis role="strong">5</emphasis>
670
has been deleted.</para></listitem>
671
<listitem><para>If you need further help while performing fdisk, type
672
<emphasis role="strong">m</emphasis> and press
673
<emphasis role="strong">ENTER</emphasis>.</para>
676
<imagedata fileref="./images/Chapter11_Image_031.png" format="PNG"/>
680
<listitem><para>The m command displays a list of all the commands that you
681
can use along with their resultant actions.</para>
682
<para>After writing the updated partition table to the disk, the kernel
683
needs to be notified on the change. You can use the partprobe command to
684
notify the kernel of the change; else, you will need to reboot the
685
system.</para></listitem>
688
<para><emphasis role="strong"><emphasis role="italic">Instructor Notes:</emphasis></emphasis></para>
689
<para><emphasis role="italic">To format the disk as an ext3 file system, which
690
is best for use with Ubuntu, type the following command:</emphasis></para>
691
<screen><para>$ sudo mke2fs -j /dev/hdd1</para></screen>
692
<para><emphasis role="italic">Substitute "/dev/hdd1" with your
693
own drive's path.</emphasis></para>
694
<screen><para><emphasis role="strong">Nice to Know:</emphasis></para>
695
<para>When formatting a drive, 5 percent of the total space of the drive
696
is reserved for the super-user (Root) so that the operating system can
697
still write to the disk even if it is full. However, for disks that only
698
contain data, this is not necessary.</para>
699
<para>You can adjust the percentage of reserved space by using the tune2fs
700
command, as shown below:</para></screen>
701
<screen><para>$ sudo tune2fs -m 1 /dev/hdd1</para></screen>
702
<screen><para>The above example reserves 1 percent of space. You can
703
change this percentage according to the requirement. Using this command
704
does not change the existing data on the drive. You can use this command
705
on a drive that contains data.</para></screen>
709
<title>Bootup Options</title>
710
<para>Booting up is a process through which the operating system is loaded into the
711
computer's main memory or random access memory (RAM). The boot-up process
712
starts when you turn on your computer. During this process, the BIOS takes control of
713
your computer and decides where to look for software on the computer and in which
714
order. Based on the BIOS settings of your computer, it is decided whether your
715
computer will first check the hard disk or a floppy disk, CD, DVD or flash memory to
716
start the booting-up process. In case you have multiple operating systems installed on
717
your computer, the BIOS configuration decides which operating system will be loaded
718
first at boot-up.</para>
719
<para>Only after all system files have been loaded into the main memory, is the
720
operating system given control of the computer. The operating system performs the
721
requested initial commands and then waits for the first interactive user input.</para>
722
<para>However, as a superuser or user with administrative privileges, it is possible
723
for you to change the boot-up configuration to define the computer's boot order,
724
change the default operating system to boot-up or make a system command run
725
automatically at boot-up.</para>
726
<para>One way to change or check your BIOS setting is to restart your computer, and
727
press a key to enter the setup function before it starts to load any operating system.
728
Generally, you can do this by pressing F1, F2, ESC or DELETE. Once you are inside the
729
BIOS setup, you can make the desired changes by following the instructions for using
730
the setup. However, you need to be very cautious when making any changes in the BIOS
731
settings because a wrong setting can prevent your computer from booting-up
733
<para>You can also perform these configuration changes by using a command line on your
734
computer's Terminal.</para>
736
<title>Running a System Command Automatically at Start-Up</title>
737
<para>At times, you may wish to add a custom command for the start-up process so
738
that your computer executes this command every time it boots up. To run a system
739
command automatically at start-up:
740
<orderedlist numeration="arabic">
741
<listitem><para>On the Terminal, type the following command to open the
742
rc.local file:</para>
743
<screen><para>$ sudo nano /etc/rc.local</para></screen>
746
<imagedata fileref="./images/Chapter11_Image_032.png" format="PNG"/>
749
<para>The rc.local file contains a script that is executed after all the
750
other initial scripts. You can insert your own initialisation scripts in
751
this file if you want some services to be executed automatically during
752
the start-up process.</para>
754
<listitem><para>The rc.local file opens in the Terminal window.
755
Type the command that you want to run at system start-up before
756
the line, exit 0.</para>
757
<screen><para>$ date > /home/oem/newbackup</para></screen>
760
<imagedata fileref="./images/Chapter11_Image_033.png" format="PNG"/>
764
<listitem><para>After you enter the command you want executed at system
765
start-up, press CTRL+X to save and exit the edited file.</para>
768
<imagedata fileref="./images/Chapter11_Image_034.png" format="PNG"/>
772
<listitem><para>When you reboot the system, the rc.local file executes.
773
If you want to display the output of the above command, type the
774
following command in the Terminal:</para>
775
<screen><para>$ cat newbackup</para></screen>
776
<para>The following image shows the output of the above command:</para>
779
<imagedata fileref="./images/Chapter11_Image_035.png" format="PNG"/>
787
<title>Changing the Default Operating System at Boot</title>
788
<para>When multiple operating systems are installed on a computer, this is
789
referred to as a multi-boot configuration. Typically, the operating system
790
that is listed on top in the configuration file is loaded on the computer.
791
To choose the operating system that starts when you turn on your computer,
792
edit the grub configuration file.
793
<orderedlist numeration="arabic">
794
<listitem><para>Back up the configuration file, and open it in a text
795
editor, as follows:</para>
797
<para>$ sudo cp /boot/grub/menu.lst /boot/grub/menu.lst_backup</para>
798
<para>$ sudo gedit /boot/grub/menu.lst</para></screen>
800
<listitem><para>Find the line written below to change the default sequence:</para>
803
<para>default 0</para>
804
<para>...</para></screen>
805
<para>Replace this line with the following line:</para>
807
<para>default X</para></screen>
808
<para>Replace X with a number based on the order in which your operating
809
systems appear in the configuration file. You should start counting from
810
0. For example, if you wish the default operating system to be the first
811
in the list, replace X with 0; and if you wish the default operating
812
system to be the second in the list, replace X with 1.</para>
814
<listitem><para>Point to saved and save default to reboot the last OS
815
chosen.</para></listitem>
820
<title>Configuring Start-Up Services</title>
821
<para>When Ubuntu starts up, many services are started for your convenience. Some
822
services are mandatory for Ubuntu to work properly on your computer. Others can
823
include services that you'll probably never need or want, either because you just
824
do not want them (for example, ntpdate, which sets your system time from a time
825
server) or you simply don't have the device (for example, the HP printing and
826
scanning system, which is of no use if you don't own a HP device).</para>
827
<para>Although these services are harmless, they increase your computer's start-up
828
time. By de-activating some of these services, you should get a slightly faster
829
start-up time.</para>
830
<screen><para><emphasis role="strong">Caution:</emphasis></para>
831
<para>Read the service information before you disable any service because
832
disabling some services may stop your system from booting-up or running
833
properly.</para></screen>
834
<para>To configure the start-up services, you need to have administrative
835
privileges. Then, perform the following steps:
836
<orderedlist numeration="arabic">
837
<listitem><para>On the <emphasis role="strong">System</emphasis> menu,
838
point to <emphasis role="strong">Administration</emphasis> and then
839
click <emphasis role="strong">Services</emphasis>.</para>
842
<imagedata fileref="./images/Chapter11_Image_036.png" format="PNG"/>
846
<listitem><para>Type your administrative password. The
847
<emphasis role="strong">Services settings</emphasis> window
848
opens.</para></listitem>
849
<listitem><para>Select the services you want running by selecting or
850
clearing the respective check boxes and click <emphasis role="strong">OK</emphasis>.
854
<imagedata fileref="./images/Chapter11_Image_037.png" format="PNG"/>
860
<para><emphasis role="strong"><emphasis role="italic">Instructor Notes:</emphasis></emphasis></para>
861
<para><emphasis role="italic">If you want greater control over the boot-up
862
services, install Boot-up Manager (bum). You can install bum from the Universe
863
repository. You need to click the <emphasis role="strong">System</emphasis> menu,
864
point to <emphasis role="strong">Administration</emphasis> and click
865
<emphasis role="strong">Boot-up Manager</emphasis>.</emphasis></para>
869
<title>Lesson Summary</title>
870
<para>In this lesson, you learnt that:
872
<listitem><para>You can run Ubuntu on a single partition or drive or may
873
decide to partition the drive after considering the various advantages of
874
partitioning.</para></listitem>
875
<listitem><para>Before partitioning the hard drive, you should make sure
876
that there is no data on the hard drive. If the hard drive on which you
877
are creating a partition contains data and you wish to preserve it, it
878
will be safer to back up the data before proceeding.</para></listitem>
879
<listitem><para>You can create a partition by using both the Gnome partition
880
editor and the command-line interface.</para></listitem>
881
<listitem><para>It is possible for you to change the boot-up configuration
882
to define the computer's boot order, change the default operating system to
883
boot or make a system command run automatically at boot-up.</para></listitem>
884
<listitem><para>To run a set of commands each time the system boots up, you
885
need to include the commands in the /etc/rc.local file so that the computer
886
executes them automatically at every boot-up.</para></listitem>
887
<listitem><para>You can change the default operating system at boot by making
888
changes in the configuration file.</para></listitem>
889
<listitem><para>You must read the service information before disabling any
890
service because disabling some services may stop your system from booting-up
891
or running properly.</para></listitem>
896
<title>Review Exercise</title>
897
<para><emphasis role="strong">Question 1</emphasis></para>
898
<para>What are the advantages of partitioning?</para>
899
<para><emphasis role="strong">Answer 1</emphasis></para>
900
<para>The following are the advantages of partitioning:
901
<orderedlist numeration="loweralpha">
902
<listitem><para>Minimises data loss</para></listitem>
903
<listitem><para>Enhances security</para></listitem>
904
<listitem><para>Enhances performance</para></listitem>
907
<para><emphasis role="strong">Question 2</emphasis></para>
908
<para>What is the minimum disk space that you need to allocate to a separate
909
root partition?</para>
910
<para><emphasis role="strong">Answer 2</emphasis></para>
911
<para>A separate root partition should be allocated at least 150-250 MB of disk
913
<para><emphasis role="strong">Question 3</emphasis></para>
914
<para>What is the function of each of the following fdisk commands:
915
<orderedlist numeration="loweralpha">
916
<listitem><para>d</para></listitem>
917
<listitem><para>n</para></listitem>
918
<listitem><para>p</para></listitem>
919
<listitem><para>w</para></listitem>
922
<para><emphasis role="strong">Answer 3</emphasis></para>
923
<orderedlist numeration="loweralpha">
924
<listitem><para>d - Deletes a partition</para></listitem>
925
<listitem><para>n - Adds a new partition</para></listitem>
926
<listitem><para>p - Prints the partition table</para></listitem>
927
<listitem><para>w - Writes table to disk and exit</para></listitem>
929
<para><emphasis role="strong">Question 4</emphasis></para>
930
<para>Why do you need to use the sudo command?</para>
931
<para><emphasis role="strong">Answer 4</emphasis></para>
932
<para>In Unix-based operating systems, you need to use the sudo command to run
933
programs that require administrative privileges.</para>
934
<para><emphasis role="strong">Question 5</emphasis></para>
935
<para>Which of these file systems does Ubuntu use by default?</para>
936
<orderedlist numeration="loweralpha">
937
<listitem><para>Fat 32</para></listitem>
938
<listitem><para>NTFS</para></listitem>
939
<listitem><para>Ext3</para></listitem>
941
<para><emphasis role="strong">Answer 5</emphasis></para>
943
<para><emphasis role="strong">Question 6</emphasis></para>
944
<para>If you want to run a system command automatically at start-up,
945
where should you add the command?</para>
946
<para><emphasis role="strong">Answer 6</emphasis></para>
947
<para>The command needs to be added to the /etc/rc.local file.</para>
948
<para><emphasis role="strong">Question 7</emphasis></para>
949
<para>Is it possible to disable all the start-up services? Why?</para>
950
<para><emphasis role="strong">Answer 7</emphasis></para>
951
<para>No, it is not possible to disable all start-up services because
952
disabling some services will stop your system from booting-up or running
956
<title>Lab Exercise</title>
957
<para><emphasis role="strong">Exercise 1</emphasis></para>
958
<para>As a previous Windows user, you want to have a dual-boot configuration
959
on your computer and create a separate partition to run Windows on it. To
960
perform this task, you need to create a 5-GB primary partition and
961
format it with a Windows-compatible file system.</para>
962
<para>Option a: To create a Partition using GNOME Partition Editor:
963
<orderedlist numeration="arabic">
964
<listitem><para>On the <emphasis role="strong">System</emphasis> menu,
965
point to <emphasis role="strong">Administration</emphasis> and then click
966
<emphasis role="strong">GNOME Partition Editor</emphasis>.</para></listitem>
967
<listitem><para>In the drive drop-down box, select the hard drive you need
968
to partition by specifying its logical name. The window refreshes and shows
969
you a representation of the drive.</para></listitem>
970
<listitem><para>Right-click the white bar and click
971
<emphasis role="strong">New</emphasis> to create a new partition.
972
The <emphasis role="strong">Create new Partition</emphasis> dialogue box
973
appears, in which you choose the specifications of the new
974
partition.</para></listitem>
975
<listitem><para>In the <emphasis role="strong">New Size</emphasis> dialogue
976
box, select the size of the new partition.</para></listitem>
977
<listitem><para>In the <emphasis role="strong">Create as</emphasis> box,
978
select <emphasis role="strong">Primary Partition</emphasis>.</para></listitem>
979
<listitem><para>Next, specify the file system. Select ntfs.</para></listitem>
980
<listitem><para>Click <emphasis role="strong">Add</emphasis> to compute the
981
partition. The graphical display updates to show a new partition on the disk.
983
<listitem><para>If you are sure about the specification of the new partition,
984
click <emphasis role="strong">Apply</emphasis>. The disk will be partitioned
985
and formatted.</para></listitem>
988
<para>Option b: To create a partition using command Line:
989
<orderedlist numeration="arabic">
990
<listitem><para>To initiate partitioning, run the fdisk command:</para>
991
<screen><para>$ sudo fdisk /dev/sda</para></screen>
993
<listitem><para>Type <emphasis role="strong">n</emphasis> to add a new
994
partition, and press <emphasis role="strong">ENTER</emphasis>.</para>
996
<listitem><para>Type <emphasis role="strong">l</emphasis> for a logical
997
partition, and press <emphasis role="strong">ENTER</emphasis>.</para>
999
<listitem><para>Type <emphasis role="strong">p</emphasis> to print the
1000
partition table. The output shows that a new partition has been created.
1002
<listitem><para>Now that the partition is created, type
1003
<emphasis role="strong">w</emphasis> to write the partition table to
1004
the disk and press <emphasis role="strong">ENTER</emphasis>.</para></listitem>
1005
<listitem><para>To format the disk, type the following command:</para>
1006
<screen><para>$ sudo mkfs -t vfat /dev/sda4</para></screen>
1007
<para>Replace sda4 with your device name.</para></listitem>