파티션 용량 정리

용량 큰 폴더 찾아내기

head -N 로 몇 개 까지 표시할 지 설정

$ du -ah ./ | grep -v "/$" | sort -rh | head -12
40G	./.cache
34G	./Downloads
30G	./github
23G	./.cache/pypoetry
22G	./github/mono-vo/dataset/sequences
22G	./github/mono-vo/dataset
22G	./github/mono-vo
22G	./Downloads/data_odometry_gray.zip
14G	./.cache/pypoetry/virtualenvs
11G	./.config
11G	./catkin_ws
8.8G	./catkin_ws/src

오래된 캐시파일 제거

보다시피 ~/.cache 에 40G 넘는 파일들이 쌓여있기 때문에 제거해야 하였으나 무작정 지우는 것이 불안하여 검색해봄.

https://askubuntu.com/questions/102046/is-it-okay-to-delete-the-cache-folder 에서 제시한 일정 기간이 지난 파일을 삭제함.

$ find ~/.cache/ -depth -type f -atime +180

용량 큰 패키지 제거

$ dpkg-query --show --showformat='${Package;-50}\t${Installed-Size}\n' | sort -k 2 -n | grep -v deinstall | awk '{printf "%.3f MB \t %s\n", $2/(1024), $1}'
# ...
362.818 MB 	 libgl1-mesa-dri
378.682 MB 	 code
379.260 MB 	 libgl1-mesa-dri
383.577 MB 	 naver-whale-stable
621.394 MB 	 wine-stable-i386
652.386 MB 	 zoom
689.403 MB 	 linux-firmware
728.213 MB 	 wine-stable-amd64

위 명령어로 용량이 큰 패키지들을 찾을 수 있고, 사용하지 않는 패키지들은 apt-get remove 로 제거해준다.

파티션 조정

/ 경로에 더 지울만한 요소가 보이지 않아 파티션을 조정하기로 함.

https://askubuntu.com/questions/1122195/how-to-remove-swap-partition

위 링크를 참조하여 //home 사이에 있는 swap 파티션을 없애 / 파티션을 늘리고자 함.

우선, /etc/fstab 에 있는 경로를 주석처리한다.

# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
# / was on /dev/nvme0n1p6 during installation
UUID=7e427749-6159-409d-bbc1-bf04542baaa3 /               ext4    errors=remount-ro 0       1
# /boot/efi was on /dev/nvme0n1p5 during installation
UUID=7644-A13D  /boot/efi       vfat    umask=0077      0       1
# /home was on /dev/nvme0n1p8 during installation
UUID=fd206db4-a7c8-4e02-b137-eb1839ea5402 /home           ext4    defaults        0       2
# swap was on /dev/nvme0n1p3 during installation
UUID=9482632b-7e03-4d4f-8c47-2eb7b0af5a58 none            swap    sw              0       0
# swap was on /dev/nvme0n1p7 during installation
# UUID=d033a561-8754-4ee8-971f-b80138d205d6 none            swap    sw              0       0

그리고 gparted 를 이용해서 /dev/nvme0n1p7 를 swap off 한 후에 제거한다. 그러면 이제 / 를 Resize 를 통해 크기를 늘릴 수 있다.