我成日都 suggest 如果想學電腦,真的要用下 Linux,以下是一個例子:
如果想 shrink 一個 parition (e.g. /dev/sda2) in ext2/3/4 file system to 120G:
0. 如果 shrink 的 parition 是 system, 需要用 Live CD / USB boot 機
1. e2fsck -f /dev/sda2 (check 下 disk 先, -f = force check even partition seems clean)
2. resize2fs /dev/sda2 119G (must slightly smaller than 120G)
3a. use fdisk /dev/sda to delete the parition 2
3b. use fdisk /dev/sda to create a new parition 2 with target size 120G (must be larger than 119G)
3c. suggest reboot after this
4. resize2fs /dev/sda2 (唔需要加 size, 用晒個 120G, 因之前 resize 成 119G, 但又唔可以打 120G, 因可能是 119.99G. If size parameter is not specified, it will default to the size of the partition)
5. e2fsck -f /dev/sda2 (最後再 check 下 disk 先)
聰明的你,應該知道最神奇的是 step 3, 竟然可以 delete and create a new parition 的同時,無 data lost! 咁又學到野,對 parition and file system 的理解又唔同左