A Blog dedicated to Redhat Exam Certification Preparation,Get answers to your Linux questions. one stop source for people seeking the RHCE Linux Certifications.
RHCE RHCT Exam:Create and Mount filesystem in redhat enterprise Linux:
Redhat Enterprise 4 Linux you can use fdisk -l to list existing partitions on your system as a part of your Lab in RH133 Course :
[root@ice ~]# fdisk -l /dev/sda
Disk /dev/sda: 21.4 GB, 21474836480 bytes 255 heads, 63 sectors/track, 2610 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System /dev/sda1 * 1 13 104391 83 Linux /dev/sda2 14 1318 10482412+ 8e Linux LVM /dev/sda3 1319 1579 2096482+ 82 Linux swap /dev/sda4 1580 2610 8281507+ 5 Extended
Here we have unallocated extended partition . Remember you can have only 3 Primary partitions for a single disk in Redhat in our case we have SCSI disk /dev/sda where we have 3 primary partitions,with remaining unlloacted space you need to create Extended partition if you need to create more than 3 partitions .
#fdisk /dev/sda
ON COMMAND TYPE n to create new partition , hit enter for start cylinder number and then on last cyliner i used +1024M you can use +1G as well , because i am going to create 1 GB filesystem :
Command (m for help): n First cylinder (1580-2610, default 1580): Using default value 1580 Last cylinder or +size or +sizeM or +sizeK (1580-2610, default 2610): +1024M 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. Syncing disks.
Here is a catch that would be really stupid idea to reboot your Redhat enterprise Linux server to activate your partition table changes. I am sure Redhat will remove this warning in their upcoming redhat enterprise level 5 Linux version.Also you can save time in your RHCT/RHCE Certification Exam using partprobe. Note this how i am activating new partition table changes using PARTPROBE magic command.
[root@ice ~]# partprobe
[root@ice ~]# fdisk -l /dev/sda
Disk /dev/sda: 21.4 GB, 21474836480 bytes 255 heads, 63 sectors/track, 2610 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System /dev/sda1 * 1 13 104391 83 Linux /dev/sda2 14 1318 10482412+ 8e Linux LVM /dev/sda3 1319 1579 2096482+ 82 Linux swap /dev/sda4 1580 2610 8281507+ 5 Extended /dev/sda5 1580 1704 1004031 83 Linux
Now I have to create a directory where i need to mount new +1 GB fileystem i am going to make ext3 filesystem .
#mkdir /home
[root@ice ~]# mkfs -t ext3 /dev/sda5 [root@ice ~]# mount /dev/sda5 /home [root@ice ~]# df -h /home Filesystem Size Used Avail Use% Mounted on /dev/sda5 966M 18M 899M 2% /home
Here is your +1GB home filesystem (type is ext3) ready to use . you can add this in yout /etc/fstab file to make change permanent where it will mount /home automatically and persistent to server reboots.