Monday, November 18, 2013

ලිනක්ස් මත fdisk හා වින්ඩෝස් මත DiskPart . . .



           වෙලාව ලැබුනම ලියන්න හිතුනා පෝස්ටුවක්. කමෙන්ට් නොකලට අනිත් බ්ලොග් අඩවි මම වෙලාවෙ හැටියට කියවනවා. සින්ඩිවලින් මාව එලියට විසි කරන්නත් බැරි නෑ නොලියම හිටියොත්. මට මෑතකදි ගොඩක් වැදගත් වුනා Windows වල එන DiskPart හා Linux වල නම් fdisk, parted කියන text-mode command එක.   පාටිෂන් create කිරීමට, destroy, resize, move and copy ext2, ext3, linux-swap ආදී reorganising සඳහාත්, write protected හින්දා format කරන්න බෑ කියන වෙලාවට,  GRUB එක ප්‍රතිස්ථාපනය කරන්න ඕන වෙනකොට, Ubuntu, Linux startup disk එකක් හදන්න ඕන වෙනකොට , නැත්නම් එහෙම හදන්න ගිහින් ඇනගත්තාම - Partition table එක නැවත සකස් කිරීම සඳහා හොඳම text-mode commands තමයි මේ.

Linux මත fdisk

Linux වලදී root විදිහට log වෙන්න ඕන. fdisk වල මූලික කමාන්ඩ් කිහිපය.

p print the partition table

n create a new partition
d delete a partition
q quit without saving changes
w write the new partition table and exit

 මතක තියාගන්න ඕන කරුණක් තමයි මොන විදිහේ වෙනස්කමක් වුනත් write(w) කමාන්ඩ් එක නැතුව apply වෙන්නේ නෑ කියන එක.
 
[root@localhost rathei]# fdisk -l

Disk /dev/sda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000d0e0f

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1        2356    18922496   83  Linux
/dev/sda2            2356        2611     2048000   82  Linux swap / Solaris

ඔන්න ඔහොමයි අපි partition table එක list කරගන්නේ.  linux දාලා තියෙන හාඩ් ඩිස්ක් එක වගේම boot loader(GRUB) තියෙන පාටිෂන් එකත් මෙයින් පෙන්නනවා.  ( 255 heads * 63 sectors * 512 bytes/sector විදිහටයි මේ සම්පූර්ණ ඉඩ ප්‍රමාණය හැදෙන්නේ) මේ calculation එක සම්බන්ධව ගැටලුවක් තියනව නම් මෙතෙන්ට යන්න.
             දැන් අපි දන්නවා අපිට තියෙන drives ගැන තොරතුරු. /dev/sda1 කියල මෙතනදි තෝරලා තියෙන්නේ මට අවශ්‍ය විස්තර බලාගන්න ඕන ඩිස්ක් එක. මෙන්න මේ විදිහට. p එකෙන් කරන්නේ print disk details යන්න ක්‍රියාත්මක කරන එක. හෙල්ප් එකක් ගන්න ඕන නම් කිසිම අවුලක් නෑ  m කියල ගැහුව නම් බෑ නොකියා උදව්වක් ගන්නත් පුලුවන් fdisk මතදී.

[root@localhost rathei]# fdisk /dev/sda1
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x60245473.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
         switch off the mode (command 'c') and change display units to
         sectors (command 'u').

Command (m for help): p

Disk /dev/sda1: 19.4 GB, 19376635904 bytes
255 heads, 63 sectors/track, 2355 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x60245473

අපිට මේ n කමාන්ඩ් එක හරහා නියමිත වූ අගයක් දීල අලුතෙන් පාටිෂන් එකක් හදන්න පුලුවන්.

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-2355, default 1): 
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-2355, default 2355):  
Using default value 2355

(මෙතනදි අපිට අගයන් විදි දෙකකට ලබා දෙන්න පුලුවන්)
1. Starting cylinder number of the partition to be create (First cylinder).
2. Size of the partition (or) the last cylinder number (Last cylinder, +cylinders or +size ).

# fdisk /dev/sda                                                 

The number of cylinders for this disk is set to 9729.
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): p

Disk /dev/sda: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0xf6edf6ed

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1        1959    15735636    c  W95 FAT32 (LBA)
/dev/sda2            1960        5283    26700030    f  W95 Ext'd (LBA)
/dev/sda3            5284        6528    10000462+   7  HPFS/NTFS
/dev/sda4            6529        9729    25712032+   c  W95 FAT32 (LBA)
/dev/sda5   *        1960        2661     5638752   83  Linux
/dev/sda6            2662        2904     1951866   83  Linux
/dev/sda7            2905        3147     1951866   83  Linux
/dev/sda8            3148        3264      939771   82  Linux swap / Solaris
/dev/sda9            3265        5283    16217586    b  W95 FAT32

Command (m for help): d
Partition number (1-9): 8

Command (m for help): d
Partition number (1-8): 7

Command (m for help): d
Partition number (1-7): 6

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 or after you run partprobe(8) or kpartx(8)
Syncing disks.

හැම කමාන්ඩ් එකකටම පස්සේ ඒවා ක්‍රියාත්මක වෙන්න නම්  w දෙන්න ඕන. නැත්නම් අපි කරපු දේවල් apply වෙන්නේ නැහැ.

View the Size of an existing Partition Using fdisk -s

# fdisk -s /dev/sda7
18922496

ආසන්න වශයෙන් 18000 mb ක්.

ඒවගේමයි ලිනක්ස්වලදි අපිට parted කියන ටෙක්ස්ට්මෝඩ් ඉන්ටර්ෆේස් එකත් මේ සඳහා  භාවිතා කරන්න පුලුවන්.

[root@localhost dev]# parted --list
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sda: 21.5GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start   End     Size    Type     File system     Flags
 1      1049kB  19.4GB  19.4GB  primary  ext4            boot
 2      19.4GB  21.5GB  2097MB  primary  linux-swap(v1)

#man parted ටර්මිනල් එකේ දුන්නාම සියලු විස්තර බලාගන්න පුලුවන්.


 Windows මතදී  diskpart

cmd එකේ diskpart කියල දුන්නනම් ටක් ගාලා ඕපන් වෙනවා diskpart කියලා වෙනම command line interface එකක් මෙන්න මේ විදිහට.

C:\diskpart

Microsoft DiskPart version 1.0
Copyright (C) 1999-2001 Microsoft Corporation.
On computer: IMT-BOL214-LAPT

DISKPART>

තවදුරටත් මේ ගැන විස්තර හොයලම ඉන්නව නම් ? ටයිප් කරලා එන්ටර් කරන්න මේ විදිහට.

DISKPART>?

Microsoft DiskPart version 1.0

ADD         - Add a mirror to a simple volume.
ACTIVE      - Activates the current basic partition.
ASSIGN      - Assign a drive letter or mount point to the selected volume.
BREAK       - Break a mirror set.
CLEAN       - Clear the configuration information, or all information, off the
              disk.
CONVERT     - Converts between different disk formats.
CREATE      - Create a volume or partition.
DELETE      - Delete an object.
DETAIL      - Provide details about an object.
EXIT        - Exit DiskPart
EXTEND      - Extend a volume.
HELP        - Prints a list of commands.
IMPORT      - Imports a disk group.
LIST        - Prints out a list of objects.
ONLINE      - Online a disk that is currently marked as offline.
REM         - Does nothing. Used to comment scripts.
REMOVE      - Remove a drive letter or mount point assignment.
RESCAN      - Rescan the computer looking for disks and volumes.
RETAIN      - Place a retainer partition under a simple volume.
SELECT      - Move the focus to an object.

මුලින්ම අපි මෙහිදී දැනට සම්බන්ධ කරලා තියෙන  disks list එක ගන්න ඕන මේ විදිහට.  එවගේමයි  Volume List එකත් ගන්න පුලුවන් මේ විදිහට.




DISKPART
> list disk

  Disk ###  Status      Size     Free     Dyn  Gpt
  --------  ----------  -------  -------  ---  ---
  Disk 0    Online        465 GB      0 B
  Disk 1    Online        465 GB      0 B
  Disk 2    Online        465 GB      0 B
  Disk 3    Online        235 GB      0 B
  Disk 4    Online         14 GB      0 B
  Disk 5    No Meida        0 B       0 B

දැන් අපි හිතමු කරප්ට් වෙලා තියෙන ඩිස්ක් එකක් හරි අන්රීඩබල් විදිහට තියෙන Volume එකක් හරි සිලෙක්ට් කරගන්න ඕන කියලා. ඒ සඳහා ඩිස්කයට හෝ  Volume එකට අදාල අංකය මේ විදිහට තෝරන්න ඕන.

DISKPART
>  select disk 0 (Volume එක නම් select volume 6 විදිහට)

Disk 4 is now the selected disk.

මම තේරුවේ disk 4 කියලා අර උඩින්ම තියෙන 14 GB ක ඩිස්ක් එක.

Format කරනව නම් “format fs=ntfs quick label=test” විදිහට දෙන්න පුලුවන්.Drive Letter එකක්  assign කරනව නම් “assign letter ” විදිහට, Clean කරනව නම් clean විදිහට, primary partition එකක් දැනට ඉන්න ඩිස්කයේ හදාගන්නව නම් “create partition primary” විදිහට, මකා දැමීමට නම් DISKPART> /delete (X): 
DISKPART වලින් ඉවත් වෙනව නම් ,

DISKPART
> exit

Leaving DiskPart...

C:\
> ;

DISKPART ගැන තවත් විස්තර
http://www.computerhope.com/diskpart.htm
http://technet.microsoft.com/en-us/library/cc770877.aspx

11 comments:

  1. root විදිහට log වෙලා කරන සෙල්ලං මට තාම නිකං ග්‍රීක් වාගේ . මොනවාහරි අළුත් සොෆ් එකක් බාගන ඇතුලට රිංගවන්ඩ උනත් හෙන අවුල් කාගෙන් හරි දවසක් දාගන අහගන්ඩ ඕන . කරුමේ කියන්නේ අහල පහල ඉන්න ඔක්කොම යමක් කමක් දන්න ලිනක්ස් කාරයෝ ඔක්කොම පට්ට බිසි

    ReplyDelete
    Replies
    1. ඕනම දෙයක් ටික ටික තමා පුරුදු වෙන්නේ සහෝ...මමත් ලිනක්ස් අත්පොත් තියලා ඒ හැටි කාලයක් නෑ. වැරදි වැරදි තමයි ගොඩ දාගන්නේ හැම දෙයක්ම.

      Delete
    2. සහෝගෙ email එක මට මෙතනින් දාන්න මා ගාව තියෙන ලිනක්ස් නෝට්ස් සියල්ල මම එවන්නම්. සෑහෙන පන්නරයක් ඒවයෙන් අරගන්න පුලුවන් ලිනක්ස් සම්බන්ධව.

      Delete
    3. Admin, matat denna puluwanda oya notes tika?
      hacker.fb.94@gmail.com

      Delete
  2. රතී.....මේ ලිපිය බොහෝ අයට වැදගත් වෙයි...මම කියෙව්වේ නැහැ...මට ලැටින් තේරෙන්නේ නැහැ දරුවෝ.

    ReplyDelete
  3. ලැටින් නෙමෙයි මහත්මයා මෙතන තියෙන්නේ. ලිනක්ස් පැත්තට පොඩ්ඩම පොඩ්ඩක් බර වුනා නම් මේව නියම සිංහල විදිහටම තේරුම් යනවා. ඔබතුමාටත් බොහොම ස්තුතියි ගොඩ වැදිලා යන්න ආවට.

    ReplyDelete
  4. ithaama sthoothiyi rathi mewani lipi liweema gana ....

    ReplyDelete
  5. godak watina deyak ...
    open source gana igena ganna kale hari wage!

    ReplyDelete