In this post, I would add a partition in Linux through command line. Your first task should be to know which partitions are already mounted on your system and where they are mounted. So, run the following command which gives you this information:
$ sudo mount
If the partition which you wish to mount is shown, you can navigate to its mount directory. Lets say the mount directory of the partition you wish to mount is /mnt/partition1, then run the following command:
$ cd /mnt/partition1
And you be able to access its file system.
But if the partition you wish to mount is not shown by the command "sudo mount", you will have to mount it first. So, you would like to know the device identifier for the partition. The following command would help to do that:
$ sudo fdisk -l
it is a lowercase L. The identifier will look something like
/dev/sda1
Now you have to create a mount point(you can give any path for it). A mount point is a directory (typically an empty one) in the currently accessible filesystem on which an additional filesystem is mounted (i.e., logically attached). The mount point becomes the root directory of the newly added filesystem, and that filesystem becomes accessible from that directory.
$ sudo mkdir /mnt/ankitpartition
I used the path /mnt/ankitpartition. You can use some other path.
$ sudo nano /etc/fstab
You can use any other text editor, but I like nano.
Within the fstab you have to add a line which tells Linux to mount the partition. There should already be some entries which will give you a general guideline about how the line has to look like. Some examples:
mounting a FAT32 partition
/dev/sda2 /mnt/mypartition vfat umask=000,defaults 0 0
mounting a NTFS partition
/dev/sda2 /mnt/mypartition ntfs umask=000,defaults 0 0
To quit nano simply press ctrl + x. It will then ask you if you want to save the changes, press Y, and if you want to save it into the same fstab file, press Enter
And the last step would be:
$ sudo mount -a
$ sudo mount
If the partition which you wish to mount is shown, you can navigate to its mount directory. Lets say the mount directory of the partition you wish to mount is /mnt/partition1, then run the following command:
$ cd /mnt/partition1
And you be able to access its file system.
But if the partition you wish to mount is not shown by the command "sudo mount", you will have to mount it first. So, you would like to know the device identifier for the partition. The following command would help to do that:
$ sudo fdisk -l
it is a lowercase L. The identifier will look something like
/dev/sda1
Now you have to create a mount point(you can give any path for it). A mount point is a directory (typically an empty one) in the currently accessible filesystem on which an additional filesystem is mounted (i.e., logically attached). The mount point becomes the root directory of the newly added filesystem, and that filesystem becomes accessible from that directory.
$ sudo mkdir /mnt/ankitpartition
I used the path /mnt/ankitpartition. You can use some other path.
Since you probably want it to be mounted all the time we’ll skip the mount command and go right into the fstab i.e. we would make this mount point default. The default mount points are the directories in which file systems will be mounted automatically when the computer is booted. Default mount points are listed in the file /etc/fstab.
So now we would make this partition default. First open fstab file in a text editor:$ sudo nano /etc/fstab
You can use any other text editor, but I like nano.
Within the fstab you have to add a line which tells Linux to mount the partition. There should already be some entries which will give you a general guideline about how the line has to look like. Some examples:
mounting a FAT32 partition
/dev/sda2 /mnt/mypartition vfat umask=000,defaults 0 0
mounting a NTFS partition
/dev/sda2 /mnt/mypartition ntfs umask=000,defaults 0 0
To quit nano simply press ctrl + x. It will then ask you if you want to save the changes, press Y, and if you want to save it into the same fstab file, press Enter
And the last step would be:
$ sudo mount -a
No comments:
Post a Comment