Montag, 27. Februar 2012

Shrinking a partition

Cropped my old linux installation to make some space:
sudo resize2fs -p /dev/sda5 8G # new size is 8G
sudo sfdisk -d /dev/sda # print current partition info
sudo fdisk /dev/sda followed by command 'p' shows the sector size of your disk. You will need it for calculating the new size multiples of sectors. Make sure it is at least 8G big.
sudo sfdisk /dev/sda -N5 -uS --no-reread # change partition info of partition 5
# you are queried for start sector and size - the only two of which are manditory

You wonder why I have chosen sfdisk instead of cfdisk or fdisk? The reason is both other tools did not allow me to enter the same start-sector like it was initially after deleting and adding the fifth partition. I also used sfdisk in the past because it allowed to create partitions via shell scripts.

Keine Kommentare:

Kommentar veröffentlichen