Redhat:Filesystem Commands

From Define Wiki
Revision as of 15:18, 6 September 2013 by Michael (talk | contribs) (Created page with "== File System Format Commands == Linux provides commands to create a filesystem. They are all based on mkfs <syntaxhighlight> mkfs.ext mkfs.ext2 mkfs.ext3 mkfs.ext4 mkfs.xfs </syntaxhighlight> ...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

File System Format Commands

Linux provides commands to create a filesystem. They are all based on mkfs

mkfs.ext
mkfs.ext2
mkfs.ext3
mkfs.ext4
mkfs.xfs

To create a file system, make sure that the partition is umounted and then run the mkfs command

mkfs.ext4 /dev/sdb1
mkfs -t ext4 /dev/sdb1

Swap Volumes

The mkswap command is used to format a swap parition. But then it must be activated using the swapon command.

File System Check Commands

To check a filesystem and perform any repairs needed use the fsck command. To do this umount the file system, this may require you to boot into single user mode.

File System Conversion Commands

To convert a file system from ext2 to ext3 for example, it must be remounted as read only before adding the journaling using the tune2fs command.

mount -o remount,ro /dev/vda1
tune2fs -j /dev/vda1
mount -o remount,rw /dev/vda1

To move to ext4, some other features must be added.

mount -o remount,ro /dev/vda1
tune2fs -O extent,uninit_bg,dir_index /dev/vda1
mount -o remount,rw /dev/vda1