通常、Live USBでのブートでは変更内容が保持されませんが、persistence領域を作成することで、ここに変更内容が保持されます。
Kali Linux Live USB Persistence
https://docs.kali.org/downloading/kali-linux-live-usb-persistence
- Live USBで起動
- ターミナル起動
- fdiskでパーティション作成
- ファイルシステム作成
- persistence領域の設定
起動するとrootで自動ログインされます。
ターミナルを起動してfdiskコマンドで認識されているHDDを確認します。
/dev/sdbがLive USB(64GB)になります。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
root@kali:~# fdisk -l Disk /dev/sda: 20 GiB, 21474836480 bytes, 41943040 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk /dev/loop0: 2.5 GiB, 2679435264 bytes, 5233272 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk /dev/sdb: 58.8 GiB, 63166218240 bytes, 123371520 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: dos Disk identifier: 0xa9ef3e16 Device Boot Start End Sectors Size Id Type /dev/sdb1 * 64 5734399 5734336 2.8G 17 Hidden HPFS/NTFS /dev/sdb2 5734400 5735807 1408 704K 1 FAT12 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
root@kali:~# fdisk /dev/sdb Welcome to fdisk (util-linux 2.31.1). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. Command (m for help): n Partition type p primary (2 primary, 0 extended, 2 free) e extended (container for logical partitions) Select (default p): p Partition number (3,4, default 3): First sector (5735808-123371519, default 5736448): Last sector, +sectors or +size{K,M,G,T,P} (5736448-123371519, default 123371519): Created a new partition 3 of type 'Linux' and of size 56.1 GiB. Command (m for help): w The partition table has been altered. Syncing disks. root@kali:~# fdisk -l Disk /dev/sda: 20 GiB, 21474836480 bytes, 41943040 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk /dev/loop0: 2.5 GiB, 2679435264 bytes, 5233272 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk /dev/sdb: 58.8 GiB, 63166218240 bytes, 123371520 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: dos Disk identifier: 0xa9ef3e16 Device Boot Start End Sectors Size Id Type /dev/sdb1 * 64 5734399 5734336 2.8G 17 Hidden HPFS/NTFS /dev/sdb2 5734400 5735807 1408 704K 1 FAT12 /dev/sdb3 5736448 123371519 117635072 56.1G 83 Linux |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
root@kali:~# mkfs -t ext3 -L persistence /dev/sdb3 mke2fs 1.44.1 (24-Mar-2018) Creating filesystem with 14704384 4k blocks and 3678208 inodes Filesystem UUID: eb394249-ee87-4793-8b17-92d2fb631ace Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000, 7962624, 11239424 Allocating group tables: done Writing inode tables: done Creating journal (65536 blocks): done Writing superblocks and filesystem accounting information: done |
1 2 3 4 5 6 |
root@kali:~# e2label /dev/sdb3 persistence root@kali:~# mount /dev/sdb3 /mnt root@kali:~# echo "/ union" > /mnt/persistence.conf root@kali:~# cat /mnt/persistence.conf / union root@kali:~# umount /mnt |
これで次回起動に「Live USB persistence」を選択するれば、/dev/sdb3がpersistence領域としてマウントされて、変更内容がここにoverwriteされます。
試しにapt update,apt upgradeを実行してみましたが大丈夫でした。