Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #identifying partitions and checking if they are unmounted
- > lsblk
- NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
- sdc 8:32 1 1.9G 0 disk
- |-sdc1 8:33 1 1G 0 part
- `-sdc2 8:34 1 910.5M 0 part
- #identifying partition type, sector size, alignment, start and end blocks
- > gdisk /dev/sdc
- GPT fdisk (gdisk) version 0.8.5
- Partition table scan:
- MBR: protective
- BSD: not present
- APM: not present
- GPT: present
- Found valid GPT with protective MBR; using GPT.
- Command (? for help): p
- Disk /dev/sdc: 3963904 sectors, 1.9 GiB
- Logical sector size: 512 bytes
- Disk identifier (GUID): D276E14A-5EB2-42FB-89DF-A742B6199BC3
- Partition table holds up to 128 entries
- First usable sector is 34, last usable sector is 3963870
- Partitions will be aligned on 2048-sector boundaries
- Total free space is 2014 sectors (1007.0 KiB)
- Number Start (sector) End (sector) Size Code Name
- 1 2048 2099199 1024.0 MiB 8300 Linux filesystem
- 2 2099200 3963870 910.5 MiB 8300 Linux filesystem
- Command (? for help): q
- #resizing /dev/sdc1 to 100M
- > ntfsresize -s 100M /dev/sdc1
- ntfsresize v2012.1.15AR.5 (libntfs-3g)
- Failed to set locale, using default 'C'.
- Device name : /dev/sdc1
- NTFS volume version: 3.1
- Cluster size : 4096 bytes
- Current volume size: 1073738240 bytes (1074 MB)
- Current device size: 1073741824 bytes (1074 MB)
- New volume size : 99996160 bytes (100 MB)
- Checking filesystem consistency ...
- 100.00 percent completed
- Accounting clusters ...
- Space in use : 6 MB (0.5%)
- Collecting resizing constraints ...
- Needed relocations : 1412 (6 MB)
- WARNING: Every sanity check passed and only the dangerous operations left.
- Make sure that important data has been backed up! Power outage or computer
- crash may result major data loss!
- Are you sure you want to proceed (y/[n])? y
- Schedule chkdsk for NTFS consistency check at Windows boot time ...
- Resetting $LogFile ... (this might take a while)
- Relocating needed data ...
- 100.00 percent completed
- Updating $BadClust file ...
- Updating $Bitmap file ...
- Updating Boot record ...
- Syncing device ...
- Successfully resized NTFS on device '/dev/sdc1'.
- You can go on to shrink the device for example with Linux fdisk.
- IMPORTANT: When recreating the partition, make sure that you
- 1) create it at the same disk sector (use sector as the unit!)
- 2) create it with the same partition type (usually 7, HPFS/NTFS)
- 3) do not make it smaller than the new NTFS filesystem size
- 4) set the bootable flag for the partition if it existed before
- Otherwise you won't be able to access NTFS or can't boot from the disk!
- If you make a mistake and don't have a partition table backup then you
- can recover the partition table by TestDisk or Parted's rescue mode.
- #calculating the new start of /dev/sdc2 in bytes (/dev/sdc1 start block)*(sector size)+(new size of /dev/sdc1 in bytes)
- > echo $((2048*512+100*1024*1024))
- 105906176
- #calculating the new start of /dev/sdc2 in sectors (size in bytes)/(sector size)
- > echo $((105906176/512))
- 206848
- #checking alignment (new start in sectors)%(alignment) 0=aligned, >0=not aligned
- > echo $((206848%2048))
- 0
- #moving /dev/sdc2 to the left bs=(sector size), seek=(new start in sectors)
- dd if=/dev/sdc2 of=/dev/sdc bs=512 seek=206848
- 1864671+0 records in
- 1864671+0 records out
- 954711552 bytes (955 MB) copied, 80.6772 s, 11.8 MB/s
- #resizing and moving partitions preserving GUIDs (start sector of /dev/sdc2 must match)
- > gdisk /dev/sdc
- GPT fdisk (gdisk) version 0.8.5
- Partition table scan:
- MBR: protective
- BSD: not present
- APM: not present
- GPT: present
- Found valid GPT with protective MBR; using GPT.
- Command (? for help): i
- Partition number (1-2): 1
- Partition GUID code: 0FC63DAF-8483-4772-8E79-3D69D8477DE4 (Linux filesystem)
- Partition unique GUID: 359B474B-0EE0-46B5-A105-A57C1D60E863
- First sector: 2048 (at 1024.0 KiB)
- Last sector: 2099199 (at 1.0 GiB)
- Partition size: 2097152 sectors (1024.0 MiB)
- Attribute flags: 0000000000000000
- Partition name: 'Linux filesystem'
- Command (? for help): i
- Partition number (1-2): 2
- Partition GUID code: 0FC63DAF-8483-4772-8E79-3D69D8477DE4 (Linux filesystem)
- Partition unique GUID: 93FD4BBB-F574-40D2-AC20-4FC162FDDEA3
- First sector: 2099200 (at 1.0 GiB)
- Last sector: 3963870 (at 1.9 GiB)
- Partition size: 1864671 sectors (910.5 MiB)
- Attribute flags: 0000000000000000
- Partition name: 'Linux filesystem'
- Command (? for help): d
- Partition number (1-2): 1
- Command (? for help): d
- Using 2
- Command (? for help): n
- Partition number (1-128, default 1): 1
- First sector (34-3963870, default = 2048) or {+-}size{KMGTP}: 2048
- Last sector (2048-3963870, default = 3963870) or {+-}size{KMGTP}: +100M
- Current type is 'Linux filesystem'
- Hex code or GUID (L to show codes, Enter = 8300):
- Changed type of partition to 'Linux filesystem'
- Command (? for help): n
- Partition number (2-128, default 2):
- First sector (34-3963870, default = 206848) or {+-}size{KMGTP}: 206848
- Last sector (206848-3963870, default = 3963870) or {+-}size{KMGTP}:
- Current type is 'Linux filesystem'
- Hex code or GUID (L to show codes, Enter = 8300):
- Changed type of partition to 'Linux filesystem'
- Command (? for help): x
- Expert command (? for help): c
- Partition number (1-2): 1
- Enter the partition's new unique GUID ('R' to randomize): 359B474B-0EE0-46B5-A105-A57C1D60E863
- New GUID is 359B474B-0EE0-46B5-A105-A57C1D60E863
- Expert command (? for help): c
- Partition number (1-2): 2
- Enter the partition's new unique GUID ('R' to randomize): 93FD4BBB-F574-40D2-AC20-4FC162FDDEA3
- New GUID is 93FD4BBB-F574-40D2-AC20-4FC162FDDEA3
- Expert command (? for help): p
- Disk /dev/sdc: 3963904 sectors, 1.9 GiB
- Logical sector size: 512 bytes
- Disk identifier (GUID): D276E14A-5EB2-42FB-89DF-A742B6199BC3
- Partition table holds up to 128 entries
- First usable sector is 34, last usable sector is 3963870
- Partitions will be aligned on 2048-sector boundaries
- Total free space is 2014 sectors (1007.0 KiB)
- Number Start (sector) End (sector) Size Code Name
- 1 2048 206847 100.0 MiB 8300 Linux filesystem
- 2 206848 3963870 1.8 GiB 8300 Linux filesystem
- Expert command (? for help): w
- Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
- PARTITIONS!!
- Do you want to proceed? (Y/N): y
- OK; writing new GUID partition table (GPT) to /dev/sdc.
- The operation has completed successfully.
- #resizing /dev/sdc2 filesystem
- > resize2fs /dev/sdc2
- resize2fs 1.42.5 (29-Jul-2012)
- Resizing the filesystem on /dev/sdc2 to 469627 (4k) blocks.
- The filesystem on /dev/sdc2 is now 469627 blocks long.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement