GParted is often worth using because it helps avoid several nasty mistakes. I guess the main advantage of command-line tools here is to have more visibility of details. This can be useful in unexpectedly fragile situations (at least once it's broken, the details might help you realize why). However I wouldn't recommend using them to others unless they want to be able to learn from mistakes up to "my disk is now full of zeros and I need to start from scratch".
Also a desktop Linux install process should provide a user-friendly tool for resizing the Windows partition. (Or official documentation). It's the common case. This would be my first recommendation in general.
All of these options will recommend making backups in case of any error.
Confusingly you should not use the parted
command-line tool. It used to be a convenient option, but the developers no longer support resizing filesystems with it.
Otherwise, you use ntfsresize
, then delete and re-create the partition (fdisk
) with the same details except for the size. BEWARE UNITS - SOME TOOLS USE MB; OTHERS MAY SAY MB BUT MEAN MiB. fdisk
uses MiB and ntfsresize
uses MB. The lazy way is to ntfsresize to much smaller than you need (e.g. 2x), then after recreating the partition you run ntfsresize a second time with no explicit size.
For the hard way, to convert units, you can run numeric expressions in bash. E.g. to see 10GiB in bytes: echo $((10 * 1024 * 1024 * 1024))
. You can use those expressions as arguments to command-line tools like ntfsresize
.
The partition name for ntfsresize will look like /dev/sda1
. lsblk -f
will list all partitions (including your boot disc) with their size, and tell you about the filesystem. fdisk
will want the name of the disk, like /dev/sda
.
For MBR, the partition details to recreate are: partition type and "active"/bootable flag, as well as starting offset.[1] fdisk
should show the partition offset in sectors by default. (If not, there may be fractions which are not shown - possibly indicated by a + on the end, but there might be a trap there - you should be sure to always use fdisk
in sectors mode).
To avoid typing errors inside fdisk
, I sometimes select numbers + paste them with the middle mouse button. That requires either X Windows, or in text mode you need gpm. I think it's less common to provide gpm on the console by default now, but it's there when I use Clonezilla Live. It's convenient, but you could probably lose the number first. So you should probably write the original partition offset down before you delete it.
[1] GPT uses a different format for the type, adds some more flags and a partition UUID. I don't think they'd usually be important; flags wouldn't apply to the main Windows partition and the partition UUID isn't used by much yet.