Thumb drive format (lesson)
introduction
You may want to format a thumb drive so it can be used in a Windows machine.
You would do this, if like me you have previously placed a live boot image on a thumb drive and you don't have any other spare thumb drives.
If the thumb drive is small enough you can back it up on your linux laptop or on the raspberry pi if you have spare storage or connect an USB external drive to the pi.
requirements
- a linux laptop (or a raspberry pi/pi400)
- a thumb drive of some size that you are prepared to erase.
- root or sudo access (the default pi images puts your initial user in sudo group)
instructions
desktop
- download gparted
sudo apt install gparted
- identify your drives before inserting the thumb drive
lsblk
- identify your drives after inserting the thumb drive
lsblk
The thumb drive will be like be /dev/sda if you have no other disk drives in your raspberry pi, but on the laptop it may be /dev/sdb or even later if you have more than one disk drive in your debian/ubuntu laptop.
The identified device will be what you choose from the gparted devices menu.
- start gparted
sudo gparted
- select the correct device from the devices menu
Now a FAT32 disk can be GPT or MBR paritioned. MBR is old so we are going to use GPT.
- Select the live partition >> umount
- select the live partition >> format it as empty
- Edit (menu) >> apply all actions
- Partition (menu) >> create new partition >> GPT
- Edit (menu) >> apply all actions
- Select the empty space >> format as FAT32
- Edit (menu) >> apply all actions
- File (menu) >> exit
You are now complete. If you remove the thumb drive and re-insert it, it will be automatically mounted and you can then use the File Explorer to examine it. It should be empty.
- You can find where it is mounted via:
lsblk
- then you can list the files on it via
ls /mnt/<yourname>/<tab>
You can then eject it from the file explorer or via (on a pi with no drives):
sudo umount /dev/sda