हेल्लो दोस्तों आज हम सीखते है की Linux System में कैसे Partition को create किया जाता है केसे Delete किया जाता है LInux server में partition create करना उनको माउंट करना Partition में data store करना storage management का एक बहुद महत्वपूण भाग है क्योकि partition के ऊपर ही Raid बनते है जो Data को residency provide करवाते है जिसके बारे में आगे के टुटोरिअल(Tutorial )में चर्चा करेगे तो यहाँ तक इस भाग में हमे only ये सीखना है की किस तरह से partition को Create किया जाता है और और Delate किया जाता है
1 . Heard Disk में ये देखने केलिए की कितना space खाली है व् कितने partition में क्या क्या Store ये देखने के लिए निचे लिखी Commands का use किया जाता है
[root@localhost ~]# fdisk -l Disk /dev/sda: 43.9 GB, 43965677568 bytes 255 heads, 63 sectors/track, 5345 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sda1 * 1 3187 25599546 83 Linux /dev/sda2 3188 4462 10241437+ 82 Linux swap [root@localhost ~]#
2. partition table में जाने के लिए हम निम्न Commands का use करते है
[root@localhost ~]# fdisk /dev/sda (यहाँ Sda Heard Disk का नाम है )
The number of cylinders for this disk is set to 5345.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
Command (m for help):
यहाँ Output में हमे Command (m for help): एक Command option दिख रहा है यहाँ M टाइप करके Enter दबाने पर partition से Related Help Command show होजाते है
3. partition टेबल में New partition create करने के लिए N press करते है
Command (m for help): n Command action e extended p primary partition (1-4)
यहाँ हमे 2 option दिख रे है e extended और p primary partition (1-4) यहाँ e press करना है जिससे एक Extended partition create होता है इसको हमे full size देनी होती है e press कर 2 बार Enter press पर यह पूरी size automatically calculate कर लेता है क्यों की बाकि सभी partition extended partition में ही Create होते है यहाँ हमे P press नहीं करना है P press करने पर primary partition create होते है जोकि System के लिए Reserve होते है
4. यहाँ हमे e प्रेस कर के दो बार enter Press करना है बिना कोई value दिए
Command (m for help): n Command action e extended p primary partition (1-4) e Partition number (1-4): 4 First cylinder (4463-5345, default 4463): Using default value 4463 Last cylinder or +size or +sizeM or +sizeK (4463-5345, default 5345):
5. partition Create होने के बाद हम p command के through देख सकते है की partition create हुवा है या नही
Command (m for help): p Disk /dev/sda: 43.9 GB, 43965677568 bytes 255 heads, 63 sectors/track, 5345 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sda1 * 1 3187 25599546 83 Linux /dev/sda2 3188 4462 10241437+ 82 Linux swap / /dev/sda4 4463 5345 7092697+ 5 Extended
अब हम यहाँ देखते है की एक Extended partition बना है /dev/sda4 अब हमे आगे जो भी partition बनाने है वो ऐसी process के through continue करेगे
6. यहाँ n के बाद Enter फिर L one time Enter और फिर + partition size Capital M (exp-+200M)
Command (m for help): n Command action l logical (5 or over) p primary partition (1-4) l First cylinder (4463-5345, default 4463): Using default value 4463 +sizeM or +sizeK (4463-5345, default 5345): +200 Command (m for help): n Command action l logical (5 or over) p primary partition (1-4) l First cylinder (4664-5345, default 4664): Using default value 4664 \ +sizeM or +sizeK (4664-5345, default 5345): +200M Command (m for help): n Command action l logical (5 or over) p primary partition (1-4)
7. अब हम यहाँ देखते है P Commands से हमारे द्वारा बनाये गए partition को
Command (m for help): p
Disk /dev/sda: 43.9 GB, 43965677568 bytes
255 heads, 63 sectors/track, 5345 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 3187 25599546 83 Linux
/dev/sda2 3188 4462 10241437+ 82 Linux swap
/dev/sda4 4463 5345 7092697+ 5 Extended
/dev/sda5 4463 4663 1614501 83 Linux
/dev/sda6 4664 4688 200781 83 Linux
8. अब partition को Save करने के लिए W commands का use करते से
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
यहाँ हम देखते है की Linux kernal में Warning होती है की ये Old partition table को ही read करे गा अगर आप चाहते है की new partition table को read करे तो system को reboot करे पर हम real server को ऐसे छोटे से काम के लिए Reboot नही कर सकते अगर Reboot किया तो वहा company में बहुद सारा work server पर हो रहा होता है वो Server को reboot करने से सभी Disturb हो जाये गा तो इस समस्या के समाधान के लिए हमे only partition table को ही karnel के लिए refresh कर सकते है partprobe command से
9. partition table को refresh किया जाता है निम्न Command से
[root@localhost ~]# partprobe /dev/sda
इस commands से वो Particular heard disk /dev/sda की वो partition table ही refresh होगी
partition बनने के बाद इनको किसी directory में MOUNT करना होता और इनको mount करने से पहले format करना आवश्यक होता है
10.निम्न Commands से partition को फॉर्मेट किया जाता है
[root@localhost ~]# mkfs.ext3 /dev/sda5
[root@localhost ~]# mkfs.ext3 /dev/sda6
[root@localhost ~]# mkfs.ext3 /dev/sda7
[root@localhost ~]# mkfs.ext3 /dev/sda5 mke2fs 1.39 (29-May-2006) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) 202176 inodes, 403625 blocks 20181 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=415236096 13 block groups 32768 blocks per group, 32768 fragments per group 15552 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912 Writing inode tables: done Creating journal (8192 blocks): done Writing superblocks and filesystem accounting information: done This filesystem will be automatically checked every 37 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override. [root@localhost ~]# mkfs.ext3 /dev/sda6 mke2fs 1.39 (29-May-2006) Filesystem label= OS type: Linux Block size=1024 (log=0) Fragment size=1024 (log=0) 50200 inodes, 200780 blocks 10039 blocks (5.00%) reserved for the super user First data block=1 Maximum filesystem blocks=67371008 25 block groups 8192 blocks per group, 8192 fragments per group 2008 inodes per group Superblock backups stored on blocks: 8193, 24577, 40961, 57345, 73729 Writing inode tables: done Creating journal (4096 blocks): done Writing superblocks and filesystem accounting information: done This filesystem will be automatically checked every 38 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override. [root@localhost ~]# mkfs.ext3 /dev/sda7 mke2fs 1.39 (29-May-2006) Filesystem label= OS type: Linux Block size=1024 (log=0) Fragment size=1024 (log=0) 50200 inodes, 200780 blocks 10039 blocks (5.00%) reserved for the super user First data block=1 Maximum filesystem blocks=67371008 25 block groups 8192 blocks per group, 8192 fragments per group 2008 inodes per group Superblock backups stored on blocks: 8193, 24577, 40961, 57345, 73729 Writing inode tables: done Creating journal (4096 blocks): done Writing superblocks and filesystem accounting information: done This filesystem will be automatically checked every 35 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override.
11. partition format के बाद इनको किसी Directory में mount करना होता है तो एक directory बनाते है Data1 है नाम से
[root@localhost ~]# mkdir /data1
12. अब इनको निम्न Commands से mount करते है
[root@localhost ~]# mount /dev/sda5 /data1
[root@localhost ~]# mount /dev/sda6 /data1
[root@localhost ~]# mount /dev/sda7 /data1
अब हम चाहते है की हमारा Server अगर future में कबिभी Reboot हो तो जो हमने partition की mounting की है वो बनी रहे तो हमे इनको permanently mount करने की आवश्यक ता होती है /etc/fstab में
13. permanent mounting /etc/fstab में निम्न प्रकार से की जाती है
[root@localhost ~]# vim /etc/fstab
LABEL=/ / ext3 defaults 1 1 tmpfs /dev/shm tmpfs defaults 0 0 devpts /dev/pts devpts gid=5,mode=620 0 0 sysfs /sys sysfs defaults 0 0 proc /proc proc defaults 0 0 LABEL=SWAP-sda2 swap swap defaults 0 0 /dev/sda5 /data1 ext3 defaults 0 0 /dev/sda6 /data1 ext3 defaults 0 0 /dev/sda7 /data1 txt3 defaults 0 0 ~ ~ ~ ~ :wq
(note- /etc/fsab में (i) perss कर insert mod में जाते है और partition का mounting path लिखने के बाद फाइल को Save करने के लिए (Esc) Press करते है फिर (:) Press करते है और wq type कर Enter press करने से file Save हो जाती है)
partitionकोremove/Deleteकेसे करे
दोस्तों partition को Remove करनेके लिए हमे जस्ट उल्टा process follow करना पड़ता है अगर हम partition table में जाकर direct partition को delete करते है तो यह ठीक नही है क्यों की ऐसा किया तो Server पर next time partition बनाने में कोई भी Error आ सकती है
तो हम निम्न Process follow करते है
1 . सबसे पहले हमे /etc/fstab में जाकर mounting path को डिलीट करना होता है
2 . फिर directory से umount करना होता है निम्न Commands से
[root@localhost ~]# umount /data1
3 .अब partition टेबल में जाकर निम्न Process follow करते है
fdisk /dev/sda partition table में जाकर d press करते है जिस partition को delete करना होता है उसका Number लिखना होता है जैसे -7 ,6 ,5 इस तरह से हर partition को एक -एक कर delete करना होता है
[root@localhost ~]# fdisk /dev/sda The number of cylinders for this disk is set to 5345. There is nothing wrong with that, but this is larger than 1024, and could in certain setups cause problems with: 1) software that runs at boot time (e.g., old versions of LILO) 2) booting and partitioning software from other OSs (e.g., DOS FDISK, OS/2 FDISK) Command (m for help): d Partition number (1-7): 7 Command (m for help): d Partition number (1-6): 6 Command (m for help): d Partition number (1-5): 5 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.
4.और यहाँ हम fdisk -l ,Commands के through देखते है की partition delete हुए है या नही
[root@localhost ~]# fdisk -l Disk /dev/sda: 43.9 GB, 43965677568 bytes 255 heads, 63 sectors/track, 5345 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sda1 * 1 3187 25599546 83 Linux /dev/sda2 3188 4462 10241437+ 82 Linux swap /dev/sda4 4463 5345 7092697+ 5 Extended
5. और फिर इसको Partprobe command के through kernel के लिए partition table को refresh करते है
[root@localhost ~]# partprobe /dev/sda
इस तरह से हम partition को Create और delete कर सकते है अगर आप को इस पूरे process में कोई problem आती है तो Comments करे में आप की problems को solve करुगा और अगर आप को मेरे द्वारा लिखा गया Tutorial /लेख अच्छा लगा होतो Like करे Share करे और Follow हिंदी आईटी.सलूशन जब भी कोई article या publish करेगी आप को E-Mail प्राप्त हो जाये गा
धन्यवाद
Writer -Vishnu Sharma