Brent’s World Quickie – Using USB Flash Drive From The Terminal On CENTos 7
This week, we are going to look at using a USB Flash Drive from the terminal in CENTos 7
First let’s take a look at XWINDOWS, in the GNOME environment. Mounting the flash drive is easy. We just plug it into our workstation. Since I am running linux in a virtual environment using VMWare Desktop, I need to take one extra step and tell the Virtual host to take possession of the USB Removable Media and disconnect it from the host.
Once this is done, you will see your USB volume mount on the desktop.
We can now open the volume by double clicking it. Notice you see another volume that appears to be mounted called PC TRANS. However when we double click on it, we receive an error. By default Linux cannot read or write to NTFS volumes. If you plan on using a USB flash drive to transfer data between a PC and Linux, or MacOS and Linux. You will want to format the drive FAT32.
Now, how do we access our flash drive from the terminal?
First let’s unmount the flash drive.
Right click on the icon on the desktop and select eject.
Now open a terminal.
Type df –k
Make a note of the mounted volumes.
[root@cr-dev ~]# df -k
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/centos_cr--dev-root 52403200 3087580 49315620 6% /
devtmpfs 1670376 0 1670376 0% /dev
tmpfs 1679956 8 1679948 1% /dev/shm
tmpfs 1679956 8712 1671244 1% /run
tmpfs 1679956 0 1679956 0% /sys/fs/cgroup
/dev/mapper/centos_cr--dev-home 27372484 317496 27054988 2% /home
/dev/sda1 508588 235800 272788 47% /boot
Now remount the flash drive
Perform the df –k again
[root@cr-dev ~]# df -k
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/centos_cr--dev-root 52403200 3087560 49315640 6% /
devtmpfs 1670376 0 1670376 0% /dev
tmpfs 1679956 8 1679948 1% /dev/shm
tmpfs 1679956 8732 1671224 1% /run
tmpfs 1679956 0 1679956 0% /sys/fs/cgroup
/dev/mapper/centos_cr--dev-home 27372484 317496 27054988 2% /home
/dev/sda1 508588 235800 272788 47% /boot
/dev/sdb2 30384752 1713792 28670960 6% /run/media/root/UNTITLED 2
Notice the extra volume /dev/sdb2? Has been mounted as /run/media/root/UNTITLED 2
So if I CD to cd “/run/media/root/UNTITLED 2”
Notice that I put the path in quotes? This is because there is a space between UNTITLED and 2. If I did not put the path in quotes, I would receive an error.
If I do a list (Using the alias for a long listing here)
[root@cr-dev UNTITLED 2]# ll
total 208
-rw-r--r--. 1 root root 146552 Jul 1 18:50 Boeing 777-300ER Normal Checklist.docx
drwx——. 2 root root 16384 Jan 1 2010 BUDA
drwx——. 4 root root 16384 May 8 2014 cr-inet
drwx——. 6 root root 16384 Sep 16 03:55 cr-web2
drwx——. 4 root root 16384 Jun 18 2014 Hongdae – Trick Art Art Museum.aplibrary[root@cr-dev UNTITLED 2]#
We can unmount the USB drive from the terminal using the umount command.
NOTE: You must CD to a directory on a different mount point before ejecting the USB drive or you will receive an error.
umount: /run/media/root/UNTITLED 2: target is busy.
(In some cases useful info about processes that use
the device is found by lsof(8) or fuser(1))
Simply cd to root
# cd /
Now issue the umount command.
\[root@cr-dev /]# umount “/run/media/root/UNTITLED 2”
root@cr-dev /]#
The USB Drive is now unmounted.
Comments
Brent’s World Quickie – Using USB Flash Drive From The Terminal On CENTos 7 — No Comments
HTML tags allowed in your comment: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>