How to create and delete a partition
====================================
Device drivers for storage devices are created by kernel in /dev partition .
All storage devices are created as block devices .
eg: ls -l /dev/sda
brw-r----- 1 root disk 8, 0 Feb 23 2011 /dev/sda
#fdisk -cul <-- To identify the type of hard disk (sata / ide)
c= Turn off Compactibility for DOS
u= Disk Units displayed in Sectors
Note : GUI is preffered more than text cmds because the cmds are not always
capable of accurately updating the PT in kernel .
#fdisk -cu /dev/hda
a <-toggle a bootable flag
(activate and decativate a partition.
activation of a partition is maintained by magic key in mbr.)
c <-toggle the dos compatibility flag.
(i.e toggling of activatation & deactivation of a partition like dos)
d <-delete a partition *
l <-list know partition types (which are recognised by linux.)*
n <-to crate a new partition*
o <-create a new empty dos partition table.
s <-create a new empty 'sun solaris' partition.
u <-change display / entry units.
v <-verify unpartition free space *
(i.e. unallocated sectors)
(note. :- In GUI mode 'hwbrowser' to verify free space.)
w <-Save a partition table*
To create a new partition in ext3 .
#fdisk /dev/sda
Type:
:n
//Give the 1st cylinder as default
//Give the last cylinder as +1024M for 1G size .
:w
#partprobe -s <-Inform OS(kernel) of changed partition table.
The kernel create device driver files in /dev (eg. /dev/sda8 ) for the new partn
The above command does not work well in RHEL6.
Hence we use
#partx -a /dev/sda Kernel manipulates the PT
Format a newly created partition by using any of following commands.
------------------------------------------------------------------
#mkfs -t ext3 /dev/sda8 <- Old style of formatting a partition
#mkfs.ext4 /dev/sda8 <- New style of formatting a partition
Mount a partition
----------------
Create a mount point
#mkdir /mnt/mydisk
#mount -t ext4 /dev/sda8 /mnt/mydisk
OR
#mount /dev/sda8 /mnt/mydisk
#df -hT <- It will show partition space used and available along with file system type.
Automounting of a partition
--------------------------
#vi /etc/fstab
device mount file mount options dump file
driver point system system scan
====== ===== ===== =========== ==== ===========
/dev/vda3 /mnt/mydisk ext4 defaults 0 2
Device driver:
Device file path (/dev/vda3) OR
Device LABEL (LABEL=<label>) OR
Device UUID (UUID=<UUID>)
#blkid /dev/vda3
/dev/vda3: UUID="fac91da8-949f-4975-9ef6-9caefc6a265c" TYPE="ext4"
To search a disk by specifying UUID ,
#blkid -U fac91da8-949f-4975-9ef6-9caefc6a265c
/dev/vda3
defaults:- Uses the default options that are rw, suid, dev, exec, auto, nouser, and async
===============================================================================
Mount Options Field
auto <- To support all the file systems.
users <- All users are allowed to mount Rom
user <- Allow only one user who has mounted cd-rom & root to umount
cd-rom and not others.
Note : 'mount' command takes values from '/etc/mtab' file.
Creating Swap Partition by Partition and File level
==================================================
By Partition Size :-
-----------------
Create a partition and change a toggle key to 82
eg. newly created partition is /dev/hda8
#mkswap -v1 /dev/hda8 <-- Format a partition
#swapon -s <-- check current swap space
#free -m <-- show ram and swap size in MB
#swapon /dev/hda8 <-- turn on swap on /dev/hda8
#swapon -s <-- show increased swap size
#cat /proc/swaps <-- Show swap partitions currently used in a system
To automount in /etc/fstab
--------------------------
#vi /etc/fstab
/dev/vda3 swap swap defaults 0 0
===========================================================================
Maintaining Swap partition by FILE level :-
-----------------------------------------
Note :- It is used when no free space is available on hard disk and we want to increase swap partition
#df -h <-- Check free space
#free -m <-- Check ram and swap size before increasing swap
#dd if=/dev/zero of=/swapfile bs=500M count=1
#mkswap -v1 /swapfile
#swapon -v /swapfile
#chmod 600 /swapfile
#swapon -s <-- Show swap size.
====================================
Device drivers for storage devices are created by kernel in /dev partition .
All storage devices are created as block devices .
eg: ls -l /dev/sda
brw-r----- 1 root disk 8, 0 Feb 23 2011 /dev/sda
#fdisk -cul <-- To identify the type of hard disk (sata / ide)
c= Turn off Compactibility for DOS
u= Disk Units displayed in Sectors
Note : GUI is preffered more than text cmds because the cmds are not always
capable of accurately updating the PT in kernel .
#fdisk -cu /dev/hda
a <-toggle a bootable flag
(activate and decativate a partition.
activation of a partition is maintained by magic key in mbr.)
c <-toggle the dos compatibility flag.
(i.e toggling of activatation & deactivation of a partition like dos)
d <-delete a partition *
l <-list know partition types (which are recognised by linux.)*
n <-to crate a new partition*
o <-create a new empty dos partition table.
s <-create a new empty 'sun solaris' partition.
u <-change display / entry units.
v <-verify unpartition free space *
(i.e. unallocated sectors)
(note. :- In GUI mode 'hwbrowser' to verify free space.)
w <-Save a partition table*
To create a new partition in ext3 .
#fdisk /dev/sda
Type:
:n
//Give the 1st cylinder as default
//Give the last cylinder as +1024M for 1G size .
:w
#partprobe -s <-Inform OS(kernel) of changed partition table.
The kernel create device driver files in /dev (eg. /dev/sda8 ) for the new partn
The above command does not work well in RHEL6.
Hence we use
#partx -a /dev/sda Kernel manipulates the PT
Format a newly created partition by using any of following commands.
------------------------------------------------------------------
#mkfs -t ext3 /dev/sda8 <- Old style of formatting a partition
#mkfs.ext4 /dev/sda8 <- New style of formatting a partition
Mount a partition
----------------
Create a mount point
#mkdir /mnt/mydisk
#mount -t ext4 /dev/sda8 /mnt/mydisk
OR
#mount /dev/sda8 /mnt/mydisk
#df -hT <- It will show partition space used and available along with file system type.
Automounting of a partition
--------------------------
#vi /etc/fstab
device mount file mount options dump file
driver point system system scan
====== ===== ===== =========== ==== ===========
/dev/vda3 /mnt/mydisk ext4 defaults 0 2
Device driver:
Device file path (/dev/vda3) OR
Device LABEL (LABEL=<label>) OR
Device UUID (UUID=<UUID>)
#blkid /dev/vda3
/dev/vda3: UUID="fac91da8-949f-4975-9ef6-9caefc6a265c" TYPE="ext4"
To search a disk by specifying UUID ,
#blkid -U fac91da8-949f-4975-9ef6-9caefc6a265c
/dev/vda3
defaults:- Uses the default options that are rw, suid, dev, exec, auto, nouser, and async
===============================================================================
Mount Options Field
auto <- To support all the file systems.
users <- All users are allowed to mount Rom
user <- Allow only one user who has mounted cd-rom & root to umount
cd-rom and not others.
Note : 'mount' command takes values from '/etc/mtab' file.
Creating Swap Partition by Partition and File level
==================================================
By Partition Size :-
-----------------
Create a partition and change a toggle key to 82
eg. newly created partition is /dev/hda8
#mkswap -v1 /dev/hda8 <-- Format a partition
#swapon -s <-- check current swap space
#free -m <-- show ram and swap size in MB
#swapon /dev/hda8 <-- turn on swap on /dev/hda8
#swapon -s <-- show increased swap size
#cat /proc/swaps <-- Show swap partitions currently used in a system
To automount in /etc/fstab
--------------------------
#vi /etc/fstab
/dev/vda3 swap swap defaults 0 0
===========================================================================
Maintaining Swap partition by FILE level :-
-----------------------------------------
Note :- It is used when no free space is available on hard disk and we want to increase swap partition
#df -h <-- Check free space
#free -m <-- Check ram and swap size before increasing swap
#dd if=/dev/zero of=/swapfile bs=500M count=1
#mkswap -v1 /swapfile
#swapon -v /swapfile
#chmod 600 /swapfile
#swapon -s <-- Show swap size.
No comments:
Post a Comment