Advertisement
Guest User

Untitled

a guest
Feb 5th, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.46 KB | None | 0 0
  1. #identifying partitions and checking if they are unmounted
  2. > lsblk
  3. NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
  4. sdc 8:32 1 1.9G 0 disk
  5. |-sdc1 8:33 1 1G 0 part
  6. `-sdc2 8:34 1 910.5M 0 part
  7.  
  8. #identifying partition type, sector size, alignment, start and end blocks
  9. > gdisk /dev/sdc
  10. GPT fdisk (gdisk) version 0.8.5
  11.  
  12. Partition table scan:
  13. MBR: protective
  14. BSD: not present
  15. APM: not present
  16. GPT: present
  17.  
  18. Found valid GPT with protective MBR; using GPT.
  19.  
  20. Command (? for help): p
  21. Disk /dev/sdc: 3963904 sectors, 1.9 GiB
  22. Logical sector size: 512 bytes
  23. Disk identifier (GUID): D276E14A-5EB2-42FB-89DF-A742B6199BC3
  24. Partition table holds up to 128 entries
  25. First usable sector is 34, last usable sector is 3963870
  26. Partitions will be aligned on 2048-sector boundaries
  27. Total free space is 2014 sectors (1007.0 KiB)
  28.  
  29. Number Start (sector) End (sector) Size Code Name
  30. 1 2048 2099199 1024.0 MiB 8300 Linux filesystem
  31. 2 2099200 3963870 910.5 MiB 8300 Linux filesystem
  32.  
  33. Command (? for help): q
  34.  
  35. #resizing /dev/sdc1 to 100M
  36. > ntfsresize -s 100M /dev/sdc1
  37. ntfsresize v2012.1.15AR.5 (libntfs-3g)
  38. Failed to set locale, using default 'C'.
  39. Device name : /dev/sdc1
  40. NTFS volume version: 3.1
  41. Cluster size : 4096 bytes
  42. Current volume size: 1073738240 bytes (1074 MB)
  43. Current device size: 1073741824 bytes (1074 MB)
  44. New volume size : 99996160 bytes (100 MB)
  45. Checking filesystem consistency ...
  46. 100.00 percent completed
  47. Accounting clusters ...
  48. Space in use : 6 MB (0.5%)
  49. Collecting resizing constraints ...
  50. Needed relocations : 1412 (6 MB)
  51. WARNING: Every sanity check passed and only the dangerous operations left.
  52. Make sure that important data has been backed up! Power outage or computer
  53. crash may result major data loss!
  54. Are you sure you want to proceed (y/[n])? y
  55. Schedule chkdsk for NTFS consistency check at Windows boot time ...
  56. Resetting $LogFile ... (this might take a while)
  57. Relocating needed data ...
  58. 100.00 percent completed
  59. Updating $BadClust file ...
  60. Updating $Bitmap file ...
  61. Updating Boot record ...
  62. Syncing device ...
  63. Successfully resized NTFS on device '/dev/sdc1'.
  64. You can go on to shrink the device for example with Linux fdisk.
  65. IMPORTANT: When recreating the partition, make sure that you
  66. 1) create it at the same disk sector (use sector as the unit!)
  67. 2) create it with the same partition type (usually 7, HPFS/NTFS)
  68. 3) do not make it smaller than the new NTFS filesystem size
  69. 4) set the bootable flag for the partition if it existed before
  70. Otherwise you won't be able to access NTFS or can't boot from the disk!
  71. If you make a mistake and don't have a partition table backup then you
  72. can recover the partition table by TestDisk or Parted's rescue mode.
  73.  
  74. #calculating the new start of /dev/sdc2 in bytes (/dev/sdc1 start block)*(sector size)+(new size of /dev/sdc1 in bytes)
  75. > echo $((2048*512+100*1024*1024))
  76. 105906176
  77.  
  78. #calculating the new start of /dev/sdc2 in sectors (size in bytes)/(sector size)
  79. > echo $((105906176/512))
  80. 206848
  81.  
  82. #checking alignment (new start in sectors)%(alignment) 0=aligned, >0=not aligned
  83. > echo $((206848%2048))
  84. 0
  85.  
  86. #moving /dev/sdc2 to the left bs=(sector size), seek=(new start in sectors)
  87. dd if=/dev/sdc2 of=/dev/sdc bs=512 seek=206848
  88. 1864671+0 records in
  89. 1864671+0 records out
  90. 954711552 bytes (955 MB) copied, 80.6772 s, 11.8 MB/s
  91.  
  92. #resizing and moving partitions preserving GUIDs (start sector of /dev/sdc2 must match)
  93. > gdisk /dev/sdc
  94. GPT fdisk (gdisk) version 0.8.5
  95.  
  96. Partition table scan:
  97. MBR: protective
  98. BSD: not present
  99. APM: not present
  100. GPT: present
  101.  
  102. Found valid GPT with protective MBR; using GPT.
  103.  
  104. Command (? for help): i
  105. Partition number (1-2): 1
  106. Partition GUID code: 0FC63DAF-8483-4772-8E79-3D69D8477DE4 (Linux filesystem)
  107. Partition unique GUID: 359B474B-0EE0-46B5-A105-A57C1D60E863
  108. First sector: 2048 (at 1024.0 KiB)
  109. Last sector: 2099199 (at 1.0 GiB)
  110. Partition size: 2097152 sectors (1024.0 MiB)
  111. Attribute flags: 0000000000000000
  112. Partition name: 'Linux filesystem'
  113.  
  114. Command (? for help): i
  115. Partition number (1-2): 2
  116. Partition GUID code: 0FC63DAF-8483-4772-8E79-3D69D8477DE4 (Linux filesystem)
  117. Partition unique GUID: 93FD4BBB-F574-40D2-AC20-4FC162FDDEA3
  118. First sector: 2099200 (at 1.0 GiB)
  119. Last sector: 3963870 (at 1.9 GiB)
  120. Partition size: 1864671 sectors (910.5 MiB)
  121. Attribute flags: 0000000000000000
  122. Partition name: 'Linux filesystem'
  123.  
  124. Command (? for help): d
  125. Partition number (1-2): 1
  126.  
  127. Command (? for help): d
  128. Using 2
  129.  
  130. Command (? for help): n
  131. Partition number (1-128, default 1): 1
  132. First sector (34-3963870, default = 2048) or {+-}size{KMGTP}: 2048
  133. Last sector (2048-3963870, default = 3963870) or {+-}size{KMGTP}: +100M
  134. Current type is 'Linux filesystem'
  135. Hex code or GUID (L to show codes, Enter = 8300):
  136. Changed type of partition to 'Linux filesystem'
  137.  
  138. Command (? for help): n
  139. Partition number (2-128, default 2):
  140. First sector (34-3963870, default = 206848) or {+-}size{KMGTP}: 206848
  141. Last sector (206848-3963870, default = 3963870) or {+-}size{KMGTP}:
  142. Current type is 'Linux filesystem'
  143. Hex code or GUID (L to show codes, Enter = 8300):
  144. Changed type of partition to 'Linux filesystem'
  145.  
  146. Command (? for help): x
  147.  
  148. Expert command (? for help): c
  149. Partition number (1-2): 1
  150. Enter the partition's new unique GUID ('R' to randomize): 359B474B-0EE0-46B5-A105-A57C1D60E863
  151. New GUID is 359B474B-0EE0-46B5-A105-A57C1D60E863
  152.  
  153. Expert command (? for help): c
  154. Partition number (1-2): 2
  155. Enter the partition's new unique GUID ('R' to randomize): 93FD4BBB-F574-40D2-AC20-4FC162FDDEA3
  156. New GUID is 93FD4BBB-F574-40D2-AC20-4FC162FDDEA3
  157.  
  158. Expert command (? for help): p
  159. Disk /dev/sdc: 3963904 sectors, 1.9 GiB
  160. Logical sector size: 512 bytes
  161. Disk identifier (GUID): D276E14A-5EB2-42FB-89DF-A742B6199BC3
  162. Partition table holds up to 128 entries
  163. First usable sector is 34, last usable sector is 3963870
  164. Partitions will be aligned on 2048-sector boundaries
  165. Total free space is 2014 sectors (1007.0 KiB)
  166.  
  167. Number Start (sector) End (sector) Size Code Name
  168. 1 2048 206847 100.0 MiB 8300 Linux filesystem
  169. 2 206848 3963870 1.8 GiB 8300 Linux filesystem
  170.  
  171. Expert command (? for help): w
  172.  
  173. Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
  174. PARTITIONS!!
  175.  
  176. Do you want to proceed? (Y/N): y
  177. OK; writing new GUID partition table (GPT) to /dev/sdc.
  178. The operation has completed successfully.
  179.  
  180. #resizing /dev/sdc2 filesystem
  181. > resize2fs /dev/sdc2
  182. resize2fs 1.42.5 (29-Jul-2012)
  183. Resizing the filesystem on /dev/sdc2 to 469627 (4k) blocks.
  184. The filesystem on /dev/sdc2 is now 469627 blocks long.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement