If you have added a new hard disk to your system or you are planning to add a new disk to your system. You will need to make file-system on newly created disks before using them. This article will help you to create partitions on disk in Linux system and format disk partitions to create a file system.
Step 1 – Create Disk Partitions
If you have added a new disk to your system, You can simply format entire disk and create it as a single disk. But it’s a good idea to create smaller partitions on large size disks.
fdisk /dev/sdc
Use n to create new partition like below. After that select p or e for creating a primary or extended file system. As we are creating first partition, so we can use p (primary). Remember that you can’t create more than 4 primary partitions.
Command (m for help):n Command action e extended p primary partition (1-4)p Partition number (1-4):1 First sector (63-104857599, default 63): 2048 Last sector, +sectors or +size{K,M,G} (2048-104857599, default 104857599):+10G
Save new partitioning table using w command.
Command (m for help):w
Step 2 – Format Disk Partitions
Use mkfs utility for creating the file system on disk partitions. You can define file system type with mkfs command which file system we need on disk.
mkfs -t ext4 /dev/sdc1
We can use any other file system type like: ext2, ext3, ext4, fat, vfat, ntfs etc.
mkfs.ext4 /dev/sdc1
3. Mount/Unmount Partitions
Before mounting a disk, you are required to create a mount point. Then use the mount command to mound disk partition on a mount point.
mkdir /newDisk1 mount /dev/sdc1 /newDisk1
Now use one of following command to verify disk is mounted successfully.
mount | grep "/dev/sdc1" df -h | grep "/dev/sdc1"
4. Mount Disk on Startup
Use /etc/fstab file which is used for mounting disk partitions during system boot up. Add the following entry in /etc/fstab file at the end of file.
/dev/sdc1 /newDisk1 ext3 defaults 0 2
2 Comments
Just press Enter and it will set to default value
what is sector and what to select for first and for last sector.???