View USB device name and use USB device under Linux system

Source: Internet
Author: User
Tags dmesg

1, after the system plugged into the USB device, from the console interface has the following prompt:

From the console information, you can see the inserted USB device name.

As you can see, the plugged-in USB device is sde4.

However, if the CRT tool is remotely connected to the past, you can use the following command to view the USB device.

2. Use the LSBLK command to find the USB device name

The lsblk command lists information for all available block devices and can also show dependencies between them, but it does not list the RAM disk information. Block devices have hard drives, flash drives, CD-ROMs and so on.

As shown below:

[[email protected] ~]# lsblk--partition before inserting USB device name Maj:min RM SIZE RO TYPE MOUNTPOINTSDA 8:0 0 20G 0 disk├─sda1 8:1 0 500M 0 part/boot└─sda2 8:2 0 19.5G 0 part├─rhe  L-root 253:0 0 17.5G 0 LVM/└─rhel-swap 253:1 0 2G 0 LVM [swap]sdb 8:16 0 6G  0 disk├─sdb1 8:17 0 100M 0 part├─sdb2 8:18 0 110M 0 part└─sdb3 8:19 0 120M 0 Part SDC 8:32 0 5G 0 disk├─sdc1 8:33 0 100M 0 part│└─vgdate-lvvol1 253: 2 0 292M 0 lvm/lvmfiles├─sdc2 8:34 0 200M 0 part│└─vgdate-lvvol1 253:2 0 292M 0 Lvm/lvmfi LES├─SDC3 8:35 0 200M 0 part└─sdc4 8:36 0 250M 0 part SDD 8:48 0 2 G 0 Disk sr0 11:0 1 1024M 0 rom [[email protected] ~]# lsblk--partition after inserting USB device name M Aj:min RM SIZE RO TYPEMOUNTPOINTSDA 8:0 0 20G 0 disk├─sda1 8:1 0 500M 0 part/boot└─sda2 8                 : 2 0 19.5G 0 part├─rhel-root 253:0 0 17.5G 0 LVM/└─rhel-swap 253:1 0 2G 0 LVM [swap]sdb 8:16 0 6G 0 disk├─sdb1 8:17 0 100M 0 part├─sdb2 8:18 0 110M 0 part  └─SDB3 8:19 0 120M 0 part SDC 8:32 0 5G 0 disk├─sdc1 8:33 0 100M 0 part│└─vgdate-lvvol1 253:2 0 292M 0 lvm/lvmfiles├─sdc2 8:34 0 200M 0 part│└─vgdate-lvvol1 25                 3:2 0 292M 0 lvm/lvmfiles├─sdc3 8:35 0 200M 0 part└─sdc4 8:36 0 250M 0 Part SDD 8:48 0 2G 0 disk sde 8:64 1 7.5G 0 disk└─sde4 8:68 1 7.5G 0 PA  RT sr0 11:0 1 1024M 0 rom [[email protected] ~]#
From the above output information can be seen, the device is SDE, for the first partition sde4, the size of 7.5GB
SDE 8:64 1 7.5G 0 disk└─sde4 8:68 1 7.5G
3. Use the Fdisk tool to identify the USB device name

Fdisk is a powerful tool for viewing all the partition tables in your system, including all USB devices, using root privileges to execute the following commands:

[[email protected] ~]# fdisk-ldisk/dev/sda:21.5 GB, 21474836480 bytes, 41943040 sectorsunits = sectors of 1 * 512 = Bytessector Size (logical/physical): bytes/512 bytesi/o size (minimum/optimal): bytes/512 bytesdisk Labe L type:dosdisk identifier:0x0006c7ae Device Boot Start End Blocks Id system/dev/sda1 * 2 048 1026047 512000 linux/dev/sda2 1026048 41943039 20458496 8e Linux lvmdisk/dev/sdb:644 2 MB, 6442450944 bytes, 12582912 sectorsunits = sectors of 1 * = bytessector size (logical/physical): Bytes/      BYTESI/O size (minimum/optimal): bytes/512 bytesdisk label Type:dosdisk identifier:0xaa06e007 Device Boot          Start End Blocks Id system/dev/sdb1 2048 206847 102400 8e Linux lvm/dev/sdb2  206848 432127 112640 8e linux lvm/dev/sdb3 432128 677887 122880 8e Linux Lvmdisk /dev/sdc:5368 MB, 5368709120 bytes, 10485760 sectorsunits = sectors of 1 * MB = bytessector size (logical/physical): bytes/512 Bytesi         /o Size (minimum/optimal): bytes/512 bytesdisk label Type:dosdisk identifier:0x0c16d904 Device Boot Start End Blocks Id system/dev/sdc1 2048 206847 102400 8e Linux LVM/DEV/SDC2 206         848 616447 204800 8e linux lvm/dev/sdc3 616448 1026047 204800 8e Linux LVM/DEV/SDC4 1026048 1538047 256000 8e Linux lvmdisk/dev/sdd:2147 MB, 2147483648 bytes, 4194304 sectorsunits = Sector S of 1 * bytessector = size (logical/physical): bytes/512 bytesi/o size (minimum/optimal): bytes/512 b Ytesdisk label Type:dosdisk identifier:0x3990990c Device Boot Start End Blocks Id Systemdisk/dev /mapper/rhel-root:18.8 GB, 18756927488 bytes, 36634624 sectorsunits = sectors of 1 * = bytessector size (logical/ Physical): BYTES/5BYTESI/O size (minimum/optimal): bytes/512 bytesdisk/dev/mapper/rhel-swap:2147 MB, 2147483648 bytes, 4194304 se Ctorsunits = sectors of 1 * bytessector size (logical/physical): bytes/512 bytesi/o size (minimum/optimal)  : bytes/512 bytesdisk/dev/mapper/vgdate-lvvol1:306 MB, 306184192 bytes, 598016 sectorsunits = sectors of 1 * 512 = Bytessector size (logical/physical): bytes/512 bytesi/o size (minimum/optimal): + bytes/512 bytesdisk/dev/ sde:8022 MB, 8022654976 bytes, 15669248 sectorsunits = sectors of 1 * = bytessector size (logical/physical): 512  bytes/512 bytesi/o Size (minimum/optimal): bytes/512 bytesdisk label Type:dosdisk Identifier:0xcad4ebea Device Boot Start End Blocks Id system/dev/sde4 * 15669184 7834561 7 HPFS/NTFS/EXF  At[[email protected] ~]#

The following information can be seen from the USB device:

disk/dev/sde:8022 MB, 8022654976 bytes, 15669248 sectorsunits = sectors of 1 * = bytessector size (logical/physi CAL): bytes/512 bytesi/o size (minimum/optimal): bytes/512 bytesdisk label Type:dosdisk Identifier:0xcad4ebe A   Device Boot      Start         End      Blocks   Id  system/dev/sde4   *    15669184     7834561    7  Hpfs/ntfs/exfat
Use the DMESG command to identify the USB device name

DMESG is an important command for printing or controlling the kernel ring buffer. A ring buffer is a data structure that holds information about the operating data of the kernel.

Run the following command to view the kernel operation information, which also prints out the information for the USB device:

...... [1055.720971] sde:sde4[1055.816921] SD 6:0:0:0: [SDE] attached SCSI removable disk[1168.185175] USB 1-1: USB Disconne CT, device number 6[1250.915177] USB 1-1: New Full-speed USB device number 7 using ohci-pci[1251.361378] USB 1-1: New US B device found, idvendor=8644, idproduct=800b[1251.364410] USB 1-1: New USB device Strings:mfr=1, product=2, Serialnumbe                       r=3[1251.367812] USB 1-1: Product:usb Flash Disk [1251.370072] USB 1-1: manufacturer:general [1251.372505] USB 1-1: serialnumber:000000000000c4fc[1251.378864] usb-storage 1-1:1.0:usb Mass Storage Dev Ice detected[1251.383180] scsi host7:usb-storage 1-1:1.0[1252.415350] SCSI 7:0:0:0: direct-access General USB Flas H Disk 1.00 pq:0 ansi:2[1252.424925] SD 7:0:0:0: attached SCSI generic SG5 type 0[1252.451723] SD 7:0:0:0: [SDE] 156 69248 512-byte Logical blocks: (8.02 gb/7.47 GiB) [1252.481780] SD 7:0:0:0: [SDE] Write Protect is off[1252.484715] SD 7: 0:0:0: [SDE] Mode Sense:03 xx 00[1252.507694] sd 7:0:0:0: [SDE] No Caching mode page found[1252.510073] SD 7:0:0:0: [SDE] Assuming drive C Ache:write through[1252.624206] sde:sde4[1252.722176] SD 7:0:0:0: [SDE] attached SCSI removable Disk[[email prot  Ected] ~]#

In fact, the information above is the output from the server console when the USB device is plugged in.

to view files within a USB device:

As can be seen from the above information, although the USB device has been plugged into the Linux system, but the mount point mounted on is empty, that is, has not completed the mount, must be mounted before use.

[Email protected] ~]# mkdir-p/mnt/myusb[[email protected] ~]# mount/dev/sde4/mnt/myusb/mount:unknown filesystem type ' NTFS ' [[email protected] ~]# df-htfilesystem                Type      Size  used Avail use% mounted On/dev/mapper/rhel-root     xfs        18G  4.6G   13G  26%/devtmpfs                  devtmpfs  911M     0  911M   0%/DEVTMPFS                     tmpfs     921M     0  921M   0%/dev/shmtmpfs                     tmpfs     921M  8.4M  912M   1%/ Runtmpfs                     tmpfs     921M     0  921M   0%/sys/fs/cgroup/dev/sda1                 xfs       497M  124M  374M  25%/boot/dev/mapper/vgdate-lvvol1 xfs       289M   16M  274M   6%/lvmfilestmpfs                     Tmpfs     185M     0  185M   0%/run/user/0

Reformat to EXT4 format:

[Email protected] ~]# mkfs.ext4/dev/sde4mke2fs 1.42.9 (28-dec-2013) Filesystem label=os type:linuxblock size=4096 (log= 2) Fragment size=4096 (log=2) stride=0 blocks, Stripe width=0 blocks490560 inodes, 1958640 blocks97932 blocks (5.00%) Reserv Ed for the Super Userfirst data block=0maximum filesystem blocks=200697446460 block groups32768 blocks per group, 32768 fr Agments per group8176 inodes per groupsuperblock backups stored on blocks:         32768, 98304, 163840, 229376, 294912, 81920 0, 884736, 1605632Allocating group Tables:done                            Writing inode tables:done                            Creating Journal (32768 blocks): DONEWR Iting Superblocks and FileSystem accounting information: Done      

After re-mounting, you can use the following:

[[email protected] ~]# mount/dev/sde4/mnt/myusb/[[email protected] ~]# Cd/mnt/myusb/[[email protected] myusb]# touch te Stmyusb[[email protected] myusb]# Lslost+found  

Use the DF-HT command to view mounted USB devices:

[Email protected] myusb]# df-htfilesystem                Type      Size  used Avail     use% mounted On/dev/mapper/rhel-root XFS        18G  4.6G   13G  26%/devtmpfs                  devtmpfs  911M     0  911M   0%/devtmpfs                     Tmpfs     921M     0  921M   0%/dev/shmtmpfs                     tmpfs     921M  8.4M  912M   1%/ Runtmpfs                     tmpfs     921M     0  921M   0%/sys/fs/cgroup/dev/sda1                 xfs       497M  124M  374M  25%/boot/dev/mapper/vgdate-lvvol1 xfs       289M   16M  274M   6%/lvmfilestmpfs                     Tmpfs     185M     0  185M   0%/run/user/0/dev/sde4                 ext4      7.3G   34M  6.9G   1%/ Mnt/myusb   

  

View USB device name and use USB device under Linux system

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.