Saturday, 19 March 2011

Add/Delete partition in Linux


Step by Step procedure to Add or Delete the partition in Linux
Simple Add of Partition
Login as root
# df –h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda3            7.0G  3.5G  3.1G  54% /
/dev/sda1            99M   13M   82M  14% /boot
/dev/sda4           7.0G  3.5G  3.1G  54% /usr
/dev/sda5           4.0G   113M   3.8G  8% /var
tmpfs                 501M     0  501M   0% /dev/shm
#fdisk –l               (To see the partition table)
# fdisk /dev/sda
n                           (Create new partition)
press enter       (cylinder space)
5000M              (Partition space)
P                           (Verify the partition)
w                           (Writing partition)
#partprobe
#mkfs.ext3 /dev/sda6
#e2label /dev/sda6 /test
#vi /etc/fstab (Set to start automatically after booting)
/dev /sda6  /data  ext3  defaults  0 0
#mount /dev/sda6 /test  (Mounting the partition)
#df –h
Now you can see your partition table
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda3            7.0G  3.5G  3.1G  54% /
/dev/sda1             99M   13M   82M  14% /boot
/dev/sda4           7.0G  3.5G  3.1G  54% /usr
/dev/sda5             4.0G   113M   3.8G  8% /var
/dev/sda6            5.0G   113M   4.8G  3% /test – New partition
tmpfs                 501M     0  501M   0% /dev/shm
Simple Delete a partition:
Login as root
# df –h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda3            7.0G  3.5G  3.1G  54% /
/dev/sda1             99M   13M   82M  14% /boot
/dev/sda4           7.0G  3.5G  3.1G  54% /usr
/dev/sda5             4.0G   113M   3.8G  8% /var
/dev/sda6            5.0G   113M   4.8G  3% /test   - the partition required to delete
tmpfs                 501M     0  501M   0% /dev/shm
Edit /etc/fstab configuration file
Comment “#”or delete mounting file of /dev/sda6
#vi /etc/fstab
#/dev/sda6  /test  ext3  defaults  0 0 (Here I gave comment “#”)
#umount /test                  (Unmount /test)
#fdisk –l
#fdisk /dev/sda
d                (delete the partition)
(1-6)   6   (Press which no of partition want to delete, here it is 6)
P
w
#partprobe
#fdisk –l
#df –h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda3            7.0G  3.5G  3.1G  54% /
/dev/sda1            99M   13M   82M  14% /boot
/dev/sda4           7.0G  3.5G  3.1G  54% /usr
/dev/sda5           4.0G   113M   3.8G  8% /var
tmpfs                 501M     0  501M   0% /dev/shm
Done………….

No comments:

Post a Comment