0% found this document useful (0 votes)
5 views

Mounting

The document provides instructions on adding swap partitions and mounting file systems in Linux. It outlines the steps for creating a swap partition using fdisk or gdisk, formatting it, and activating it with swapon. Additionally, it explains how to mount file systems using device names, labels, or UUIDs, and emphasizes the importance of configuring automatic mounts through the /etc/fstab file.

Uploaded by

Mohamed Ibrahim
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Mounting

The document provides instructions on adding swap partitions and mounting file systems in Linux. It outlines the steps for creating a swap partition using fdisk or gdisk, formatting it, and activating it with swapon. Additionally, it explains how to mount file systems using device names, labels, or UUIDs, and emphasizes the importance of configuring automatic mounts through the /etc/fstab file.

Uploaded by

Mohamed Ibrahim
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Adding Swap Partitions

Using swap on Linux is a convenient way to improve Linux kernel memory usage. If a shortage of physical RAM occurs, non-
recently-used memory pages can be moved to swap, which makes more RAM available for programs that need access to memory
pages. Most Linux servers for that reason are configured with a certain amount of swap. If swap starts being used intensively, you
could be in trouble though, and that is why swap usage should be closely monitored .

Creating a Swap Partition

1. Use fdisk /dev/vda to open your disk in fdisk. (Use gdisk if you are using a disk with a GUID partition table.)
2. Press n to add a new partition.
3. Type t to change the partition type. If you are using fdisk, use partition type 82. If you are using gdisk, use
partition type 8200.
4. Use mkswap to format the partition as swap space. Use, for instance, mkswap /dev/vda6 if the partition you
have just created is /dev/vda6.
5. Type free -m. You see the amount of swap space that is currently allocated.
6. Use swapon to switch on the newly allocated swap space. If, for instance, the swap device you have just
created is /dev/vda6, use swapon /dev/vda6 to activate the swap space.
7. Type free -m again. You see that the new swap space has been added to your server.

Mounting File Systems

Mounting Means make FileSystem accessible to end user so he can write data and retrieve this
data again.
We used earlier the command mount as #mount /dev/sdb1 /mnt
you make its(/dev/sdb1) contents accessible through a specific directory(/mnt).
To mount a file system, some information is needed:
■ What to mount: This information is mandatory and specifies the name of the device that
needs to be mounted.
■ Where to mount it: This is also mandatory information which specifies the directory on
which the device should be mounted.
■ What file system to mount: Optionally, you can specify the file system type. In most cases,
this is not necessary. The mount command will detect which file system is used on the device
and make sure the correct driver is used.
■ Mount options: Many mount options can be used when mounting a device. Using options is
optional and depends on the needs you may have with the file system.

What to mount ?
You can use one of the following options to refer to the partirion you want to mount:
1. Device name (/dev/sdc1, /dev/sdb5,….)
2. Label : Label is just name for you as you can rename a partition under windows with
name songs or movies .
To create label for partition :
In ext4 filesystem the command is e2label
#e2label /dev/sda3 songs
In xfs filesystem the command is xfs_admin –L
#xfs_admin –L songs /dev/sda3

3. UUID : every object in your system has it’s unique ID. Every Parition you created and
applied FileSystem on it the system created UUID for it. (THE BEST WAY).
To display UUID for the partitions in the system use the command blkid
To display block devices in the system use command lsblk (with –f option to list labels)
Examples
1. mount UUID="42f419c4-633f-4ed7-b161-519a4dadd3da" /mnt
2. mount /dev/sdc4 /media
3. mount LABEL=songs /mnt

Permanent Mount with fstab:

Normally, you do not want to be mounting file systems manually. Once you are ready, it is a good idea to have them mounted
automatically. The classical way to do this is through the /etc/fstab file.

[root@server3 ~]# cat /etc/fstab


#
# /etc/fstab
# Created by anaconda on Fri Jan 16 10:28:41 2015
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/centos-root / xfs defaults 1 1
UUID=02305166-840d-4f74 / xfs defaults 1 2
/dev/mapper/centos-swap swap swap defaults 0 0
Content of FSTAB file

Mounting Options

Eng. Muhammad Adel

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy