LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   USB FORMAT (https://www.linuxquestions.org/questions/linux-software-2/usb-format-4175679690/)

CrazyCatLover 07-31-2020 02:04 AM

USB FORMAT
 
Hi,
I am using Debian. When I plug in a USB, it auto mounts as a media. How do I make it mount as a device cause I need to format it. Thanks.

pan64 07-31-2020 02:28 AM

you do not need to mount it if you want to format it. Just umount and format.

syg00 07-31-2020 02:47 AM

Depending on DE, you may need to do that from the terminal. If you use the GUI to eject it, it may destroy the device node as well. Gnome (3) seems to.

GPGAgent 07-31-2020 03:30 AM

try this: https://tecadmin.net/format-usb-in-linux/

hazel 07-31-2020 05:57 AM

Devices exist from the moment that the kernel recognises them, which in the case of usb keys is just after you have plugged them in. The kernel recognises the key as a whole (for example it might call it sdb) and also any partitions on it (sdb1, etc). A program called udev will immediately create the corresponding device files (/dev/sdb, /dev/sdb1). From that point onwards, you can format any partition on the device or you can repartition it. These are both operations that are carried out on the raw device file. They have nothing to do with mounting.

If the device or a partition on it contains a filesystem, this can be mounted to access the files that it contains. But you should not try to format it when it is mounted. That leads to data corruption.

A complicating fact is that some desktops automatically mount any filesystems they find on plug-in devices. This is convenient for users but also very confusing to newbies, as it blurs the distinction between a raw device and the files and directories that it contains. In Windows that distinction doesn't really exist; in Linux and all Unixes, it is fundamental. As Pan64 says, if a partition on your devices gets automounted in this way, you must unmount it before you can format it.

kilgoretrout 07-31-2020 07:24 AM

Quote:

Depending on DE, you may need to do that from the terminal. If you use the GUI to eject it, it may destroy the device node as well. Gnome (3) seems to.
So does KDE IIRC. So you probably have to use the command line to unmount the usb drive before you can format it. A GUI option would be using gparted. Install it with:
Code:

# apt install gparted
Then launch gparted; it will ask for the admin password. Once gparted is open, go to your usb drive partition, right click on it and choose the "Unmount" option. After the usb partition is unmounted, you can format the partition by right clicking on it once again and choose the "Format to" option.

hazel 07-31-2020 07:41 AM

You see how needlessly complicated these "user-friendly" desktops make things!

jefro 07-31-2020 03:22 PM

Side note.
"USB, it auto mounts as a media."
You may mean it mounts under /media?

mrmazda 07-31-2020 07:37 PM

Or /run/media?

Skaperen 07-31-2020 09:25 PM

don't eject it (that's the equivalent of having the CD tray open up to let you pick up the CD). just unmount it (as in the umount command). if you are not using command line and expect to use a GUI formatter, then choose one that knows how to unmount it or find a way to do it in GUI or learn to use command line.

CrazyCatLover 07-31-2020 10:52 PM

Hi, I managed to unmount it but i cant create a physical volume with it. It mentions like device excluded by a filter, so i check online and was told to use wipefs, but i cant find the package in debian, i read it may be under util-linux which i have already installed. So i have no idea what i should do now?
I am using the debian instructions from below.
https://wiki.debian.org/LVM

ondoho 08-01-2020 04:11 AM

Quote:

Originally Posted by CrazyCatLover (Post 6151543)
Hi, I managed to unmount it but i cant create a physical volume with it. It mentions like device excluded by a filter, so i check online and was told to use wipefs, but i cant find the package in debian, i read it may be under util-linux which i have already installed. So i have no idea what i should do now?
I am using the debian instructions from below.
https://wiki.debian.org/LVM

Sorry, what are you actually trying to accomplish here?

Please, always show us actual commands issued and full output received.
Tell us everything that happened, not a "Reader's Digest".

PS: bonus points for using CODE tags for command output. See my signature.

fatmac 08-01-2020 09:46 AM

USB drives come pre formatted with a MS Windows file system, which will normally get mounted on insertion, if you have automount on.

In such a case, you can use a GUI disk partitioner to unmount it before re partitioning/putting a file system on it.

Or you can unmount it at the command line first, before re partitioning/putting a filesystem onto it.


All times are GMT -5. The time now is 02:57 PM.