0

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.

--

joseph22
  • 509

0 Answers0