Официален блог на WebEKM EKM очаквайте сайта онлайн скоро.

Download Free Templates http://bigtheme.net/ free full Wordpress, Joomla, Mgento - premium themes.

Linux – Adding new HDD to the server, partitioning, formatting with PARTED, permanent mounting with fstab.

Dealing with freshly added hard drives to the system is not difficult, but as every system manipulation in Linux requires a CLI knowledge. This article allows you adding seamlessly hard drive to the system, partitioning and mounting its permanently thanks to fstab file.

The steps required in order to add the hard drive and mount its may look just in this way. I used PARTED software but you can use FDISK for example as well.


1. Identifying the new hard drive
Firstly you have to get to know what is the name of the hard disk that you just added to the server. CentOS show you this information if you use command “lsblk“. In my case the hard disk got “sdb” name as the second disk in the server


2 . Running PARTED
Now we have to use PARTED software or FDISK to create partition and format its. I gonna use PARTED. Because we will be working with “sdb” hard disk we type “select /dev/sdb/

2parted unrecog label

3. Choosing type of partition table GPT/MSDOS
As we see on the output above there is an error “unrecognised disk label”, what means there is no partition table on “sdb”. We fix it by “mklabel gpt” command. You may also choose “msdos” partition table but is less safe and doesn’t support HDD larger then 2TB My hard disk is only 5GB, but I’ve choosen GPT anyway.


4. Partitioning
Every hard disk can be partitioned, what means we may create a few  logical disks within single physical disk. In Parted we do that by “mkpart” command. As you see I created 2 partitions: 2GB  and 3GB and also named them “music” and “videos”


let’s check how does it look by “lsblk” and “blkid”

5.lsblk after parted

6. blkid

5. Formatting partitions with filesystems
Because there is no file system on our partitions we have to create any. Parted doesn’t format partitions that we created only puts a flag, so you have to use  “mkfs” software. You may choose among many types, I formatted my partitions with ext4 filesystem. I also decided to add the LABELs “music” and “videos” for further purpose (fstab modfication).

No file system on sdb1 sdb2

7.lsblk -f no fs

let’s use “mkfs” command 


and how it looks after formatting

9.lsblk -f with fs

6. Mounting
In Linux we have to mount partitions to folders, only then they will be visible and ready to use. I mounted sdb1 and sdb2 partitions in /mnt/music and /mnt/videos folders

10mkdir mount

Let’s check how now our partitions are visible for CentOS

11lsblk after mount

Let’s check if we may copy files to /mnt/music and /mnt/videos, if yes, that’s mean everything has proceeded properly !


Now, there is a little problem every time we reboot the server our partitions will be unmounted without our permission. Before you check this, first type “cat /etc/mtab” In “mtab” file we will find the most current list of mounted devices. You gonna find sdb1 and sdb2 here for sure, among many others.

12 mtab

Now check the “fstab” file by “cat /etc/fstab”.

13 fstab empty

Fstab is the system file that store the list of permamently mounted devices. As you see there are no sdb1 and sdb2 partitions. 

Let’s reboot the server, there are no points of mounting for sdb1 and sdb2!

16lsblk after reboot

We have to change this ! But before we do that, one important thing!

We may add sdb1 and sdb2 in three ways with label name that we created during formatting (music/videos), device(/dev/sdb1, /dev/sdb2) name or UUID (check by blkid)

14 blkid

I use nano editor to edit fstab file. “nano /etc/fstab”

17 ftsab modified

I’ve decided to add sdb1 by UUID and sdb2 by the LABEL that I assigned before during formatting, now let’s reboot the server one more time .

18 lsblk -f aft reboot

Points of mount have been permamantly added to the server, now will be visible until we remove them from fstab ! 


Onlain bookmaker bet365.com - the best bokie