using
Ubuntu 20.04.4 LTS (Focal Fossa)
GNU bash, version 5.1.16(1)
List all drives: UNmounted and mounted
lsblk --noheadings --raw | awk '{print substr($0,0,4)}' | uniq -c | grep 1 | awk '{print "/dev/"$2}' ;
/dev/loop
/dev/sda
/dev/sda1
/dev/sda2
/dev/sda5
/dev/sdb
/dev/sdb1
/dev/sdc
/dev/sdd
/dev/sdd1
From above bash, we have 2 usb sticks c and d as:
/dev/sdc FAT (32-bit version)
/dev/sdd
/dev/sdd1 FAT (32-bit version)
How come sdd has 2 entries?
/dev/sdd
/dev/sdd1 FAT (32-bit version)
How to format usb sdc to get 2 entries like sdd above?
Why?
Because it seems that 2 entries behaves better for
UNmounting usb manually via DISKs and
mounting usb via a bash script below.
Show UNmounted drives and Show Extended Partition Types:
lsblk --noheadings --raw -o NAME,MOUNTPOINT | awk '$1~/[[:digit:]]/ && $2 == ""' ;
Show stats: UNmounted drives and Extended Partition Type:
lsblk --noheadings --raw | awk '$1~/s.*[[:digit:]]/ && $7==""' ;
Mount drives via bash. Then do virus scanning:
lsblk --noheadings --raw | awk '{print substr($0,0,4)}' | uniq -c | grep 1 | awk '{print "/dev/"$2}' | grep -E "(/dev/sd.)[[:digit:]]" | xargs -I{} -n1 udisksctl mount -b {} ;
Mounted /dev/sdd1 at /media/u3/USBstick
/dev/sdc FAT (32-bit version)
is manually UNmounted and
above bash script does not mount /dev/sdc
/dev/sdd
/dev/sdd1 FAT (32-bit version)
is manually UNmounted and
above bash script works.
Mounts sdd
Target is to have bash script mount all drives before a virus scan.
Explain.
Why sdc is only 1 entry versus 2 for sdd?
/dev/sdc FAT (32-bit version)
/dev/sdd
/dev/sdd1 FAT (32-bit version)
Explain.
How to format sdc?
So sdc responds to above bash mount script
like sdd responds.
--
sddis a whole block device.sdd1is the first partition within the device. See a table in this answer. A setup where there is no partition table and a filesystem takes the whole device is called "superfloppy". See this question: Uses of single-partition disk configuration. The fact you and your script are confused kinda confirms what I said in my answer there. – Kamil Maciorowski Jun 10 '22 at 04:09sdcmeaningsdc1is absent . 2. Format usb bysudo mkfs.vfat /dev/sdcresults with messagemkfs.fat 4.1 (2017-01-24)and
– joseph22 Jun 10 '22 at 14:07mkfs.vfat: unable to open /dev/sdc: No medium found. How to format usb? to reach the targetsdcwithsdc1being the first partition within the device. i understand 'Programs may expect a partition table first, a filesystem later.' i understand this means the mount script expectssdcwith partitionsdc1.$ lsblk -o PATHreplaces most parts of your initial thing ending in "awk". – Hannu Jun 10 '22 at 17:38$ lsblk -o PATHworks, meaning, List all drives: UNmounted and mounted, but 16 items were Listed and are of no interest, being/dev/loop0to/dev/loop15. The first script of 102 characters shortens uninteresting data to 1 item/dev/loop. i read/dev/loopXare virtual devices, read only, connected to the snapd service, extra loop devices added for every software you install using "snap" and/dev/loopXcan be removed by uninstalling the app via snapd. Any ideas how to format usb? to getsdcandsdc1. – joseph22 Jun 10 '22 at 20:18