[Tips] Persistence of Kali Linux Live Image with USB memory

Overview

It's just a memorandum for myself. The referenced manual is below.

Adding Persistence to a Kali Linux "Live" USB Drive

Preparation: Burn Kali Linux to USB stick

Burn the Kali Linux Live Image to a USB memory in advance by referring to the following. Burn with Etcher for Windows or dd command for Linux.

Making a Kali Bootable USB Drive

Check disk size

This time, it was carried out with a 32GB USB memory. The effective capacity is 28.93 GiB.

┌─[[email protected]]─[/home/jangari]
└──╼ #fdisk -l

Disk /dev/sdb: 28.93 GiB, 31042043904 bytes, 60628992 sectors
Disk model: USB Flash Disk  
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: 0xfb0b3988

Device     Boot   Start     End Sectors  Size Id Type
/dev/sdb1  *         64 5898239 5898176  2.8G 17 Hidden HPFS/NTFS
/dev/sdb2       5898240 5899711    1472  736K  1 FAT12

Cut additional partitions

The starting position is as per the manual, starting right next to the ISO size of Live Image. The end position is 28gb with a margin from the disk size.

┌─[[email protected]]─[/home/jangari]
└──╼ #end=28gb
┌─[[email protected]]─[/home/jangari]
└──╼ #read start _ < <(du -bcm /home/jangari/Downloads/kali-linux-2020.2-live-amd64.iso | tail -1); echo $start
2882

If you try to partition with parted, it's not the most recent optimal starting point I get a warning that the alignment is out of alignment. It's sunny, so give a proper starting point Make a note and cancel it.

┌─[[email protected]]─[/home/jangari]
└──╼ #parted /dev/sdb mkpart primary $start $end
Warning: You requested a partition from 2882MB to 28.0GB (sectors 5628906..54687500).
The closest location we can manage is 3021MB to 28.0GB (sectors 5899712..54687500).
Is this still acceptable to you?
Yes/No? Yes                                                               
Warning: The resulting partition is not properly aligned for best performance:
5899712s % 2048s != 0s
Ignore/Cancel? Cancel
┌─[✗]─[[email protected]]─[/home/jangari]
└──╼ #

Specify the start point again and cut the partition.

┌─[[email protected]]─[/home/jangari]
└──╼ #parted /dev/sdb mkpart primary 3021MB $end
Information: You may need to update /etc/fstab.

┌─[[email protected]]─[/home/jangari]                                           
└──╼ #fdisk -l

Disk /dev/sdb: 28.93 GiB, 31042043904 bytes, 60628992 sectors
Disk model: USB Flash Disk  
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: 0xfb0b3988

Device     Boot   Start      End  Sectors  Size Id Type
/dev/sdb1  *         64  5898239  5898176  2.8G 17 Hidden HPFS/NTFS
/dev/sdb2       5898240  5899711     1472  736K  1 FAT12
/dev/sdb3       5900288 54687743 48787456 23.3G 83 Linux

Creating a file system

This time I made ext4 with mkfs.ext4. The label should be persistence.

┌─[[email protected]]─[/home/jangari]
└──╼ #mkfs.ext4 -L persistence /dev/sdb3
mke2fs 1.45.6 (20-Mar-2020)
Creating filesystem with 6098432 4k blocks and 1525920 inodes
Filesystem UUID: 181ecc87-e2fd-4c2d-8feb-d2ee3655d23c
Superblock backups stored on blocks: 
	32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
	4096000

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

Make a mount point and check if it can be mounted.

┌─[[email protected]]─[/home/jangari]
└──╼ #mkdir /mnt/my_usb
┌─[[email protected]]─[/home/jangari]
└──╼ #mount /dev/sdb3 /mnt/my_usb
┌─[[email protected]]─[/home/jangari]
└──╼ #mount | grep /dev/sdb3
/dev/sdb3 on /mnt/my_usb type ext4 (rw,relatime)

Live Image Persistence Settings

Create persistence.conf.

┌─[[email protected]]─[/home/jangari]
└──╼ #echo "/ union" > /mnt/my_usb/persistence.conf
┌─[[email protected]]─[/home/jangari]
└──╼ #ls -l /mnt/my_usb/persistence.conf 
-rw-r--r-- 1 root root 8 Jun  8 16:20 /mnt/my_usb/persistence.conf

Unmount when finished.

┌─[[email protected]]─[/home/jangari]
└──╼ #umount /mnt/my_usb
┌─[[email protected]]─[/home/jangari]
└──╼ #mount | grep /dev/sdb3
┌─[✗]─[[email protected]]─[/home/jangari]
└──╼ #

in conclusion

end!

Recommended Posts

[Tips] Persistence of Kali Linux Live Image with USB memory
Create a permanent write area on Kali Linux with USB memory boot
Check the memory status of the server with the Linux free command
Check the memory protection of linux kerne with the code for ARM
Command to create Linux Live USB
Make Live USB on Alpine Linux
Using Kali Linux Gui with WSL2
Basics of binarized image processing with Python
Drawing with Matrix-Reinventor of Python Image Processing-