How can we help?
Смотрим как в системе называется наша Kali Linux Live USB:
sudo lsbk
┌──(kali㉿kali)-[~/Downloads]
└─$ sudo lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
loop0 7:0 0 3.1G 1 loop /usr/lib/live/mount/rootfs/filesystem.squashfs
/run/live/rootfs/filesystem.squashfs
sda 8:0 1 7.5G 0 disk
├─sda1 8:1 1 3.6G 0 part /usr/lib/live/mount/medium
│ /run/live/medium
└─sda2 8:2 1 896K 0 part
nvme0n1 259:0 0 476.9G 0 disk
├─nvme0n1p1 259:1 0 100M 0 part
├─nvme0n1p2 259:2 0 16M 0 part
├─nvme0n1p3 259:3 0 476.3G 0 part
└─nvme0n1p4 259:4 0 521M 0 part
Пишем название нашей Kali Linux Live USB (/dev/sda) в переменную :
usb=/dev/sda
И создаем новый раздел на /dev/sda:
sudo fdisk $usb <<< $(printf "n\np\n\n\n\nw")
┌──(kali㉿kali)-[~/Downloads]
└─$ usb=/dev/sda
┌──(kali㉿kali)-[~/Downloads]
└─$ sudo fdisk $usb <<< $(printf "n\np\n\n\n\nw")
Welcome to fdisk (util-linux 2.38).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
This disk is currently in use - repartitioning is probably a bad idea.
It's recommended to umount all file systems, and swapoff all swap
partitions on this disk.
The device contains 'iso9660' signature and it may remain on the device. It is recommended to wipe the device with wipefs(8) or fdisk --wipe, in order to avoid possible collisions.
Command (m for help): Partition type
p primary (2 primary, 0 extended, 2 free)
e extended (container for logical partitions)
Select (default p): Partition number (3,4, default 3): First sector (7458304-15794175, default 7458816): Last sector, +/-sectors or +/-size{K,M,G,T,P} (7458816-15794175, default 15794175):
Created a new partition 3 of type 'Linux' and of size 4 GiB.
Command (m for help): The partition table has been altered.
Syncing disks.
Далее размечаем полученный раздел:
sudo mkfs.ext4 -L persistence ${usb}3
┌──(kali㉿kali)-[~/Downloads]
└─$ usb=/dev/sda
┌──(kali㉿kali)-[~/Downloads]
└─$ sudo mkfs.ext4 -L persistence ${usb}3
mke2fs 1.46.5 (30-Dec-2021)
Creating filesystem with 1041920 4k blocks and 260608 inodes
Filesystem UUID: e20be7f8-146a-42be-81d8-bb4ad53d89e2
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736
Allocating group tables: done
Writing inode tables: done
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information:
done
Создаем точку монтирования:
sudo mkdir -p /mnt/my_usb
Монтируем туда новый раздел:
sudo mount ${usb}3 /mnt/my_usb
Создаем файл конфигурации, чтобы включить сохраняемость:
echo "/ union" | sudo tee /mnt/my_usb/persistence.conf
Ну и наконец, размонтируем раздел:
sudo umount ${usb}3
┌──(kali㉿kali)-[~/Downloads]
└─$ usb=/dev/sda
┌──(kali㉿kali)-[~/Downloads]
└─$ usb=/dev/sda
┌──(kali㉿kali)-[~/Downloads]
└─$ sudo mkdir -p /mnt/my_usb
┌──(kali㉿kali)-[~/Downloads]
└─$ sudo mount ${usb}3 /mnt/my_usb
┌──(kali㉿kali)-[~/Downloads]
└─$ echo "/ union" | sudo tee /mnt/my_usb/persistence.conf
/ union
┌──(kali㉿kali)-[~/Downloads]
└─$ sudo umount ${usb}3