自動判別硬碟的問題?

19 views
Skip to first unread message

willie lin

unread,
May 13, 2026, 4:10:45 AM (13 days ago) May 13
to 再生龍clonezilla
請教一下:

之前,我有做一鍵備份及還原的的選項,之前是在 SSD的選項,現在是NVME,我知道是可以直接改成NVME0n1,就可以。但,我想兩者通用,有沒有什麼方法,可以自動判別硬碟,可以直接備份或還原。我之前的的如下:

  $linux_cmd /live/vmlinuz boot=live union=overlay username=user hostname=kinetic config quiet loglevel=0 noswap edd=on nomodeset enforcing=0 noeject locales= keyboard-layouts=en ocs_prerun="mount /dev/sdb1 /mnt" ocs_prerun1=\"mount --bind /mnt/backup /home/partimag/\" ocs_live_run="ocs-sr -q2 -c -j2 -z9p -i 4096 -sfsck -scs -senc -p choose savedisk default-img sda" ocs_live_extra_param="" ocs_live_batch="no" vga=788 toram=live,syslinux,EFI,boot,.disk,utils ip= net.ifnames=0  splash i915.blacklist=yes radeonhd.blacklist=yes nouveau.blacklist=yes vmwgfx.enable_fbdev=1
  $initrd_cmd /live/initrd.img0

Steven Shiau

unread,
May 13, 2026, 8:26:20 AM (13 days ago) May 13
to ocs-clo...@googlegroups.com

你若接受在TUI選擇的話,將ocs_live_run中的"sda",改成"ask_user"。
若是要全部自動的話,可以將"sda"改成"all".

Steven

--
這是 Google 網路論壇針對「再生龍clonezilla」群組發送的訂閱通知郵件。
如要取消訂閱這個群組並停止接收來自這個群組的郵件,請傳送電子郵件到 ocs-clonezill...@googlegroups.com
如要查看這個討論,請前往 https://groups.google.com/d/msgid/ocs-clonezilla/5ecb426f-bda1-43b4-b829-441ec4a75085n%40googlegroups.com
-- 
Steven Shiau <steven _at_ stevenshiau org>
Public Key Server PGP Key ID: 4096R/163E3FB0
Fingerprint: EB1D D5BF 6F88 820B BCF5  356C 8E94 C9CD 163E 3FB0

willie lin

unread,
May 15, 2026, 5:58:08 AM (11 days ago) May 15
to 再生龍clonezilla
謝謝指導,我已經完成,
指令如下
menuentry --hotkey=p " Restore Default Image " --id live-default {
  search --set -f /live/vmlinuz
  $linux_cmd /live/vmlinuz boot=live union=overlay username=user config components quiet noswap edd=on nomodeset enforcing=0 noeject locales=en_US.UTF-8 keyboard-layouts=us ocs_prerun="mount /dev/sda1 /mnt" ocs_prerun1="mount --bind /mnt/backup/ /home/partimag/" ocs_live_run="ocs-sr -g auto -e1 auto -e2 -r -j2 -k1 -scr -batch -p choose restoredisk default-img all" ocs_live_batch="yes" vga=788 ip= nosplash net.ifnames=0 splash i915.blacklist=yes radeonhd.blacklist=yes nouveau.blacklist=yes vmwgfx.enable_fbdev=1
  $initrd_cmd /live/initrd.img
}

menuentry --hotkey=p " Backup Default Image " --id live-toram {
  search --set -f /live/vmlinuz
  $linux_cmd /live/vmlinuz boot=live union=overlay username=user hostname=kinetic config quiet loglevel=0 noswap edd=on nomodeset enforcing=0 noeject locales=en_US.UTF-8 keyboard-layouts=us ocs_prerun="mount /dev/sda1 /mnt" ocs_prerun1=\"mount --bind /mnt/backup /home/partimag/\" ocs_live_run="ocs-sr -q2 -c -j2 -gb3 -gmf -z9p -plu -i 4096 -sfsck -scs -senc -p choose savedisk default-img all" ocs_live_extra_param="" ocs_live_batch="no" vga=788 toram=live,syslinux,EFI,boot,.disk,utils ip= net.ifnames=0  splash i915.blacklist=yes radeonhd.blacklist=yes nouveau.blacklist=yes vmwgfx.enable_fbdev=1
  $initrd_cmd /live/initrd.img

但我有幾個問題:
   1. USB 一定是SDA嗎?如果變SDB那這個就無法使用,我在2022有做的一版USB是SDB。
   2. -senc 是不加密,如果我改加密 -enc,好像不能輸入密碼?而且備份失敗?(加密是為了CRA要求)
   3. 上題延伸,果我要自動備份跟加密,該如何做?
   4. 在自動還原(不考慮解密)上,完成後,可以調重開機,但這會無限循環。有沒有辦法在重開機前,調BIOS改成 Windows Boot Manager為第一個選項?

    謝謝幫忙!


Steven Shiau 在 2026年5月13日 星期三晚上8:26:20 [UTC+8] 的信中寫道:

Steven Shiau

unread,
May 15, 2026, 9:32:22 PM (10 days ago) May 15
to ocs-clo...@googlegroups.com


On 5/15/26 17:33, willie lin wrote:
謝謝指導,我已經完成,
指令如下
menuentry --hotkey=p " Restore Default Image " --id live-default {
  search --set -f /live/vmlinuz
  $linux_cmd /live/vmlinuz boot=live union=overlay username=user config components quiet noswap edd=on nomodeset enforcing=0 noeject locales=en_US.UTF-8 keyboard-layouts=us ocs_prerun="mount /dev/sda1 /mnt" ocs_prerun1="mount --bind /mnt/backup/ /home/partimag/" ocs_live_run="ocs-sr -g auto -e1 auto -e2 -r -j2 -k1 -scr -batch -p choose restoredisk default-img all" ocs_live_batch="yes" vga=788 ip= nosplash net.ifnames=0 splash i915.blacklist=yes radeonhd.blacklist=yes nouveau.blacklist=yes vmwgfx.enable_fbdev=1
  $initrd_cmd /live/initrd.img
}

menuentry --hotkey=p " Backup Default Image " --id live-toram {
  search --set -f /live/vmlinuz
  $linux_cmd /live/vmlinuz boot=live union=overlay username=user hostname=kinetic config quiet loglevel=0 noswap edd=on nomodeset enforcing=0 noeject locales=en_US.UTF-8 keyboard-layouts=us ocs_prerun="mount /dev/sda1 /mnt" ocs_prerun1=\"mount --bind /mnt/backup /home/partimag/\" ocs_live_run="ocs-sr -q2 -c -j2 -gb3 -gmf -z9p -plu -i 4096 -sfsck -scs -senc -p choose savedisk default-img all" ocs_live_extra_param="" ocs_live_batch="no" vga=788 toram=live,syslinux,EFI,boot,.disk,utils ip= net.ifnames=0  splash i915.blacklist=yes radeonhd.blacklist=yes nouveau.blacklist=yes vmwgfx.enable_fbdev=1
  $initrd_cmd /live/initrd.img

但我有幾個問題:
   1. USB 一定是SDA嗎?如果變SDB那這個就無法使用,我在2022有做的一版USB是SDB。
不一定,若你的機器本來就有SATA的硬碟,加上USB stick,不管是sda或者sdb都有可能。目前Clonezilla有一個測試中的功能,文件還沒說明不過已經可以用了。也就是用ocs-?d*來取代你目前的sda, sdb或者all:
# NVMe device: ocs-nd01, ocs-nd02...
# SATA/SAS/SCSI/USB device: ocs-sd01, ocs-sd02... and USB one will be in low priority
# EMMC device: ocs-md01, ocs-md02...

這是依照裝置連接的順序。例如以你描述的情形,若有兩個儲存裝置,分別是SATA硬碟與USB stick,可以用ocs-sd01來取代第一個SATA硬碟,USB stick就是ocs-sd02

   2. -senc 是不加密,如果我改加密 -enc,好像不能輸入密碼?而且備份失敗?(加密是為了CRA要求)
應該會出現這樣的:
//NOTE// You must remember the passphrase; otherwise, the image will _NOT_ be usable in the future.
*** Enter the passphrase to encrypt the image: default-img ***
(It will not be echoed on the screen)

   3. 上題延伸,果我要自動備份跟加密,該如何做?
你是說非交談式的作法?若是,應該只能用檔案的方式來提供passphrase或者key。這部份其實可以透過ocs_prerun的參數來自己用cryptfs或者gocryptfs來掛載。BTW,未來我們會逐步淘汰cryptfs,改用gocryptfs (這已經在測試版的Clonezilla live中有了)
   4. 在自動還原(不考慮解密)上,完成後,可以調重開機,但這會無限循環。有沒有辦法在重開機前,調BIOS改成 Windows Boot Manager為第一個選項?
你可以在開機參數ocs_postrun去指定,用efibootmgr來指定EFI BIOS中的開機順序。例如先用efibootmgr查出Boot0001是你要指定的:

ocs_postrun="efibootmgr ---bootorder 1"

Steven


    謝謝幫忙!


Steven Shiau 在 2026年5月13日 星期三晚上8:26:20 [UTC+8] 的信中寫道:

你若接受在TUI選擇的話,將ocs_live_run中的"sda",改成"ask_user"。
若是要全部自動的話,可以將"sda"改成"all".

Steven

On 5/13/26 13:22, willie lin wrote:
請教一下:

之前,我有做一鍵備份及還原的的選項,之前是在 SSD的選項,現在是NVME,我知道是可以直接改成NVME0n1,就可以。但,我想兩者通用,有沒有什麼方法,可以自動判別硬碟,可以直接備份或還原。我之前的的如下:

  $linux_cmd /live/vmlinuz boot=live union=overlay username=user hostname=kinetic config quiet loglevel=0 noswap edd=on nomodeset enforcing=0 noeject locales= keyboard-layouts=en ocs_prerun="mount /dev/sdb1 /mnt" ocs_prerun1=\"mount --bind /mnt/backup /home/partimag/\" ocs_live_run="ocs-sr -q2 -c -j2 -z9p -i 4096 -sfsck -scs -senc -p choose savedisk default-img sda" ocs_live_extra_param="" ocs_live_batch="no" vga=788 toram=live,syslinux,EFI,boot,.disk,utils ip= net.ifnames=0  splash i915.blacklist=yes radeonhd.blacklist=yes nouveau.blacklist=yes vmwgfx.enable_fbdev=1
  $initrd_cmd /live/initrd.img0
--
這是 Google 網路論壇針對「再生龍clonezilla」群組發送的訂閱通知郵件。
如要取消訂閱這個群組並停止接收來自這個群組的郵件,請傳送電子郵件到 ocs-clonezill...@googlegroups.com
如要查看這個討論,請前往 https://groups.google.com/d/msgid/ocs-clonezilla/5ecb426f-bda1-43b4-b829-441ec4a75085n%40googlegroups.com
-- 
Steven Shiau <steven _at_ stevenshiau org>
Public Key Server PGP Key ID: 4096R/163E3FB0
Fingerprint: EB1D D5BF 6F88 820B BCF5  356C 8E94 C9CD 163E 3FB0
--
這是 Google 網路論壇針對「再生龍clonezilla」群組發送的訂閱通知郵件。
如要取消訂閱這個群組並停止接收來自這個群組的郵件,請傳送電子郵件到 ocs-clonezill...@googlegroups.com

willie lin

unread,
May 18, 2026, 3:51:32 AM (8 days ago) May 18
to 再生龍clonezilla
1.是改 ocs_prerun="mount /dev/sda1 改成  mount /dev/ ocs-sd02 ???
     應該說:我們公司的裝置有可能是 USB+ NVME、USB +SSD,或USB+MSATA,但USB是固定的,固定放IMAGE的地方。備份跟還原都從這。這樣怎麼做?
                      有一種方式,如下圖:是否可行。如果可以,該怎麼做?
                       Clonezilla.png

3.我的意思是,,如果,我是用 -enc 不要跳出 輸入密碼的畫面,密碼,可以藏在檔案( -enc   \grub\clonezilla.txt之類 )或參數,(如 -enc  XXXX  )?是否可行。
Steven Shiau 在 2026年5月16日 星期六上午9:32:22 [UTC+8] 的信中寫道:
Reply all
Reply to author
Forward
0 new messages