I didn't notice until recently, but the automatic partitioning scheme I used during installation left about half of the volume unused. I decided I want to add all of that space to my /home partition. If you have more than two partitions, e.g. root and swap, adding space to a partition that isn't the last is almost impossible without reinstalling. Luckily, and probably by design, /home is the last partition on the disklabel, so this should be simple.
First, backup all of your files. If your disk is sd0, run: disklabel sd0 . Compute how much space you have (units are sectors, which are 512 bytes) between the end of the last partition (probably /home) and the end of the volume. Now compute the new total size of the partition. Write those numbers down. Note the letter of the last partition, e.g. sd0k. Make sure nothing is running in the /home directory. cd to /, then run umount /home or umount /dev/sd0k (where k is the letter of your last partition). You may have to use the -f option to force it to unmount. Now run disklabel -E sd0 . This opens the interactive disklabel editor. Type "c" and enter (you can also use "m" instead of "c", see the man pages). It will show you the maximum size, which you can type in, or you can type in how much ever you want to grow the partition with a + number of sectors. Check the numbers it gives against what you calculated: the number it gives should be close, but slightly smaller. After that, type "q", enter, "yes", enter. That will exit the interactive editor and save changes. Now do: growfs sd0k . This will grow the filesystem to the size of the partition. Next, check the partition: fsck /dev/sd0k . Let this run until it's finished. Now mount the partition again: mount /dev/sd0k /home . Make sure your files are still there. Run disklabel sd0 one more time just to check. That's it!
Note: These steps works just fine for partitions on an encrypted volume: that's how mine is setup.
Unfortunately, there isn't an easy tool for shrinking partitions.
Links: 1 2 3
No comments:
Post a Comment