Partitioning is a very important concept in Linux. If you have your concepts clear, related to partitioning in Linux, it will be very helpful when you became a Linux System Administrator.
There is a new partitioning tool RHEL6 cfdisk, but we will see the traditional and most popular partitioning tool "fdisk". To use fdisk first you have to login as root. if you are a regular user and know root password, you can switch to root account using "su" command.
- To see your current disk and partitions run: fdisk -l
In the above image you can see that I have two hard disks. The first one is /dev/sda and the other one is /dev/sdb. In the above image you can see that the HDD /dev/sda is of size 16 GB and having two partitions /dev/sda1, which is created at the time of installation as /boot, and /dev/sda2, which is a Linux Logical Volume Manager(LVM). The second HDD is /dev/sdb which is newly installed HDD of size 2 GB and does not contain any valid partition table as you can see in the image.
In this post we will create the physical partitions and mount them on particular directories.
- To create a partition of 1 GB form /dev/sdb type :fdisk /dev/sdb, and press m to see menue.
- Press n to create new partition, p to create primary partition and e to create extended(always create first partition as primary), make partition 1, select first cylinder as default and on next line type +size of partition to be created,ex +1G.
- Now press p to print current partition table and press w to save partition table. and on command prompt type partprobe to update current partition table and run fdisk -l /dev/sdb.
- Now format this partition with command : mkfs.ext4 /dev/sdb1. Then create a directory /mydata, and mount /dev/sdb1 on /mydata using command : mount /dev/sdb1 /mydata.
- Make entry in /etc/fstab to make mounting persisting, means mount /mydata every time when server restart.
No comments:
Post a Comment