A file system is an organization that stores data and metadata on a device. If you want to access any file in a Unix-like operating system, you must mount the file system where the file is located. As we all know, Linux file systems are Ext, Ext2, Ext3, Ex4, BtrFS, ReiserFS, ZFS, XFS, JFS, and Swap.
Let’s create a partition on Linux, create a file system and learn how to mount the file system.
Step 1: Create a partition
Before creating, make sure you have a free cylinder. You can check it with the following command.
#Fdisk -l disk / dev / sda: 10.7 GB, 10737418240 bytes 255 head, 63 sectors / track, 1305 cylinder units = cylinder 16065 * 512 = 8225280 bytes device boot end block ID system / dev / sda1 * 1 1020 8193118 + 83 Linux / dev / sda2 1021 1147 1020127+ 82 Linux swap / Solaris Here you can see that there are 1305 cylinders on the / dev / sda disk, and a maximum of 1147 cylinders are used. Therefore, we can use fdisk to create new partitions.
Fdisk command can be used to create a new partition
#Fdisk / dev / sda press n press p press “Enter” as the default boot cylinder “Now enter 100MB + change the partition type to 83 and finally reboot the system.
Step 2: Create a file system
In Linux, you can use the mkfs, mkfs.ext2, mkfs.ext3 or mkfs.ext4 commands (mke4fs) to create a file system.
# Mkfs.ext3 / dev / sda3 mke2fs 1.39 (May 29, 2006) File system label = OS type: Linux block size = 1024 (log = 0) Fragment size = 1024 (log = 0) 26208 inodes, 104420 Block 5221 blocks (5.00%) are reserved for super users to use the first data block = 1 maximum file system block = 67371008 13 block groups of 8192 blocks per group, 8192 fragments per group 2016 inode each group stored in block Superblock backup on: 8193, 24577, 40641, 57345, 73729 Inode table: Finish creating log (4096 blocks): Finish writing superblock and file system accounting information: Done
Step 3: Mount the file system
The most common way to mount a file system is to use the mount command manually or add an entry in / etc / fstab to mount the file system at boot time.
Syntax: Installation [option]
#Mount / dev / sda3 / dat
In the above example, we have mounted the / dev / sda3 partition to the / dat directory. You can verify this by executing the following command.
#Install | grep -i sda3 / dev / sda3 on / data type ext3 (rw)
Alternatively, you can unmount / dev / sda3 using the umount command.
# Uninstall / data
The / data file system is not available whenever the linux system is restarted. If you want to use the file system again, you must mount it manually. To avoid duplicate installations after Linux boot, we have to add entries in / etc / fstab. Fstab (File System Table) file is a file system configuration file.
Here we will briefly introduce the / etc / fstab configuration file.
#Cat / etc / fstab # device name mountpoint fs option type dump fsck LABEL = // ext3 default value 1 1 devpts / dev / pts devpts gid = 5, mode = 620 0 0 tmpfs / dev / shm tmpfs default value 0 0 proc / proc proc default value 0 0 sysfs / sys sysfs default value 0 0 LABEL = SWAP-sda2 swap exchange default value 0 0 / dev / sda3 / data ext3 default value 0 0
The name of the device / partition or source path (what to mount) / dev / sda3
Where the data is attached to the file system (mounting location) / data
The file system type is ext2, ext3, nfs, proc, etc.
In this option, you can apply a security policy to a specific file system. For example, when mounting, you can set no binary file execution or set a read-only file system. By default, the file system has rw, suid, rw, exec, auto, nouser, and async.
This is used for file system backups. If the value is set to zero, the backup is ignored. If set to 1, the file system is backed up.
This option determines the order in which file systems should be checked.
- How to use fdisk tool to create partitions in Linux
- How to force unmount NFS mounted directories in Linux
- Find detailed NFS mount options in Linux