Monday 6 June 2011

Create, mount, unmount and use ext2, ext3 and ext4 file systems

In order to create a file system, you need to use the command mkfs. Depending on filesystem type you can use:

mkfs.ext2 <devicename>
mkfs.ext3 <devicename>
mkfs.ext4 <devicename> 

Thus for instance, in order to create a ext4 filesystem with label MyLabel you would run the following command:

mkfs.ext4 /dev/sdc1 -L MyLabel

In order to mount this newly created filesystem to a directory called MyLabel, you would type:

mount /dev/sdc1 /MyLabel
or
mount -L MyLabel /MyLabel

Unmounting is done by the following command:

umount /MyLabel

Note that all of this mounting is temporary, so if you want to make it permanent, then you need to add it to the /etc/fstab file, e.g.

echo "LABEL=MyLabel /MyLabel ext4 defaults 1 2" >> /etc/fstab 

No comments:

Post a Comment