Disable Windows fast reboot
feature!
Procedure 1. Selecting and resizing a partition.
#
blkid
/dev/sda1: SEC_TYPE="msdos" UUID="32AE-E651" TYPE="vfat" PARTLABEL="EFI System Partition" PARTUUID="0315942d-8c2c-414f-a560-cfa499494a72" /dev/sda2: UUID="593153ae-2b67-4a5b-9efa-fa3954953abd" TYPE="ext4" PARTUUID="68cadad8-6de2-4ef7-96ff-f58e5114fdcc" /dev/sda3: UUID="P2xKTQ-aQWG-z2Uv-jSw5-kkUK-SN5Q-cNf3PI" TYPE="LVM2_member" PARTUUID="7ba7ed40-b43f-4e71-b83e-51629bf7db47" /dev/sda5: UUID="44B6BAD1B6BAC2AA" TYPE="ntfs" PARTUUID="9c62d1dc-dedd-4d4c-9728-5f2ef69f2b42"
ntfs
partitions indicate the existing Windows installation. Examine the partitions on the /dev/sda
drive.
#
parted /dev/sda print
Model: ATA ST9320328CS (scsi) Disk /dev/sda: 320GB Sector size (logical/physical): 512B/512B Partition Table: gpt Disk Flags: pmbr_boot Number Start End Size File system Name Flags 1 1049kB 211MB 210MB fat16 EFI System Partition boot 2 211MB 735MB 524MB ext4 3 735MB 119GB 118GB 4 119GB 119GB 134MB Microsoft reserved partition msftres 5 119GB 215GB 96.2GB ntfs
#
ntfsresize --info /dev/sda5
ntfsresize v2013.1.13 (libntfs-3g) Device name : /dev/sda5 NTFS volume version: 3.1 Cluster size : 4096 bytes Current volume size: 96234107392 bytes (96235 MB) Current device size: 96234110976 bytes (96235 MB) Checking filesystem consistency ... 100.00 percent completed Accounting clusters ... Space in use : 29222 MB (30.4%) Collecting resizing constraints ... You might resize at 29221265408 bytes or 29222 MB (freeing 67013 MB). Please make a test run using both the -n and -s options before real resizing!
#
ntfsresize --size 40G /dev/sda5
ntfsresize v2013.1.13 (libntfs-3g) Device name : /dev/sda5 NTFS volume version: 3.1 Cluster size : 4096 bytes Current volume size: 96234107392 bytes (96235 MB) Current device size: 96234110976 bytes (96235 MB) New volume size : 39999996416 bytes (40000 MB) Checking filesystem consistency ... 100.00 percent completed Accounting clusters ... Space in use : 29222 MB (30.4%) Collecting resizing constraints ... Needed relocations : 0 (0 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) Updating $BadClust file ... Updating $Bitmap file ... Updating Boot record ... Syncing device ... Successfully resized NTFS on device '/dev/sda5'. 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.
Procedure 2. Resizing the partition
#
parted /dev/sda unit s print
Model: ATA ST9320328CS (scsi) Disk /dev/sda: 625142448s Sector size (logical/physical): 512B/512B Partition Table: gpt Disk Flags: pmbr_boot Number Start End Size File system Name Flags 1 2048s 411647s 409600s fat16 EFI System Partition boot 2 411648s 1435647s 1024000s ext4 3 1435648s 232122367s 230686720s 4 232122368s 232384511s 262144s Microsoft reserved partition msftres 5 232384512s 420341759s 187957248s ntfs 6 420341760s 420343807s 2048s bios_grub 7 420343808s 421367807s 1024000s ext4 8 421367808s 625141759s 203773952s
232384512
, and the sector size is 512 bytles
#
ntfsfix -d /dev/sda5
Mounting volume... OK Processing of $MFT and $MFTMirr completed successfully. Checking the alternate boot sector... OK NTFS volume version is 3.1. NTFS partition /dev/sda5 was processed successfully.
#
ntfsinfo -m /dev/sda5|grep Cluster
Cluster Size: 4096 Volume Size in Clusters: 9765624 Compression Block Clusters: 0 Free Clusters: 2631945 (27.0%)
Equation 1. Filesystem size in sectors
Equation 2. End sector of new partition
ntfs
filesystem on /dev/sda
. Using the s
after the number ensures parted
uses sectors as the unit.
#
parted /dev/sda
GNU Parted 3.1 Using /dev/sda Welcome to GNU Parted! Type 'help' to view a list of commands.(parted)
(parted)
rm 5(parted)
mkpart Partition name? []? windowsdisk File system type? [ext2]? ntfs Start? 232384512s End? 310509504s(parted)
quit
parted
.
(parted)
print free Model: ATA ST9320328CS (scsi) Disk /dev/sda: 320GB Sector size (logical/physical): 512B/512B Partition Table: gpt Disk Flags: pmbr_boot Number Start End Size File system Name Flags 17.4kB 1049kB 1031kB Free Space 1 1049kB 211MB 210MB fat16 EFI System Partition boot 2 211MB 735MB 524MB ext4 3 735MB 119GB 118GB 4 119GB 119GB 134MB Microsoft reserved partition msftres 5 119GB 159GB 40.0GB ntfs 159GB 215GB 56.2GB Free Space(parted)
quit