IT

wsl 가상 드라이브(vhdx) 크기 정리(줄이기)

codens 2023. 9. 20. 22:02


    - hyper-v 


//-------------------------------------
기초 준비 작업 : 리눅스 드라이브 단편화 정리(linux drive defrag)
https://www.tecmint.com/defragment-linux-system-partitions-and-directories/

    - 디스크 검사
$ sudo umount /dev/sda1
$ sudo e2fsck -fn /dev/sda1

    - 폴더 용량 확인
sudo du -shc  /usr/local/* | sort -n -r

    - 필요없는 파일 삭제


    - 단편화 정리
$ sudo apt-get install e2fsprogs 

$ sudo e4defrag "<device> or <location>"



//-------------------------------------
diskpart 이용하여 가상 디스크 용량 정리(줄이기, compact)
https://writeabout.net/2021/10/14/shrink-your-wsl2-virtual-disk-on-windows-home/

$ wsl --shutdown
$ diskpart


select vdisk file="가상 디스크(vhdx) 경로"
compact vdisk



//-----------------------------------------------------------------------------
wsl v2.0 새 기능으로 디스크 용량 정리하기

//-------------------------------------
https://github.com/microsoft/WSL/releases

https://devblogs.microsoft.com/commandline/windows-subsystem-for-linux-september-2023-update/

    - 개발 버전으로 wsl 최신 업데이트( 버전 업그레이드)
> wsl --update --pre-release


    - 용량 정리
https://superuser.com/questions/1606213/how-do-i-get-back-unused-disk-space-from-ubuntu-on-wsl2

.wslconfig  수정
[experimental]
sparseVhd=true


> wsl --manage <distro> --set-sparse true

 




반응형