Windows 11'de UTC Desteğini Etkinleştirme

PC hakkındaki genel bilgi ve ipucu paylaşım alanıdır.
Cevapla
Kullanıcı avatarı
TRWE_2012
Zettabyte1
Zettabyte1
Mesajlar: 15491
Kayıt: 25 Eyl 2013, 13:38
cinsiyet: Erkek
Teşekkür etti: 2655 kez
Teşekkür edildi: 5536 kez

Windows 11'de UTC Desteğini Etkinleştirme

Mesaj gönderen TRWE_2012 »

Merhabalar

UTC_BIOS_Ayarı.reg

Kod: Tümünü seç

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\TimeZoneInformation]
"RealTimeIsUniversal"=dword:00000001
A) Zaman Dilimi ve Saatin Doğru Olduğunu Kontrol Edin

Ayarlar ===>> Saat ve Dil ===>> Tarih ve Saat

"Saati otomatik olarak ayarla" ve "Saat dilimini otomatik olarak ayarla" seçeneklerinin Açık olduğundan emin olun.

B) Windows Zaman Hizmetini (W32Time) Aktif Edin ve Senkronize Edin

Yönetici olarak açılmış bir Komut İstemi (CMD) veya PowerShell'de şu komutları sırayla çalıştırın:

Kod: Tümünü seç

net stop w32time
w32tm /config /syncfromflags:manual /manualpeerlist:"time.windows.com,0x8" /reliable:YES /update
net start w32time
w32tm /resync
Sistemi yeniden başlatın...

C) Başarılı Oldu mu Kontrol Edin:

Tekrar bunu çalıştırın.

Kod: Tümünü seç

net stop w32time
w32tm /config /syncfromflags:manual /manualpeerlist:"time.windows.com,0x8" /reliable:YES /update
net start w32time
w32tm /resync
Daha sonra sonucu kontrol edin.

Kod: Tümünü seç

w32tm /query /status
Çıktıda Source: time.windows.com,0x8 veya seçtiğiniz sunucu yazmalı ve Last successful sync time güncel olmalı.
Kullanıcı avatarı
TRWE_2012
Zettabyte1
Zettabyte1
Mesajlar: 15491
Kayıt: 25 Eyl 2013, 13:38
cinsiyet: Erkek
Teşekkür etti: 2655 kez
Teşekkür edildi: 5536 kez

Betiği Güncelledim Ve Hesabıma Aktardım.

Mesaj gönderen TRWE_2012 »

Uzun süreli indirme için hesabıma yükledim...
Resim
İndirme : https://www.upload.ee/files/19502350/Si ... r_.7z.html

Arşivde gerekli açıklama notunu da ekledim.Güle güle kullanın...Eğer benim gibi çift işletim sistemine sahipseniz, gerekli bilgi not'a eklendi.Eğer sadece Windows varsa, windows .reg ve bat dosyalarını uygulayın...
Kullanıcı avatarı
TRWE_2012
Zettabyte1
Zettabyte1
Mesajlar: 15491
Kayıt: 25 Eyl 2013, 13:38
cinsiyet: Erkek
Teşekkür etti: 2655 kez
Teşekkür edildi: 5536 kez

sync_time_windows.bat — Değişim Günlüğü

Mesaj gönderen TRWE_2012 »

Sorun:

0x80070426 hatası (Hizmet başlatılmadı) — w32tm /config komutu servis durdurulmuşken çalıştırılıyordu.

Yapılan değişiklikler:

net stop w32time satırı, yapılandırma adımından tamamen kaldırıldı.Yerine net start w32time eklendi , böylece servisin yapılandırma öncesinde çalışır durumda olması sağlandı.

w32tm /config /syncfromflags:manual /manualpeerlist:"time.windows.com,0x9" /reliable:NO /update komutu artık servis aktifken çalıştırılıyor, böylece ayar RPC üzerinden servise doğrudan iletilebiliyor.

Yapılandırma tamamlandıktan sonra net stop w32time + net start w32time komutu eklendi(neden eklendi?) , servisin yeni ayarlarla temiz bir şekilde yeniden başlaması için.

timeout /t 5 /nobreak, w32tm /resync /force ve doğrulama (w32tm /query /status) adımları değiştirilmeden korundu.

Dual-boot hatırlatma mesajı (UTC_BIOS_Setting.reg) aynen korundu.

Betik artık hatasız çalışıyor, senkronizasyon başarıyla tamamlanıyor ve w32tm /query /status çıktısında Source: time.windows.com,0x9 doğru şekilde...

sync_time_windows.bat

Kod: Tümünü seç

@echo off
setlocal enabledelayedexpansion

:: ================================================
:: Windows Time Sync (W32Time) - Corrected Version
:: Target: Windows 11 24H2 (dual-boot with Linux Mint 22.2)
:: ================================================

net session >nul 2>&1
if %errorLevel% neq 0 (
    echo Error: This script requires Administrator privileges.
    echo Right-click the file and select "Run as administrator".
    echo.
    echo Press ENTER to exit.
    pause>nul
    exit /b 1
)

echo ================================================
echo  Windows Time Service Reconfiguration
echo ================================================
echo.

echo Ensuring W32Time service is running before configuration...
net start w32time >nul 2>&1

echo Configuring manual peer list (time.windows.com, Client + SpecialPollInterval)...
w32tm /config /syncfromflags:manual /manualpeerlist:"time.windows.com,0x9" /reliable:NO /update

echo Restarting W32Time service to apply configuration cleanly...
net stop w32time
net start w32time

echo Waiting for the service to fully initialize...
timeout /t 5 /nobreak >nul

echo Forcing resynchronization...
w32tm /resync /force

echo.
echo ================================================
echo  Verification
echo ================================================
w32tm /query /status

echo.
echo ================================================
echo  Reminder
echo ================================================
echo If this machine dual-boots with Linux Mint, make sure
echo UTC_BIOS_Setting.reg has been imported and the system
echo has been restarted so the BIOS clock is treated as UTC
echo consistently on both operating systems.
echo.
echo Press ENTER to exit.
pause>nul
Ekran Görüntüleri :

Öncesi : Hata veriyordu...
Resim
Sonrası : Hata yok...!!
Resim
NOT :

https://www.upload.ee/files/19502350/Si ... r_.7z.html , bağlantısındaki arşivi indirin içindeki bat dosyasının içeriği yukarıdaki ile değiştirin.
Kullanıcı avatarı
TRWE_2012
Zettabyte1
Zettabyte1
Mesajlar: 15491
Kayıt: 25 Eyl 2013, 13:38
cinsiyet: Erkek
Teşekkür etti: 2655 kez
Teşekkür edildi: 5536 kez

ntp_sync_linux.sh — Değişim Günlüğü [Bugün formumdayım]

Mesaj gönderen TRWE_2012 »

Düzeltme - 1 :

NTP_TOOL=$(check_ntp_tool) komut'u çağrıldığında , check_ntp_tool fonksiyonundaki exit 1 yalnızca alt kabuğu (subshell) sonlandırıyordu; bundan dolayı betik boş bir NTP_TOOL komutu ile devam edip yanlışlıkla "başarılı" mesajı verebiliyordu. Şimdi main() içinde NTP_TOOL boşsa betik gerçekten durduruluyor ve hata mesajı gösteriliyor.

Düzeltme -2 :

$HOME belirsizliği düzeltildi: Betik sudo ile çalıştırıldığında $HOME genellikle /root'a işaret eder. Artık SUDO_USER değişkeni üzerinden gerçek kullanıcının (linuxmaster) ev dizini getent passwd ile tespit ediliyor ve CONFIG_FILE oraya yazılıyor.

Düzeltme -3 :

Config dosyası sahipliği düzeltildi: Dosya root olarak yazıldığından, save_config fonksiyonu artık dosyanın sahipliğini chown ile gerçek kullanıcıya devrediyor , böylece kullanıcı ileride dosyayı sudo olmadan da düzenleyebilir.

Düzeltme-4 :

local kapsam iyileştirmesi: select_server içindeki choice, set_rtc_to_utc içindeki choice, ve main içindeki last_selected / reuse değişkenleri artık local olarak tanımlandı böylece global scope belirsizliği önlendi.

Betik bash -n ile sözdizimi kontrolünden geçti. Test etmek için Linux üzerinde şu şekilde çalıştırabilirsiniz:

Kod: Tümünü seç

sudo bash ntp_sync_linux.sh
KOD İÇERİĞİ :

Kod: Tümünü seç

#!/bin/bash
export LANG=tr_TR.UTF-8
export LC_ALL=tr_TR.UTF-8

# ================================================
# NTP Synchronization + BIOS UTC Converter
# Support: systemd-timesyncd, chrony, ntpdate
# Target: Linux Mint 22.2 (dual-boot with Windows 11)
# ================================================

RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m'

# Resolve the real invoking user's home directory, even when running under sudo,
# so the config file is not accidentally written to /root instead of the actual user.
if [[ -n "$SUDO_USER" ]]; then
    REAL_HOME=$(getent passwd "$SUDO_USER" | cut -d: -f6)
else
    REAL_HOME="$HOME"
fi
CONFIG_FILE="$REAL_HOME/.ntp_sync_config"

# ================================================
# 1. TRUSTED ATOMIC TIME SERVER LIST
#    (Stratum 1 and high-accuracy pools)
# ================================================
declare -a SERVER_LIST=(
    "tr.pool.ntp.org"
    "time.nist.gov"
    "ntp.nict.jp"
    "ptbtime1.ptb.de"
    "0.pool.ntp.org"
    "1.pool.ntp.org"
    "time.google.com"
    "time.cloudflare.com"
    "clock.isc.org"
    "ntp.ubuntu.com"
    "0.tr.pool.ntp.org"
    "1.tr.pool.ntp.org"
)

# ================================================
# 2. HELPER FUNCTIONS
# ================================================

check_root() {
    if [[ $EUID -ne 0 ]]; then
        echo -e "${RED}Error: This script requires root privileges. Run with 'sudo'.${NC}"
        exit 1
    fi
}

# Detect the ACTIVE NTP service first, then fall back to installed binaries.
# Checking the active systemd unit avoids misdetection on systems where
# both timedatectl and chrony are installed but only one is actually running.
check_ntp_tool() {
    if systemctl is-active --quiet chronyd 2>/dev/null || systemctl is-active --quiet chrony 2>/dev/null; then
        echo "chrony"
    elif systemctl is-active --quiet systemd-timesyncd 2>/dev/null; then
        echo "timedatectl"
    elif command -v chronyc &>/dev/null; then
        echo "chrony"
    elif command -v timedatectl &>/dev/null; then
        echo "timedatectl"
    elif command -v ntpdate &>/dev/null; then
        echo "ntpdate"
    else
        echo -e "${RED}No NTP tool found (timedatectl, chrony, ntpdate).${NC}" >&2
        exit 1
    fi
}

# Save the selection to the config file (to remember it for next time)
save_config() {
    local selected="$1"
    > "$CONFIG_FILE"
    for server in "${SERVER_LIST[@]}"; do
        if [[ "$server" == "$selected" ]]; then
            echo "* $server" >> "$CONFIG_FILE"
        else
            echo "  $server" >> "$CONFIG_FILE"
        fi
    done

    # File was just written as root; hand ownership back to the invoking user
    if [[ -n "$SUDO_USER" ]]; then
        chown "$SUDO_USER":"$SUDO_USER" "$CONFIG_FILE" 2>/dev/null
    fi

    echo -e "${GREEN}Configuration file updated: $CONFIG_FILE${NC}"
}

# Ask the user to select a server
select_server() {
    echo -e "${YELLOW}=== AVAILABLE ATOMIC TIME SERVERS ===${NC}"
    local i=1
    local choice
    for server in "${SERVER_LIST[@]}"; do
        echo "  $i) $server"
        ((i++))
    done
    echo -n "Enter a server number (1-${#SERVER_LIST[@]}): "
    read -r choice

    if ! [[ "$choice" =~ ^[0-9]+$ ]] || [[ "$choice" -lt 1 ]] || [[ "$choice" -gt ${#SERVER_LIST[@]} ]]; then
        echo -e "${RED}Invalid selection! Defaulting to 'tr.pool.ntp.org'.${NC}"
        selected_server="${SERVER_LIST[0]}"
    else
        selected_server="${SERVER_LIST[$((choice-1))]}"
    fi
    echo -e "${GREEN}Selected server: $selected_server${NC}"
}

# ================================================
# 3. CONVERT BIOS (RTC) CLOCK TO UTC
# ================================================
set_rtc_to_utc() {
    local choice
    echo -e "${BLUE}--- BIOS (RTC) Clock Setting Check ---${NC}"

    if timedatectl status | grep -q "RTC in local TZ: yes"; then
        echo -e "${YELLOW}Warning: BIOS clock is currently set to LOCAL TIME (+03).${NC}"
        echo -e "${YELLOW}This causes clock confusion in Windows + Linux dual-boot setups.${NC}"
        echo -n "Do you want to convert the BIOS clock to UTC? (Y/n): "
        read -r choice

        if [[ "$choice" =~ ^[Yy]$ ]] || [[ -z "$choice" ]]; then
            sudo timedatectl set-local-rtc 0
            if [[ $? -eq 0 ]]; then
                echo -e "${GREEN}BIOS clock successfully converted to UTC.${NC}"
                echo -e "${GREEN}(Remember to also apply 'RealTimeIsUniversal=1' via UTC_BIOS_Setting.reg on the Windows side.)${NC}"
            else
                echo -e "${RED}BIOS UTC conversion failed!${NC}"
            fi
        else
            echo -e "${BLUE}BIOS UTC conversion skipped.${NC}"
        fi
    else
        echo -e "${GREEN}BIOS clock is already set to UTC. No action needed.${NC}"
    fi
}

# ================================================
# 4. systemd-timesyncd CONFIGURATION
#    (automatically edits timesyncd.conf)
# ================================================
configure_timesyncd() {
    local server="$1"
    local conf_file="/etc/systemd/timesyncd.conf"

    if [[ ! -f "$conf_file" ]]; then
        echo -e "${RED}timesyncd.conf not found!${NC}"
        return 1
    fi

    echo -e "${BLUE}Updating ${conf_file}...${NC}"

    # Backup first
    sudo cp "$conf_file" "$conf_file.bak_$(date +%Y%m%d_%H%M%S)" 2>/dev/null

    # Remove existing NTP= lines (commented or not)
    sudo sed -i "/^#\?NTP=/d" "$conf_file"

    # Insert NTP= right after the [Time] section header
    sudo sed -i "/^\[Time\]/a NTP=$server" "$conf_file"

    # Refresh FallbackNTP= as well
    sudo sed -i "/^#\?FallbackNTP=/d" "$conf_file"
    sudo sed -i "/^NTP=/a FallbackNTP=ntp.ubuntu.com time.google.com" "$conf_file"

    echo -e "${GREEN}Configuration updated: NTP=$server${NC}"
}

# ================================================
# 5. RUN SYNCHRONIZATION
# ================================================
sync_time() {
    local server="$1"
    local tool="$2"

    echo -e "${BLUE}=== Starting Synchronization (Tool: $tool) ===${NC}"

    case $tool in
        timedatectl)
            configure_timesyncd "$server"
            sudo systemctl restart systemd-timesyncd
            sleep 2
            sudo timedatectl set-ntp true
            echo -e "${GREEN}systemd-timesyncd service restarted.${NC}"
            ;;

        chrony)
            echo "server $server iburst" | sudo tee /etc/chrony.d/temp_sync.conf > /dev/null
            sudo systemctl restart chrony 2>/dev/null || sudo systemctl restart chronyd
            sleep 2
            sudo chronyc -a makestep
            echo -e "${GREEN}chrony synchronization completed.${NC}"
            ;;

        ntpdate)
            sudo ntpdate -u "$server"
            if [[ $? -eq 0 ]]; then
                echo -e "${GREEN}ntpdate synchronization successful.${NC}"
            else
                echo -e "${RED}ntpdate failed.${NC}"
                return 1
            fi
            ;;
    esac

    # Write system time to the BIOS/hardware clock (RTC)
    echo -e "${BLUE}Updating hardware clock (RTC)...${NC}"
    sudo hwclock --systohc
    if [[ $? -eq 0 ]]; then
        echo -e "${GREEN}BIOS (RTC) clock updated from system time.${NC}"
    else
        echo -e "${RED}BIOS clock update failed!${NC}"
    fi

    echo -e "${BLUE}--- Current Time Status ---${NC}"
    timedatectl status
}

# ================================================
# 6. MAIN PROGRAM
# ================================================
main() {
    local last_selected
    local reuse
    check_root

    NTP_TOOL=$(check_ntp_tool)
    if [[ -z "$NTP_TOOL" ]]; then
        echo -e "${RED}Fatal: No usable NTP tool detected. Aborting.${NC}"
        read -rp $'\nPress ENTER to exit.' _
        exit 1
    fi
    echo -e "${GREEN}NTP tool to be used: $NTP_TOOL${NC}"

    if [[ -f "$CONFIG_FILE" ]]; then
        last_selected=$(grep '^\*' "$CONFIG_FILE" | sed 's/^\* //')
        if [[ -n "$last_selected" ]]; then
            echo -e "${YELLOW}Previous selection: $last_selected${NC}"
            echo -n "Do you want to use this server again? (Y/n): "
            read -r reuse
            if [[ "$reuse" =~ ^[Yy]$ ]] || [[ -z "$reuse" ]]; then
                selected_server="$last_selected"
                echo -e "${GREEN}Using previous server: $selected_server${NC}"

                set_rtc_to_utc
                sync_time "$selected_server" "$NTP_TOOL"

                echo -e "${GREEN}=== All operations completed! ===${NC}"
                read -rp $'\nPress ENTER to exit.' _
                exit 0
            fi
        fi
    fi

    select_server
    save_config "$selected_server"

    set_rtc_to_utc
    sync_time "$selected_server" "$NTP_TOOL"

    echo -e "${GREEN}=== All operations completed! ===${NC}"
    read -rp $'\nPress ENTER to exit.' _
}

main
Kullanıcı avatarı
TRWE_2012
Zettabyte1
Zettabyte1
Mesajlar: 15491
Kayıt: 25 Eyl 2013, 13:38
cinsiyet: Erkek
Teşekkür etti: 2655 kez
Teşekkür edildi: 5536 kez

UTC_BIOS_Setting.reg

Mesaj gönderen TRWE_2012 »

Madem, bat ve .sh betiklerini güncelledik o zaman birinci mesajımdaki indirme bağlantısının "HİÇBİR ÖNEMİ KALMADI" diyebilirim.Türkçesi, boş verin indirmeyin...

Kod: Tümünü seç

Windows Registry Editor Version 5.00

; Sets the RTC (BIOS / hardware clock) to be interpreted as UTC.
; Required for consistent time handling in Windows + Linux dual-boot systems.
; After importing this file, restart Windows, then run sync_time_windows.bat.

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\TimeZoneInformation]
"RealTimeIsUniversal"=dword:00000001
Bu uyarı notunu okuyun yeter...

UYARI NOTU :

Kullanım sırası: Önce .reg dosyasını Windows'ta içe aktarın › yeniden başlatın › sync_time_windows.bat'ı yönetici olarak çalıştırın; Linux Mint tarafında ise sudo bash ntp_sync_linux.sh ile çalıştırın.

Bu kadar, artık Windows-Linux saat kayması sorunu sonsuza dek çözümlenmiştir...

Güle güle kullanın...
Cevapla

“Genel bilgiler ve ipuçları” sayfasına dön