If you have added a new hard disk to your system or you are planning to add new disk to your system. You will need to make file-system on newly created disks before use them. This article will help you to create partitions on disk in Linux system and format disk partitions to create file system.
1. Make 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 its 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 primary or extended file system. As we are creating first partition, so we can use
p (primary). Remember that you can’t create more that 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
2. Format Disk Partitions
Linux provides mkfs utility command to create filesystem on disk. We 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 mount command to mound disk partition on 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
Thanks for Visit Here
Comments
Post a Comment