Linux with Operating System Concepts


partitions will be archived by dump, respectively. The most common entry is 0 0



Download 5,65 Mb.
Pdf ko'rish
bet151/254
Sana22.07.2022
Hajmi5,65 Mb.
#840170
1   ...   147   148   149   150   151   152   153   154   ...   254
Bog'liq
Linux-with-Operating-System-Concepts-Fox-Richard-CRC-Press-2014


partitions will be archived by dump, respectively. The most common entry is 0 0.
You can explore the currently mounted partitions through the 
df
command. This com-
mand displays file system usage. Specifically, it lists the amount of disk space that is being 
used and the amount that is free for each mounted partition. An example of output from 
df is shown in Figure 10.6. Notice how the information somewhat overlaps what we find in 
the /etc/fstab file although df does not display all of the file systems (for instance, missing 
are swap and proc).
The first column of the df output is the mounted partition’s device name while the last 
column is the partition’s mount point. In between, we see usage and free information. In 
this case, we are given these values in terms of used and available disk blocks. We can alter 
this behavior to illustrate the number of used and free inodes or used and free disk space 
by capacity (e.g., 31G).
Filesystem
1 K-Blocks Used
Available Use% Mounted on
/dev/sda1
4,031,680
2,955,480 871,400
78
/
/dev/sda5
6,349,763
359,761
5,667,443 6
/home
/dev/sda2
1,007,896
178,220
778,476
19
/var
www.someserver.com:
/home/stuff
635,008
35,968
566,784
6
/home/coolstuff
tmpfs
510,324
284
510,040
1
/dev/shm
FIGURE 10.6 
Results from df.


The Linux File System

409
Options to alter the output of df are shown below:
• -a—output all file systems, including “dummy” file systems
• -B size—output number of blocks in size increments, for instance, -B 1K would out-
put file system capacity and availability in 1K block sizes while -B 8K would use 8K 
block sizes
• -h—use human-readable format for sizes using units in K, M, G, T, and so on
• -i—output inodes rather than disk blocks
The df command can be used on individual file systems, as in 
df /home
. The 
parameter(s) can also be individual files, in which case df outputs the usage information 
for the file’s file system. For instance, 
df /home/foxr/somefile
would output the 
same information as 
df /home
.
Finally, the /etc/mtab file contains the up-to-date mount information. That is, while 
fstab is a static description of the file space’s partitions, mtab shows you what is currently 
mounted, including file systems that are mounted remotely. If you have not mounted or 
unmounted any partitions, then you should have the same partitions listed in both mtab 
and fstab. However, mtab is interactive; that is, it is modified as partitions are mounted and 
unmounted. If you have unmounted some partitions and want to reestablish the mounting 
as you expect to see it upon a fresh boot of the OS, you can issue the mount all command, 
which is 
mount –a
. We explore mounting later.
10.4.3 Creating Partitions
When do you create your initial partitions? You do so when you first install your operating 
system, as we saw in Chapter 8. How do you decide upon the partitions for your system? 
What size do we reserve for our partitions and what types should these partitions be (what 
types of file systems?) Where will we make the mount points for the partitions? These are 
decisions that we will make based on the type and usage of our computer.
Is it a standalone workstation for a single user? If so, fine-grained partitions are not 
really needed and most of the space can be reserved for /home. Is the workstation one that 
multiple users might be using at a time? This may lead you to a greater degree of partition-
ing such as having a separate /usr partition for software. Is the computer a server that will 
handle dozens, hundreds, or even millions of requests a day? If so, then /var will store a 
greater amount of information and so might require extra space.
Fortunately, these partitioning decisions are fairly uniform in that we do not have to 
consider too many other questions. This simplifies the partitioning process and lets us 
have confidence in our decisions. Below is a description of the different partitions that you 
might choose and why.
/—every Linux installation requires a root partition for the Linux OS. This will include 
the directories /bin, /usr/bin, /sbin, and /usr/sbin unless we specify a finer-grained distri-
bution. In addition, / will store the root account’s home directory (/root).


410

Linux with Operating System Concepts
If we do not separately create a /boot partition, then /boot (the OS kernel and boot 
loader programs) will be stored under the root partition as well.
/home—we separate the user space from the root partition for security purposes. The 
/home partition should be the partition in which all user directories and files are stored. 
While / is not expected to grow, /home will grow as you add users to the system and those 
users create files. The /home directory is a potential target for placing disk quotas whereas 
/ would not need this.
/var—this top-level directory houses many of the system data files. The term “var” indi-
cates “variable” in that these files will change over time. Not only does this require that the 
partition be rw (readable, writable) but also that we will need to ensure room for these files 
to grow over time.
Among the files that you would find here are mail directories (one for each user account), 
log files, which are generated by various software and operating system events, print spooler 
files, and possibly even server files such as the web space for a website. Unlike /home, there 
would be little point to placing disk quotas on this file space because the files will primarily 
be owned by various software (or root).
swap—The swap space is essential so that the Linux operating system can expect to run 
efficiently no matter how many processes are launched. Processes are copied into memory 
to be executed. However, when memory becomes full, unused portions of those processes 
are held in swap space. This includes both executable code and data space. The items moved 
between swap space and memory are known as pages and the pages are only loaded into 
memory on demand (as needed). So memory is in reality only storing portions of what is 
running while their entire backing content is stored in swap space.
The swap space for Linux should be at least the size of the computer’s RAM. This is dif-
ferent from Windows systems where swap space is often recommended to be at least twice 
the size of the main memory. If you examine the swap partition entry in /etc/fstab (see 
Figure 10.5), you will see that this file system does not have a mount point like the other 
partitions. You will also see that the swap partition does not even appear when you use the 
df command (see Figure 10.6).
Linux comes with 
swapon
and 
swapoff
instructions to mount and unmount the 
swap space. Normally, you would never unmount the swap space. But if you wanted to 
switch swap spaces, for instance, if your original swap partition was deemed too small 
and you have created a new swap partition on another device, you can swapoff and then 
swapon using the new device. When using these commands, the option -a will turn 
all
swap space off or on.
Other partitions that you might make include /usr to store all executable user software, 
/tmp, which is used by running software to store temporary files, /boot to store the boot 
program itself, /opt and /usr/bin. The /opt directory is for third-party software and /usr/
bin allows you to separate the binary portions of the /usr directory from other files that 
support application software (such as man pages, configuration files, shared library files
and source code).
You might expect files in /usr and /opt to be read-only, so you would mount them using 
the ro option instead of the default rw. The /tmp directory is writable by anyone and 


The Linux File System

411
everyone so it might be mounted using a umask of 000 (recall the umask from Chapter 9 
is used to establish default permissions by subtracting the umask from 777 for directories, 
thus /tmp would have permissions of 777).
10.4.4 Altering Partitions
What happens if you decide, after OS installation, that you want to increase the number of 
Download 5,65 Mb.

Do'stlaringiz bilan baham:
1   ...   147   148   149   150   151   152   153   154   ...   254




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish