Advertisement
v1ral_ITS

multi partition terminal fdisk ( commands )

Feb 7th, 2018
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.35 KB | None | 0 0
  1.  Example:
  2.  
  3. I start fdisk from the shell prompt:
  4.  
  5.  
  6. # fdisk /dev/hdb
  7.  
  8. which indicates that I am using the second drive on my IDE controller. (See Section 2.1.) When I print the (empty) partition table, I just get configuration information.
  9.  
  10.  
  11. Command (m for help): p
  12.  
  13. Disk /dev/hdb: 64 heads, 63 sectors, 621 cylinders
  14. Units = cylinders of 4032 * 512 bytes
  15.  
  16. I knew that I had a 1.2Gb drive, but now I really know: 64 * 63 * 512 * 621 = 1281982464 bytes. I decide to reserve 128Mb of that space for swap, leaving 1153982464. If I use one of my primary partitions for swap, that means I have three left for ext2 partitions. Divided equally, that makes for 384Mb per partition. Now I get to work.
  17.  
  18.  
  19. Command (m for help): n
  20. Command action
  21.    e   extended
  22.    p   primary partition (1-4)
  23. p
  24. Partition number (1-4): 1
  25. First cylinder (1-621, default 1):<RETURN>
  26. Using default value 1
  27. Last cylinder or +size or +sizeM or +sizeK (1-621, default 621): +384M
  28.  
  29. Next, I set up the partition I want to use for swap:
  30.  
  31.  
  32. Command (m for help): n
  33. Command action
  34.    e   extended
  35.    p   primary partition (1-4)
  36. p
  37. Partition number (1-4): 2
  38. First cylinder (197-621, default 197):<RETURN>
  39. Using default value 197
  40. Last cylinder or +size or +sizeM or +sizeK (197-621, default 621): +128M
  41.  
  42. Now the partition table looks like this:
  43.  
  44.  
  45.    Device Boot    Start       End    Blocks   Id  System
  46. /dev/hdb1             1       196    395104   83  Linux
  47. /dev/hdb2           197       262    133056   83  Linux
  48.  
  49. I set up the remaining two partitions the same way I did the first. Finally, I make the first partition bootable:
  50.  
  51.  
  52. Command (m for help): a
  53. Partition number (1-4): 1
  54.  
  55. And I make the second partition of type swap:
  56.  
  57.  
  58. Command (m for help): t
  59. Partition number (1-4): 2
  60. Hex code (type L to list codes): 82
  61. Changed system type of partition 2 to 82 (Linux swap)      
  62. Command (m for help): p
  63.  
  64. The end result:
  65.  
  66.  
  67. Disk /dev/hdb: 64 heads, 63 sectors, 621 cylinders
  68. Units = cylinders of 4032 * 512 bytes
  69.  
  70.    Device Boot    Start       End    Blocks   Id  System
  71. /dev/hdb1   *         1       196    395104+  83  Linux
  72. /dev/hdb2           197       262    133056   82  Linux swap
  73. /dev/hdb3           263       458    395136   83  Linux
  74. /dev/hdb4           459       621    328608   83  Linux          
  75.  
  76. Finally, I issue the write command (w) to write the table on the disk.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement