Archive

Posts Tagged ‘lvcreate’

Linux – Create Filesystem


On Linux you can create a filesystem using the command line as follows:

# lvcreate -n <log volume name> --size <size> <volume group>
# mkdir <filesystem name>
# mkfs.ext2 -v <log volume full name>
# mount -t ext2 <log volume full name>

Full Example:

# lvcreate -n LogVol24 --size 1G VolGroup00
# mkdir /icdev3f/flash_recovery_area
# mkfs.ext2 -v /dev/VolGroup00/LogVol24
# mount -t ext2 /dev/VolGroup00/LogVol24

Linux – Create new filesystem on Linux using lvcreate, mke2fs, tune2fs, mkdir, and mount

June 17, 2011 1 comment

Linux allows you to create a new filesystem on a new logical volume, this helps separate out different sections of the disk as well as making it easier to maintain. If you had all the data on a disk held under one bucket filesystem, you could have your log files filling up a section and not notice until it were too late.

Create new logical volume

To create a new logical volume you need to use the lvcreate command as follows:

$ lvcreate --size 10G --name LogVol21 VolGroup01

lvcreate flags

lvcreate

The command line command to issue to start the creation of a logical volume.

--size 10G

Specifies how big you wish the logical volume to be.

--name LogVol21

The name of the new logical volume. Without this option the name is given a default of lvol# where # is the LVM internal number of the logical volume.

VolGroup01

The name of the volume group to create the logical volume within.

Create an ext2/3 filesystem

The next step is to create an ext2/3 filesystem as follows:

mke2fs -j -L /sawprd /dev/VolGroup01/LogVol21

Mke2fs flags

mke2fs

The command to enter on the command line to create an ext2/3 filesystem

-j

Create the filesystem with an ext3 journal. You must be using a kernel with ext3 support to make use of the journal. If this is omitted then the default journal parameters will be used to create an appropriate sized journal stored within the filesystem.

-L /sawprd

Set the volume label for the filesystem.

/dev/VolGroup01/LogVol21

The name of the logical volume where the filesystem should be created.

Adjust tuneable filesystem parameters on ext2/3 filesystems

Next tune the filesystem with the following command:

tune2fs -c 0 -i 0 /dev/VolGroup01/LogVol21

Tune2fs flags

tune2fs

Run the tune2fs command from the command line

-c 0

Adjust the number of mounts after which a filesystem will be checked by e2fsck. If max mount-counts is 0 or -1 then the number of times the filesystem has been mounted will be disregarded by e2fsck and the kernel.

-i 0

Adjust the maximum time between two filesystem checks . A value of 0 will disable the time-dependant checking.

Write new filesystem entry to /etc/fstab

Next force a write of the new filesystem entry to /etc/fstab:

echo "/dev/VolGroup01/LogVol21 /sawprd ext3 defaults 1 2" >> /etc/fstab

Make sure the get the right spacing between values in this statement so everything stays legible in fstab

Make the directory

Next make the directory for the filesystem:

mkdir -p /sawprd

Mkdir flags

-p

Create any missing intermediate pathname components.

Mount the new filesystem

For the new filesystem to be visible you need to mount it with the following command:

mount /sawprd