Ollama 서버 재시작: 모델 저장 위치 유지·변경·이동 (Windows·Mac)
- 재시작 메뉴: 그대로(기본) / 저장 위치 바꾸고 기존 모델 옮겨서 / 저장 위치만 바꿔서(기존 모델 그대로)
- ollama_models_change nomove, Set-OllamaModelsLocation -NoMove 추가 ('모델 저장 위치' 메뉴는 그대로)
- 서버가 꺼져 있었으면 바꾼 위치로 기동, 위치를 바꾸지 않으면 재시작하지 않음
- (Windows 19_ollama_restart.ps1, Mac 19_ollama_restart.sh)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HnDmXrFqktWwYa1cuJRAVZ
This commit is contained in:
@@ -83,30 +83,40 @@ function Test-MoveTarget([string]$Old, [string]$New, [double]$SizeGB) {
|
||||
}
|
||||
|
||||
# Ollama 모델 저장 위치 변경
|
||||
function Set-OllamaModelsLocation {
|
||||
# -NoMove: 위치만 바꾸고 기존 모델은 지금 위치에 그대로 둠
|
||||
function Set-OllamaModelsLocation([switch]$NoMove) {
|
||||
$old = Get-ModelsDir
|
||||
$new = Select-FolderPath 'Ollama 모델 저장 위치 변경' $old $OllamaModelsDefault
|
||||
if (-not $new) { return }
|
||||
Clear-Host
|
||||
$size = Get-PathSizeGB $old
|
||||
if (-not (Test-MoveTarget $old $new $size)) { return }
|
||||
Write-C "${CYAN}Ollama 모델 저장 위치를 바꿉니다${RESET}"
|
||||
if ($NoMove) {
|
||||
if ($old.TrimEnd('\') -eq $new.TrimEnd('\')) { Write-C "${YELLOW}지금과 같은 위치입니다.${RESET}"; return }
|
||||
if (-not (Test-Path -LiteralPath $new)) { New-Item -ItemType Directory -Path $new -Force -ErrorAction SilentlyContinue | Out-Null }
|
||||
if (-not (Test-Path -LiteralPath $new)) { Write-C "${RED}❌ 폴더를 만들 수 없습니다: $new${RESET}"; return }
|
||||
Write-C "${CYAN}Ollama 모델 저장 위치를 바꿉니다 (기존 모델은 옮기지 않음)${RESET}"
|
||||
} else {
|
||||
if (-not (Test-MoveTarget $old $new $size)) { return }
|
||||
Write-C "${CYAN}Ollama 모델 저장 위치를 바꿉니다${RESET}"
|
||||
}
|
||||
Write-C " 지금: $old ($size GB)"
|
||||
Write-C " 새 위치: $new (남은 공간 $(Get-PathFreeGB $new)GB)"
|
||||
Write-C "${GRAY} 받은 모델은 새 위치로 옮기고, 사용자 환경 변수 OLLAMA_MODELS 에 저장합니다.${RESET}"
|
||||
if ($NoMove) { Write-C "${GRAY} 받은 모델은 지금 위치($old)에 그대로 두고, 사용자 환경 변수 OLLAMA_MODELS 만 새 위치로 바꿉니다. (새 위치에 모델이 없으면 목록이 비어 보임)${RESET}" }
|
||||
else { Write-C "${GRAY} 받은 모델은 새 위치로 옮기고, 사용자 환경 변수 OLLAMA_MODELS 에 저장합니다.${RESET}" }
|
||||
$wasRunning = Test-Server
|
||||
$owner = ''
|
||||
if ($wasRunning) {
|
||||
$owner = (Get-ServerInfo).Owner
|
||||
Write-C "${YELLOW} 옮기는 동안 Ollama 서버를 잠시 종료합니다.${RESET}"
|
||||
}
|
||||
if (-not (Confirm-Choice "Ollama 모델을 새 위치로 옮길까요?")) { return }
|
||||
$q = if ($NoMove) { '저장 위치를 새 위치로 바꿀까요? (모델은 옮기지 않음)' } else { 'Ollama 모델을 새 위치로 옮길까요?' }
|
||||
if (-not (Confirm-Choice $q)) { return }
|
||||
$before = @((Get-ModelIdMap).Keys).Count
|
||||
if ($wasRunning) {
|
||||
Stop-OllamaServer
|
||||
if (Test-Server) { Write-C "${RED}❌ 서버가 아직 실행 중이라 옮기지 않았습니다.${RESET}"; return }
|
||||
}
|
||||
if (-not (Move-FolderContent $old $new)) { return }
|
||||
if (-not $NoMove) { if (-not (Move-FolderContent $old $new)) { return } }
|
||||
if ($new -eq $OllamaModelsDefault) {
|
||||
[Environment]::SetEnvironmentVariable('OLLAMA_MODELS', $null, 'User')
|
||||
Remove-Item Env:OLLAMA_MODELS -ErrorAction SilentlyContinue
|
||||
@@ -114,7 +124,7 @@ function Set-OllamaModelsLocation {
|
||||
[Environment]::SetEnvironmentVariable('OLLAMA_MODELS', $new, 'User')
|
||||
$env:OLLAMA_MODELS = $new
|
||||
}
|
||||
if ((Test-Path -LiteralPath $old) -and @(Get-ChildItem -LiteralPath $old -Recurse -File -Force -ErrorAction SilentlyContinue).Count -eq 0) {
|
||||
if ((-not $NoMove) -and (Test-Path -LiteralPath $old) -and @(Get-ChildItem -LiteralPath $old -Recurse -File -Force -ErrorAction SilentlyContinue).Count -eq 0) {
|
||||
Remove-Item -LiteralPath $old -Recurse -Force -ErrorAction SilentlyContinue
|
||||
}
|
||||
Clear-StorageCache
|
||||
@@ -124,7 +134,8 @@ function Set-OllamaModelsLocation {
|
||||
[void](Invoke-ServerLaunch $script:Perf.ContextLength)
|
||||
Start-Sleep -Seconds 1
|
||||
$after = @((Get-ModelIdMap).Keys).Count
|
||||
if ($after -eq $before) { Write-C "${GREEN}✅ 실행 확인: 설치된 모델 ${after}개가 새 위치에서 그대로 보입니다.${RESET}" }
|
||||
if ($NoMove) { Write-C "${GREEN}✅ 새 위치에서 모델 ${after}개가 보입니다. (기존 모델 ${before}개는 $old 에 그대로 있음)${RESET}" }
|
||||
elseif ($after -eq $before) { Write-C "${GREEN}✅ 실행 확인: 설치된 모델 ${after}개가 새 위치에서 그대로 보입니다.${RESET}" }
|
||||
else { Write-C "${YELLOW}⚠️ 모델 개수가 다릅니다 (전 ${before}개 → 지금 ${after}개). 새 폴더를 확인해 주세요: $new${RESET}" }
|
||||
}
|
||||
if ($owner -and $owner -ne '스크립트') {
|
||||
|
||||
Reference in New Issue
Block a user