如何在 USB 闪存驱动器上安装 Kali Linux

如何在 USB 闪存驱动器上安装 Kali Linux

我想知道有没有办法在 USB 驱动器而不是 SSD 上安装 Kali Linux。我有一个 32GB 闪存驱动器,我想使用它来代替 SSD 分区。这样做的原因是我想定制我的 Kali Linux。它已经可以从实时 USB 启动。

答案1

就可以正常安装了!

只需插入 USB 启动并选择它即可。

如果您想在运行当前操作系统时安装它,请安装 KVM 并使用以下命令:

  cdRom=/path/to/kali.iso
  HDA=/dev/sd[x] # e.g /dev/sda (a hd not part like /dev/sda1) use lsblk
  kvm -cdrom "$cdRom" -hda "$HDA" -m 1024 -boot d

你可以用这个脚本

#!/bin/bash
((!EUID)) || exec sudo "$0"
#NOTE : don't use $HOME var in your paths , because the script will restart as root
# which means if you have var=$HOME/file.iso , when script re-exec itself 
# your var will be "/root/file.iso" not "/home/user/file.iso"
xCdImageDirectory=/home/younes/Documents/library/application/x-cd-image
xRawDiskImageDirectory=/home/younes/Documents/library/application/x-raw-disk-image
defaultHardDrive=$xRawDiskImageDirectory/`basename $0`.img #creat a default raw-img if like testing os's
function bootXCdImage() {
  kvm -cdrom "$1" -hda "$2" -m 1024 -boot d
}
function bootXRawDiskImage() {
  kvm -hda "$1" -m 1024
}

echo -n "bootType : 1=>isoImage , 2=>rawImage,   ??: "
read bootType
case $bootType in
  1 )
    echo "pick an XCdImage!"
    ls $xCdImageDirectory/ | nl
    read n
    ((${#n})) && {
    xCdImage=$(ls $xCdImageDirectory/* | sed -n "$n p")
    echo "selected image : $xCdImage"
    } || {
        echo "nothing done"
        exit
    }
    echo "pick a hard drive to use ! sdX or sdXY or empty for default image.img"
    lsblk | grep --color=auto 'sd[a-z]'
    read hardDrive
    [[ -n $hardDrive ]] && {
        hardDrive=/dev/$hardDrive
    } || {
        [[ -f $defaultHardDrive ]] && {
            hardDrive=$defaultHardDrive
        } || {
        echo "$defaultHardDrive does not exist !"
        exit
        }
    }
    echo "selected harddrive: $hardDrive"
    bootXCdImage "$xCdImage" "$hardDrive"
    ;;
  2 )
    echo "pick an XRawDiskImage!"
    ls $xRawDiskImageDirectory/ | nl
    read n
    ((${#n})) && {
        xRawDiskImage=$(ls $xRawDiskImageDirectory/* | sed -n "$n p")
        [[ -f $xRawDiskImage ]] || {
            echo "$xRawDiskImage does not exist !"
            exit
        }
        bootXRawDiskImage "$xRawDiskImage"
        } || {
        echo "nothing done"
        exit
    }
    ;;
  * )
    echo "nothing done!"
    ;;
esac
exit

答案2

从 USB 驱动器启动时,您必须在启动选项中启用持久性。这样您就可以将设置和数据保存到 USB 驱动器中。更多信息在 Kali Linux 官方页面

相关内容