0% found this document useful (0 votes)
5 views

Managing Partitioned and Creating Filesystem

The document provides a comprehensive guide on managing partitions and creating filesystems in Linux using utilities like fdisk and partprobe. It details the steps for creating, formatting, and mounting partitions, as well as how to delete them. Additionally, it explains how to update the partition table without rebooting and how to check filesystem types and mount points.

Uploaded by

abhisheksafeeka
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Managing Partitioned and Creating Filesystem

The document provides a comprehensive guide on managing partitions and creating filesystems in Linux using utilities like fdisk and partprobe. It details the steps for creating, formatting, and mounting partitions, as well as how to delete them. Additionally, it explains how to update the partition table without rebooting and how to check filesystem types and mount points.

Uploaded by

abhisheksafeeka
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 21

Linux Managing Partitions and Creating Filesystem

Managing partitions include creating a new partition, deleting an


existing partition etc.

Below are some of the utilities used to manage partitions in Linux .


o fdisk
o GNU parted - advanced partition manipulation (Create copy,
resize etc)
o partprobe - reinitializes the kernel's in-memory version
of the partition table

Managing Partitions using fdisk


Syntax :fdisk device name

Creating Partitioned

To List all the current Partitioned.

[root@localhost ~]# fdisk -l

Disk /dev/sda: 80.5 GB, 80530636800 bytes, 157286400 sectors


Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x0006b846

Device Boot Start End Blocks Id System


/dev/sda1 * 2048 2101247 1049600 83 Linux
/dev/sda2 2101248 23869439 10884096 83 Linux
/dev/sda3 23869440 28063743 2097152 82 Linux swap /
Solaris
/dev/sda4 28063744 157286399 64611328 5 Extended
/dev/sda5 28065792 39849983 5892096 83 Linux
/dev/sda6 39852032 44046335 2097152 83 Linux
/dev/sda7 44048384 52436991 4194304 82 Linux swap /
Solaris
/dev/sda8 52439040 58730495 3145728 83 Linux
/dev/sda9 58732544 65023999 3145728 83 Linux
/dev/sda10 65026048 69220351 2097152 83 Linux
/dev/sda11 69222400 73416703 2097152 83 Linux
/dev/sda12 73418752 77613055 2097152 83 Linux
/dev/sda13 77615104 81809407 2097152 8e Linux LVM
/dev/sda14 81811456 83908607 1048576 83 Linux
/dev/sda15 83910656 86007807 1048576 83 Linux
/dev/sda16 86009856 88107007 1048576 83 Linux
/dev/sda17 88109056 90206207 1048576 83 Linux

Step 1: use fdisk Utility to create partitioned


command :/fdisk /dev/sda

[root@localhost ~]# fdisk /dev/sda


Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Step 2: To create or add a new partition press [n] key

To create Partitioned Type n

Command (m for help): n


All primary partitions are in use
Adding logical partition 6
First sector (39852032-157286399, default 39852032):
Using default value 39852032

To create a partitioned of Size 4GB ,give +4G

Last sector, +sectors or +size{K,M,G} (39852032-157286399, default


157286399): +4G

Partition 6 of type Linux and of size 4 GiB is set

Step 3: You have option of creating a primary or extended partition.


To create a Primary Partitioned press [p] key to create a primary
partition

Step 4: Press [p] key to print the partition table

To view newly created Partition Type p ,You can see partitioned


/dev/sda6 is created with Default file system ID 83
Command (m for help): p

Disk /dev/sda: 80.5 GB, 80530636800 bytes, 157286400 sectors


Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x0006b846

Device Boot Start End Blocks Id System


/dev/sda1 * 2048 2101247 1049600 83 Linux
/dev/sda2 2101248 23869439 10884096 83 Linux
/dev/sda3 23869440 28063743 2097152 82 Linux swap /
Solaris
/dev/sda4 28063744 157286399 64611328 5 Extended
/dev/sda5 28065792 39849983 5892096 83 Linux
/dev/sda6 39852032 48240639 4194304 83 Linux

Step 5:Press [w] key to write the changes to the partition table and
exit
To Save the Partitioned Table ,Type w

Command (m for help): w


The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or
resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.
[root@localhost ~]#Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or
resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.
[root@localhost ~]#

Step 6:To Update Partition table Run command partx -a /dev/sda or


partprobe /dev/sda

New partitioned created has not been reflected in partition table ,for
changes to reflected its need to be rebooted.
But in production ,we cannot reboot server machine .

We can clearly see partitioned 6 is not updated in partitioned table .


[root@localhost ~]# cat /proc/partitions
major minor #blocks name

11 0 1048575 sr0
8 0 78643200 sda
8 1 1049600 sda1
8 2 10884096 sda2
8 3 2097152 sda3
8 4 1 sda4
8 5 5892096 sda5
[root@localhost ~]#

In order to update partitioned table without allowing reboot


,we can use command : partprobe device name

[root@localhost ~]# partprobe /dev/sda

Forcefully telling kernel to update partitioned table without restart.

Step 7:To verify the created partitions


Command :cat /proc/partitions

Now we can see Updated Partitioned Table .

[root@localhost ~]# cat /proc/partitions


major minor #blocks name

11 0 1048575 sr0
8 0 78643200 sda
8 1 1049600 sda1
8 2 10884096 sda2
8 3 2097152 sda3
8 4 1 sda4
8 5 5892096 sda5
8 6 4194304 sda6
[root@localhost ~]#

Step 8: Once the partition is created it has to be formatted with a


filesystem and mounted so that it can be used
Command :mkfs -t ext4 /dev/sda6

Now New Partitioned has been created but its just a Raw partitioned .
[root@localhost ~]# fdisk -l

Disk /dev/sda: 80.5 GB, 80530636800 bytes, 157286400 sectors


Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x0006b846

Device Boot Start End Blocks Id System


/dev/sda1 * 2048 2101247 1049600 83 Linux
/dev/sda2 2101248 23869439 10884096 83 Linux
/dev/sda3 23869440 28063743 2097152 82 Linux swap /
Solaris
/dev/sda4 28063744 157286399 64611328 5 Extended
/dev/sda5 28065792 39849983 5892096 83 Linux
/dev/sda6 39852032 48240639 4194304 83 Linux
[root@localhost ~]#

We cannot read and write data in Raw partitioned. In order to write


and read we have to create Filesystem.

To create Filesystem either ext3 or ext4,xfs is default filesystem in


RHEL 7

Below command will create and format with ext4 filesystem


mkfs -t ext4 /dev/sda6

[root@localhost ~]# mkfs -t ext4 /dev/sda6


mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
262144 inodes, 1048576 blocks
52428 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=1073741824
32 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736

Allocating group tables: done


Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

[root@localhost ~]#

Step 9:To provide Label name to created partition


Syntax :e2label /partition/name label name

[root@localhost ~]# e2label /dev/sda6 data


To View label of filesystem

[root@localhost ~]# e2label /dev/sda6


data

Step 10:To check the filesystem type and partition information


Command :blkid

To see filesystem type and Partitioned Information ,you can also use
command blkid

[root@localhost ~]# blkid


/dev/sda2: UUID="0d0f59f0-2554-4b2e-8a91-f29a9b16f4a0" TYPE="xfs"
/dev/sda1: UUID="844f08a3-4f7b-420d-97a2-c2f90f4b35be" TYPE="xfs"
/dev/sda3: UUID="e81d6072-3717-4d0c-b8cb-31a1cae2c7ed" TYPE="swap"
/dev/sda5: UUID="5400577a-046d-4199-86d2-82a7c57be329" TYPE="xfs"
/dev/sda6: LABEL="data" UUID="a7e3f6c7-0b9c-4e72-889b-dbf3c27a02f7"
TYPE="ext4"
[root@localhost ~]#

Step 11: To permanently mount the partition on a directory :


Command : vi /etc/fstab
Insert the following line in /etc/fstab
/dev/sda6 /mnt ext4 defaults 11

To make it mount permanently even after restart, make a entry in


file /etc/fstab ,In last line Enter

[root@localhost ~]# cat /etc/fstab

/dev/sda6 /data ext4 defaults 0 0


[root@localhost ~]#

Step 12: To mount the directory by re-reading the fstab entries


command :mount -a

mount -a : Will read the mount point by reading configuration file


called /etc/fstab

[root@localhost ~]# mount -a


Step 13: To check Mount is successful or not use command df-hT, where
option h:size in human readable format and option T:Type of Filesystem

[root@localhost ~]# df -hT


Filesystem Type Size Used Avail Use% Mounted on
/dev/sda2 xfs 11G 3.3G 7.2G 32% /
devtmpfs devtmpfs 906M 0 906M 0% /dev
tmpfs tmpfs 920M 0 920M 0% /dev/shm
tmpfs tmpfs 920M 8.9M 911M 1% /run
tmpfs tmpfs 920M 0 920M 0% /sys/fs/cgroup
/dev/sda5 xfs 5.7G 37M 5.6G 1% /home
/dev/sda1 xfs 1015M 173M 843M 18% /boot
tmpfs tmpfs 184M 4.0K 184M 1% /run/user/42
tmpfs tmpfs 184M 36K 184M 1% /run/user/1000
tmpfs tmpfs 184M 0 184M 0% /run/user/0
/dev/sda6 ext4 3.9G 16M 3.6G 1% /data
[root@localhost ~]#

Delete a partition

Step 1 :First partitioned to be unmounted

To see partitioned is Mounted or not

[root@localhost ~]# mount | grep sda6


/dev/sda6 on /data type ext4 (rw,relatime,seclabel,data=ordered)
[root@localhost ~]#

To check Partitioned is Mounted or not using df -hT command

[root@localhost ~]# df -hT| grep sda6


/dev/sda6 ext4 3.9G 16M 3.6G 1% /data
[root@localhost ~]#

To unmount the Partitioned /dev/sda6


[root@localhost ~]# umount /data
[root@localhost ~]#
To Delete a Partition -fdisk /dev/sda

Step 2 :To Delete the partitioned go to Partitioned Device. using


below command :

root@localhost ~]# fdisk /dev/sda


Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Step 3 :In command Line Type Press [d] key and select partition number
to delete a partition .

Command (m for help): d

In command Prompt provide, partitioned number to be deleted


Partition number (1-6, default 6): 6
Partition 6 is deleted

Step 3 :In command Line Type Press [w] key to write the changes to the
partition Table and exit

Command (m for help): w


The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device
or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.
[root@localhost ~]#

Step 4 :Run Partx -a /dev/sda execute this command to update the


partition table

Even after deleting from Command Line ,in Partition Table still
partitioned is not deleted ,can be verify from file /proc/partitions
[root@localhost ~]# cat /proc/partitions
major minor #blocks name

11 0 1048575 sr0
8 0 78643200 sda
8 1 1049600 sda1
8 2 10884096 sda2
8 3 2097152 sda3
8 4 1 sda4
8 5 5892096 sda5
8 6 4194304 sda6
[root@localhost ~]#

Step 5 :To Update the Partitioned table without Machine restart ,use
partprobe command

[root@localhost ~]# partprobe /dev/sda


[root@localhost ~]#

Step 6 :Now we can verify same in Partition Table ,by looking into
file /proc/partitions , we can se sda6 has been deleted.

[root@localhost ~]# cat /proc/partitions


major minor #blocks name

11 0 1048575 sr0
8 0 78643200 sda
8 1 1049600 sda1
8 2 10884096 sda2
8 3 2097152 sda3
8 4 1 sda4
8 5 5892096 sda5
[root@localhost ~]#

Making Filesystems

MKFS is used to build a Linux file system on a device


To list the available file system commands
command:ls /sbin/mkfs*

ls /sbin/mkfs*

[root@localhost ~]# ls /sbin/mkfs*


/sbin/mkfs /sbin/mkfs.ext2 /sbin/mkfs.fat /sbin/mkfs.vfat
/sbin/mkfs.btrfs /sbin/mkfs.ext3 /sbin/mkfs.minix /sbin/mkfs.xfs
/sbin/mkfs.cramfs /sbin/mkfs.ext4 /sbin/mkfs.msdos
[root@localhost ~]#

mkfs options
-t Specifies the type of file system to built. The default is
ext2
-c Check the device for bad blocks before building a file
system
- v display Verbose output

Creating a file system on a device


command :mkfs - t ext4 /dev/sda17

[root@localhost ~]# mkfs -t ext4 /dev/sda6


mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
262144 inodes, 1048576 blocks
52428 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=1073741824
32 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736

Allocating group tables: done


Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
To Check for bad sectors on a device
commands: mkfs -c /dev/sda17

[root@server ~]# mkfs -c /dev/sda17


mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
65536 inodes, 262144 blocks
13107 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=268435456
8 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376

Checking for bad blocks (read-only test): done


Allocating group tables: done
Writing inode tables: done
Writing superblocks and filesystem accounting information: done

[root@server ~]#

To Create a file system with journal


Command :mke2fs /dev/sda17 -j

[root@server ~]# mke2fs /dev/sda17 -j


mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
65536 inodes, 262144 blocks
13107 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=268435456
8 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376

Allocating group tables: done


Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done

[root@server ~]#

To Change the inode size on the partition


Command :mke2fs -I 256 /dev/sda17

[root@server ~]# mke2fs -I 256 /dev/sda17


mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
65536 inodes, 262144 blocks
13107 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=268435456
8 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376

Allocating group tables: done


Writing inode tables: done
Writing superblocks and filesystem accounting information: done

Filesystem labels
E2label will display or change the file system labels, which provide
an alternative way to refer to devices
Syntax :e2label device labelname

[root@server ~]# e2label /dev/sda17 pract1


[root@server ~]# e2label /dev/sda17
pract1
[root@server ~]#

Blkid :To see the file system type and label

Options
-c :Read from cache file instead of reading from the default
cache
-g : perform a garbage collection pass on the blkid cache to
remove devices which no longer exist
-h Display a usage message and exit

[root@server ~]# blkid -cg


/dev/sda1: UUID="844f08a3-4f7b-420d-97a2-c2f90f4b35be" TYPE="xfs"
/dev/sda2: UUID="0d0f59f0-2554-4b2e-8a91-f29a9b16f4a0" TYPE="xfs"
/dev/sda3: UUID="e81d6072-3717-4d0c-b8cb-31a1cae2c7ed" TYPE="swap"
/dev/sda5: UUID="5400577a-046d-4199-86d2-82a7c57be329" TYPE="xfs"
/dev/sda6: UUID="WvAYOy-1q0r-lUa4-Hbyh-vS5n-T2CM-qX2mFG"
TYPE="LVM2_member"
/dev/sda7: UUID="16fbcfbf-8f92-4450-9511-adc920925d7e" TYPE="swap"
/dev/sda8: UUID="hLLfkc-FoG6-kJXC-VrRU-pMFp-Qjbq-kTiKuv"
TYPE="LVM2_member"
/dev/sda9: UUID="1WztpE-hIeC-fAbH-j0Gm-SNyf-U679-Yp42co"
TYPE="LVM2_member"
/dev/sda10: UUID="aqxtqr-0Bnx-2dHZ-8EA3-Liug-Dtap-H46wzb"
TYPE="LVM2_member"
/dev/sda11: UUID="BywwAt-Xn36-hc44-FjWj-uvFd-s8vi-3GYUVz"
TYPE="LVM2_member"
/dev/sda12: UUID="fbQLQg-t1EU-B7mR-IdEm-ocVC-fwvp-ZTgvp9"
TYPE="LVM2_member"
/dev/sda13: UUID="eSoTez-gWUK-6aGu-Jbdd-8R5y-5yXn-oNbfXA"
TYPE="LVM2_member"
/dev/sda17: LABEL="pract1" UUID="2f4e5819-f679-4cac-b0d2-e7d4dd694273"
TYPE="ext2"
/dev/mapper/VG01_RHEL7-LV01_RHEL7: UUID="76a50abb-a68d-474a-9a87-
6bb948d4041a" TYPE="ext4"
/dev/mapper/VG01_RHEL7-LV01_RHEL7_SNAP: UUID="76a50abb-a68d-474a-9a87-
6bb948d4041a" TYPE="ext4"
[root@server ~]#

Tune2fs :
Tune2fs allows the system administrator to adjust file
system parameters
View File system information

Command :tune2fs -l /dev/sda6

To see complete Information about Filesystem /dev/sda6

[root@localhost ~]# tune2fs -l /dev/sda6


tune2fs 1.42.9 (28-Dec-2013)
Filesystem volume name: data
Last mounted on: <not available>
Filesystem UUID: 0b7cd2a7-61c5-4a0e-ab04-2c67662c94c5
Filesystem magic number: 0xEF53
Filesystem revision #: 1 (dynamic)
Filesystem features: has_journal ext_attr resize_inode dir_index
filetype n
eeds_recovery extent 64bit flex_bg sparse_super large_file huge_file
uninit_bg d
ir_nlink extra_isize
Filesystem flags: signed_directory_hash
Default mount options: user_xattr acl
Filesystem state: clean
Errors behavior: Continue
Filesystem OS type: Linux
Inode count: 131072
Block count: 524288
Reserved block count: 26214
Free blocks: 498132
Free inodes: 131061
First block: 0
Block size: 4096
Fragment size: 4096
Group descriptor size: 64
Reserved GDT blocks: 255
Blocks per group: 32768
Fragments per group: 32768
Inodes per group: 8192
Inode blocks per group: 512
Flex block group size: 16
Filesystem created: Tue Oct 10 22:07:15 2017
Last mount time: Tue Oct 10 22:07:49 2017
Last write time: Tue Oct 10 22:07:49 2017
Mount count: 1
Maximum mount count: -1
Last checked: Tue Oct 10 22:07:15 2017
Check interval: 0 (<none>)
Lifetime writes: 65 MB
Reserved blocks uid: 0 (user root)
Reserved blocks gid: 0 (group root)
First inode: 11
Inode size: 256
Required extra isize: 28
Desired extra isize: 28
Journal inode: 8
Default directory hash: half_md4
Directory Hash Seed: 36460618-014b-414c-99c3-d1811984ea16
Journal backup: inode blocks

Display File system volume name using tune2fs


Command :tune2fs -l /dev/sda6 |grep volume
To see Volume Name of Filesystem /dev/sda6

[root@localhost ~]# tune2fs -l /dev/sda6 | grep volume


Filesystem volume name: data

To Change File system volume name


Command:tune2fs -L updatevol /dev/sda6

To update filesystem labels ,for example changing filesystem /dev/sda6


level name from data to Data use command tune2fs with Option Capital
-L

[root@localhost ~]# tune2fs -L Data /dev/sda6


tune2fs 1.42.9 (28-Dec-2013)

To check change Label

[root@localhost ~]# tune2fs -l /dev/sda6 | grep volume


Filesystem volume name: Data

Finding File system Check intervals and Mount counts


Command :tune2fs -l /dev/sda6 |grep counts

To scan filesystem after this interval for backlogs or error


Check interval : count

[root@localhost ~]# tune2fs -l /dev/sda6 |grep count


Inode count: 131072
Block count: 524288
Reserved block count: 26214
Mount count: 1
Maximum mount count: -1
[root@localhost ~]#

Mount count :1
means After 1 mount it will check partitioned /dev/sda6

To verify the Inode & Block count by passing '-i' argument to tune2fs
command on a specific partition
Command:tune2fs -l /dev/sda6 |grep -i count
[root@server ~]# tune2fs -l /dev/sda17 |grep -i count
Inode count: 65536
Block count: 262144
Reserved block count: 13107
Mount count: 0
Maximum mount count: -1

To Adjust the number of mounts after which the filesystem will be


checked by e2fsck.
Command :tune2fs -c 100 -i 2m /dev/sda6

To set after 200 mount and time period of 2 month ,It will check or
scan filesystem.

[root@localhost ~]# tune2fs -c 200 -i 2m /dev/sda6


tune2fs 1.42.9 (28-Dec-2013)
Setting maximal mount count to 200
Setting interval between checks to 5184000 seconds
[root@localhost ~]#

To check or scan filesystem /dev/sda6 after the interval in seconds (2


months)

[root@localhost ~]# tune2fs -l /dev/sda6 |grep interval


Check interval: 5184000 (2 months)
[root@localhost ~]#

Dump2fs Command

Dump2fs prints the super block and blocks group information on the
file system and present on device
Command :dump2fs -h /dev/sda6
The above command dumps all file system information

To check filesystem /dev/sda6 super block information

[root@localhost ~]# dumpe2fs -h /dev/sda6


dumpe2fs 1.42.9 (28-Dec-2013)
Filesystem volume name: Data
Last mounted on: <not available>
Filesystem UUID: 0b7cd2a7-61c5-4a0e-ab04-2c67662c94c5
Filesystem magic number: 0xEF53
Filesystem revision #: 1 (dynamic)
Filesystem features: has_journal ext_attr resize_inode dir_index
filetype n
eeds_recovery extent 64bit flex_bg sparse_super large_file huge_file
uninit_bg d
ir_nlink extra_isize
Filesystem flags: signed_directory_hash
Default mount options: user_xattr acl
Filesystem state: clean
Errors behavior: Continue
Filesystem OS type: Linux
Inode count: 131072
Block count: 524288
Reserved block count: 26214
Free blocks: 498132
Free inodes: 131061
First block: 0
Block size: 4096
Fragment size: 4096
Group descriptor size: 64
Reserved GDT blocks: 255
Blocks per group: 32768
Fragments per group: 32768
Inodes per group: 8192
Inode blocks per group: 512
Flex block group size: 16
Filesystem created: Tue Oct 10 22:07:15 2017
Last mount time: Tue Oct 10 22:07:49 2017
Last write time: Tue Oct 10 22:23:58 2017
Mount count: 1
Maximum mount count: 200
Last checked: Tue Oct 10 22:07:15 2017
Check interval: 5184000 (2 months)
Next check after: Sat Dec 9 22:07:15 2017
Lifetime writes: 65 MB
Reserved blocks uid: 0 (user root)
Reserved blocks gid: 0 (group root)
First inode: 11
Inode size: 256
Required extra isize: 28
Desired extra isize: 28
Journal inode: 8
Default directory hash: half_md4
Directory Hash Seed: 36460618-014b-414c-99c3-d1811984ea16
Journal backup: inode blocks
Journal features: journal_64bit
Journal size: 64M
Journal length: 16384
Journal sequence: 0x00000002
Journal start: 1

[root@localhost ~]#

Mount

All files accessible in Linux system are arranged like a tree, the
file hierarchy rooted at "/".These files can be spread out over
several devices .The mount command serves to attach the file system
found on some device to one big file tree

Mount command reads information from the mentioned below:


1. /etc/fstab - File system table
2. /etc/mtab -table of mounted file systems
3. /etc/mtab~ lock file
4. /etc/mtab.tmp temporary file
5. /etc/filesystems - a list of file system

Mount Point -
A mount point is a directory to access the data, which is stored in
our disks.

Example :Mount Points - /mountdir


/dev/sda6 -path of the partition

To View all mount points


Command :Mount

[root@server ~]# mount


sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime,seclabel)
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
devtmpfs on /dev type devtmpfs
(rw,nosuid,seclabel,size=927256k,nr_inodes=231814,mode=755)
securityfs on /sys/kernel/security type securityfs
(rw,nosuid,nodev,noexec,relatime)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev,seclabel)
devpts on /dev/pts type devpts
(rw,nosuid,noexec,relatime,seclabel,gid=5,mode=620,ptmxmode=000)
tmpfs on /run type tmpfs (rw,nosuid,nodev,seclabel,mode=755)
tmpfs on /sys/fs/cgroup type tmpfs
(ro,nosuid,nodev,noexec,seclabel,mode=755)
cgroup on /sys/fs/cgroup/systemd type cgroup
(rw,nosuid,nodev,noexec,relatime,xat

Mount Points and /etc/fstab

Fstab
/etc/fstab -static information about the file systems

the fstab file contains descriptive information about the various file
systems. Each file system and its mounting information is described in
a seperate line.Fields on each line are delimited by tabs
Command:cat /etc/fstab
[root@server ~]# cat /etc/fstab

#
# /etc/fstab
/dev/sda17 /agoutam ext4 defaults 0 0
[root@server ~]#

Fstab fields :

Field 1: Local partition or remote file system to be mounted


Field 2: Mount point for the filesystem
Field 3: Types of Filesystem
Filed 4: Mount options associated with the filesystem
Field 5: Dump options [ 0 or 1].if set as 0 ,dump will assume that the
filesystem does not need to be dumped.If set as 1, the filesystem will
create a backup
field 6: fsck options [0,1, or 2]. Root filesystem "/" should always
be set as 1, and other filesystems should be set as 2 .filesystems
with fsck option set as 0 does not get checked

To re-read /etc/fstab entries and mount the mentioned filesystems


command :mount -a

To unmount all the filesystems mentioned in /etc/mtab


Command :umount -a

To view specific type of mounted filesystems


Command :mount -i -t ext4

[root@server ~]# cat /etc/fstab | grep sda17


/dev/sda17 /agoutam ext4 defaults 0 0

[root@server ~]# mount -i -t ext4


/dev/sda17 on /agoutam type ext4 (rw,relatime,seclabel,data=ordered)
[root@server ~]#

To Mount without writing entry into /etc/mtab


Command : mount -n /dev/sda17 /agoutam
[root@server ~]# mount -n /dev/sda17 /agoutam
[root@server ~]# mount |grep agoutam
/dev/sda17 on /agoutam type ext2 (rw,relatime,seclabel)
[root@server ~]#

Mount filesystem with read or read/write access


use -r to mount partitions as read only
Command :mount /dev/sda17 /agoutam -r

To Mount filesystem only read only, For example filesystem


/dev/sda6 is mount in Read-only.

[root@server ~]# mount /dev/sda17 /agoutam -r


[root@server ~]# mount |grep agoutam
/dev/sda17 on /agoutam type ext2 (ro,relatime,seclabel)
[root@server ~]#

use -r to mount partitions as read only

To Mount filesystem only read-write, For example filesystem


/dev/sda6 is mount in Read-write

[root@server ~]# mount /dev/sda17 /agoutam -rw


[root@server ~]# mount |grep agoutam
/dev/sda17 on /agoutam type ext2 (rw,relatime,seclabel)
[root@server ~]#

Remount the mounted filesystem


Command : mount -o ro,remount /agoutam
.

To mount with other permission , with mount command pass option -o


with permission.
To mount on read only mode to already mount Point data in Read only
mode

[root@localhost ~]# mount -o ro,remount /data


[root@localhost ~]# mount | grep data
/dev/sda6 on /data type ext4 (ro,relatime,seclabel,data=ordered)
[root@localhost ~]#

Unmounting Filesystems :
Command :umount /dev/sda17

[root@localhost ~]# umount /dev/sda17

You might also like