Tuesday, March 31, 2015

Partitions In linux with examples.

Partitions 

http://www.linuxserverworldadmin.blogspot.in/2015/03/what-is-disk-partitioning-in-linux.html

Step 1 ) To Create the partitions 

[root@client1 ~]# fdisk -l 
[root@client1 ~]# fdisk /dev/hda 
Command (m for help): m 
d     d elete a partition 
m   print this menu 
n     add a new partition 
p     p rint the partition table 
q     quit without saving changes 
w     write table to disk and exit 

Command (m for help): 

Command (m for help): n 
First cylinder (1098-2434, default 1098): Using default value 1098 
Last cylinder or +size or +sizeM or +sizeK (1098-2434, default 2434): 
+100M 
Command (m for help): p 
Command (m for help): n 
Command (m for help): p 
Command (m for help): n 
Command (m for help): p 
Command (m for help): d
Command (m for help): 10 partition
Command (m for help): w 
[root@client1 ~]#
To update the kernel without restarting
 [root@client1 ~]# partprobe /dev/hda
[root@client1 ~]# fdisk -l
#write the number of 


Step 2 ) Make the filesystem ( i.e format the partition) ext2, ext3, vfat 

[root@client1 ~]# mkfs.ext2 /dev/hda8 
[root@client1 ~]# mkfs.ext3 /dev/hda9 
[root@client1 ~]# mkfs.vfat /dev/hda10 

Step 3 ) Create a folder & Mount the partition to use 

[root@client1 ~]# mkdir /mnt/song /mnt/video /mnt/music 

[root@client1 ~]# mount /dev/hda8 /mnt/song 

[root@client1 ~]# mount /dev/hda9 /mnt/video 
[root@client1 ~]# mount /dev/hda10 /mnt/music 
[root@client1 ~]# mount 
Step 4 ) Write the data inside the partition 
[root@client1 ~]# cd /mnt/song 
[root@client1 song]# 
[root@client1 song]# touch myfile1 myfile2 myfile3 
[root@client1 song]# mkdir hyd sec bhills ameerpet 
*****************  This is the output  ******************** 
[root@client1 song]# ls 
ameerpet  bhills  hyd  lost+found  myfile1  myfile2  myfile3  sec [root@client1 myfolder]# 

Converting from ext3 to ext2 


[root@client1 ~]# umount /dev/hda8 

[root@client1 ~]# tune2fs -O ^has_journal /dev/hda8 [root@client1 ~]# mount /dev/hda8 /myfolder/ 
[root@client1 ~]# mount 
Convert from ext2 to ext3 
[root@client1 ~]# umount /dev/hda8 
[root@client1 ~]# tune2fs -j /dev/hda8 
[root@client1 ~]# mount /dev/hda8 /myfolder 
[root@client1 ~]# mount 

LABELS 

To check the label 
[root@client1 ~]# e2label /dev/hda8 
To assign the labels 
[root@client1 ~]# e2label /dev/hda8 linux 

[root@client1 ~]# e2label /dev/hda8 
linux 
Permanent Mounting 
Mounting the partition /dev/hda9 parmanently 
[root@client1 ~]# vi /etc/fstab 

LABEL=linux /myfolder ext3 defaults  0 0 

:wq 

[root@client1 ~]# mount 
[root@client1 ~]# mount -a
[root@client1 ~]# mount 
Mounting the cdrom 
[root@client1 ~]# mkdir /media/cdrom 
[root@client1 ~]# mount /dev/cdrom /media/cdrom 
To see the disk space 
[root@client1 ~]# df -h 
To see the block size

[root@client1 ~]# blockdev --getbsz /dev/hda8 
1024 

[root@client1 ~]# blockdev --getbsz /dev/hda3 

4096 




No comments:

Post a Comment