Linux mount command to access filesystems, iso image, usb, network drives


Linux, CheatSheet, How To, What Is

In this article I will cover various topics using Linux mount command to perform temporary and permanent mount. We will try to access file system, USB drives, ISO images, network drives using Linux mount command and unmount them using umount command with examples. before you mount USB drive using Linux mount command, you must know how to list USB drives and check USB ports in Linux so you know the connected USB drives in Linux. I will also share some fstab example, explain fstab options and syntax to mount permanently using Linux mount command.

I have used RHEL/CentOS 7/8 to demonstrate the examples from this article on Linux mount command and it's usage.

 

Linux Mount Command Scenarios and Examples

Below I will cover various scenarios to access file systems temporarily and permanent using Linux mount command with examples.

 

Mount File System (ext3, ext4, xfs and so on..)

Using Linux mount command you can mount various types of system file system. But this will be active only for the current session (not reboot persistent). For such requirement you can use /mnt mount point along with Linux mount command.

Syntax to mount file system

# mount [-t fstype] DEVICE DIR

Here,

-t		The argument following the -t is used to indicate the filesystem type.
DEVICE	Here DEVICE is our File System /dev/sdb1
DIR		Here DIR is our target mount point
NOTE:
If -t option is not given, or if the auto type is specified, mount will try to guess the desired type. Mount uses the blkid library for guessing the file system type; if that does not turn up anything that looks familiar, mount will try to read the file /etc/filesystems, or, if that does not exist, /proc/filesystems.

So we can mount /dev/sdb1 without specifying file system type

# mount /dev/sdb1 /mnt

or with -t option

# mount -t xfs /dev/sdb1 /mnt

To permanently mount file system, you must add device and mount point entry in /etc/fstab

I will create a new mount point directory

# mkdir /mydata

Now we can mount our xfs file system /dev/sdb1 on /mydata mount point.

# mount -t xfs /dev/sdb1 /mydata

But this is again temporary, to mount file system permanently we have to update /etc/fstab in the below fstab format. fstab example from my setup:

# echo "UUID=2c566ef5-fe73-4e1c-aa71-9a8cd77c0b31       /mydata         xfs     defaults        0 0"  >> /etc/fstab

 

How to get UUID and file system type?

To get UUID of a file system using blkid

# blkid /dev/sdb1
/dev/sdb1: UUID="2c566ef5-fe73-4e1c-aa71-9a8cd77c0b31" TYPE="xfs" PARTUUID="09181a39-01"

In the same output you can see the file system type as XFS

 

What are the different fstab options?

In /etc/fstab we have 6 different section per column with different possible options. Each row is broken into six fields of data, separated by whitespace. Below are the different fstab options

  • The device to mount (Here we have used UUID or you can also use /dev/sdb1).
  • The mount point (/mydata).
  • The filesystem type (xfs).
  • The mount options (defaults).
  • Dump level (0). This field is related to the dump command and is rarely used.
  • The fsck pass field (0). A value of 0 means “do not run fsck on this filesystem during system boot,” whereas a value of 1 or higher means “run fsck on this filesystem during system boot.”

 

Mount ISO File

There are two possible scenarios to mount ISO files:

  1. Mount ISO File from Virtual Media
  2. Mount ISO File DVD

In either scenario to mount ISO file you have to use iso9660 as the file system type along with Linux mount command.

NOTE:
On a Linux distro running with GUI, when removable media, such as CD-ROMs or DVDs, are automatically mounted, they are typically made available under the /media directory. On a system that does not have a running GUI, this auto mount process does not take place. You can configure the system so a regular user can mount a removable device by using /etc/fstab entry:

 

Virtual Media ISO Image

On RHEL/CentOS 7 any ISO File on Virtual media is available under /dev/srX file system. For example my ISO File is available under /dev/sr0 and /dev/sr1

# lsscsi
[0:0:0:0]    cd/dvd  VBOX     CD-ROM           1.0   /dev/sr0
[1:0:0:0]    cd/dvd  VBOX     CD-ROM           1.0   /dev/sr1
[2:0:0:0]    disk    ATA      VBOX HARDDISK    1.0   /dev/sda

To mount ISO file from virtual media on /media using Linux mount command:

# mount -t iso9660 /dev/sr0 /media
mount: /media: WARNING: device write-protected, mounted read-only.

To permanently mount ISO file using /etc/fstab we use similar syntax with below fstab format as we used to mount file system. fstab example from my setup

# echo "/dev/sr0        /media         iso9660         defaults        0 0"  >> /etc/fstab

 

ISO DVD Image

If you have an ISO DVD Image File available on your Linux system, you can mount ISO file DVD using again iso9660 as the file system type with Linux mount command:

# mount -t iso9660 -o loop /root/rhel-8.1-x86_64-dvd.iso /media/
mount: /media: WARNING: device write-protected, mounted read-only.

Again to permanently mount ISO DVD File use /etc/fstab we use similar fstab format. Below is fstab example from my setup to mount iso image

# echo "/root/rhel-8.1-x86_64-dvd.iso        /media         iso9660         defaults        0 0"  >> /etc/fstab

 

Mount USB Drive

Before I share the steps to mount USB drive, you must be familiar to check and list USB devices connected to your Linux host and check USB ports. There are various methods and commands available to list USB devices and check USB ports, I will try to share some of them here:

 

6 commands to list USB devices and check USB ports

Below I will share various commands you can use in Linux to view and list connected USB devices to your Linux host and check USB ports.

 

1. Journalctl or /var/log/messages

You can use journalctl or /var/log/messages to check usb ports and list usb devices which were connected to your Linux machine. below is a snippet of my /var/log/messages on RHEL/CentOS 7/8 node. Observe the highlighted section to list USB devices connected.

Nov 20 22:27:33 centos-8 kernel: usb 1-1: new full-speed USB device number 2 using ohci-pci
Nov 20 22:27:33 centos-8 kernel: usb 1-1: config 1 interface 0 altsetting 0 endpoint 0x81 has invalid maxpacket 512, setting to 64
Nov 20 22:27:33 centos-8 kernel: usb 1-1: config 1 interface 0 altsetting 0 endpoint 0x2 has invalid maxpacket 512, setting to 64
Nov 20 22:27:33 centos-8 kernel: usb 1-1: New USB device found, idVendor=0781, idProduct=5567, bcdDevice= 1.00
Nov 20 22:27:33 centos-8 kernel: usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
Nov 20 22:27:33 centos-8 kernel: usb 1-1: Product: Cruzer Blade
Nov 20 22:27:33 centos-8 kernel: usb 1-1: Manufacturer: SanDisk
Nov 20 22:27:33 centos-8 kernel: usb 1-1: SerialNumber: 4C531001480518118400
Nov 20 22:27:33 centos-8 kernel: usb-storage 1-1:1.0: USB Mass Storage device detected
Nov 20 22:27:33 centos-8 kernel: scsi host4: usb-storage 1-1:1.0
Nov 20 22:27:33 centos-8 kernel: usbcore: registered new interface driver usb-storage
Nov 20 22:27:33 centos-8 kernel: usbcore: registered new interface driver uas
Nov 20 22:27:34 centos-8 kernel: scsi 4:0:0:0: Direct-Access     SanDisk  Cruzer Blade     1.00 PQ: 0 ANSI: 6
Nov 20 22:27:34 centos-8 kernel: sd 4:0:0:0: Attached scsi generic sg4 type 0
Nov 20 22:27:34 centos-8 kernel: sd 4:0:0:0: [sdc] 30595072 512-byte logical blocks: (15.7 GB/14.6 GiB)
Nov 20 22:27:34 centos-8 kernel: sd 4:0:0:0: [sdc] Write Protect is off
Nov 20 22:27:34 centos-8 kernel: sd 4:0:0:0: [sdc] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
Nov 20 22:27:34 centos-8 kernel: sdc: sdc1
Nov 20 22:27:34 centos-8 kernel: sd 4:0:0:0: [sdc] Attached SCSI removable disk

 

2. lsusb

You can check usb ports in linux using lsusb. lsusb tool is part of usbutils rpm. So install usbutils to check USB ports in Linux. For example I have a single USB connected on Port 1:

# lsusb -t
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=ohci-pci/12p, 12M
    |__ Port 1: Dev 2, If 0, Class=Mass Storage, Driver=usb-storage, 12M

 

3. lsscsi

You can list all the devices connected to Linux using lsscsi. So to list USB devices also you can use lsscsi command in Linux. Here my USB drive is mounted on /dev/sdc

# lsscsi
[0:0:0:0]    cd/dvd  VBOX     CD-ROM           1.0   /dev/sr0
[1:0:0:0]    cd/dvd  VBOX     CD-ROM           1.0   /dev/sr1
[2:0:0:0]    disk    ATA      VBOX HARDDISK    1.0   /dev/sda
[3:0:0:0]    disk    ATA      VBOX HARDDISK    1.0   /dev/sdb
[4:0:0:0]    disk    SanDisk  Cruzer Blade     1.00  /dev/sdc

 

4. lsblk

Use lsblk to show and list usb devices and partition which are connected to your linux machine.

# lsblk  /dev/sdc
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sdc      8:32   1 14.6G  0 disk
└─sdc1   8:33   1 14.6G  0 part

 

5. blkid

Use blkid to list usb devices and all the required details. As you can see my USB drive is NTFS file system. If you execute blkid without any arguments, it will list all the connected devices to Linux host.

# blkid /dev/sdc1
/dev/sdc1: LABEL="Deepak-16G" UUID="B48646258645E886" TYPE="ntfs" PARTUUID="2633de4d-01"

 

6. fdisk

Using fdisk you can list all the connected storage devices. We will use fdisk to list usb devices. If you have multiple drives connected to your Linux machine then the list can be long, you can look towards the end of fdisk -l output, for example

Disk /dev/sdc: 14.6 GiB, 15664676864 bytes, 30595072 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x2633de4d

Device     Boot Start      End  Sectors  Size Id Type
/dev/sdc1  *     2048 30595071 30593024 14.6G  7 HPFS/NTFS/exFAT

As you see this is dos disk with size of 14.6 GB and type as HPFS/NTFS/exFAT so this is most likely our USb drive, you can again confirm this by using lsscsi or any other commands from above list.

 

USB Drive with NTFS File System

Now that you can list USB devices and check USB ports, to mount USB drive with NTFS file system type using Linux mount command we need ntfs-3g driver in Linux. If you attempt to mount USB drive without ntfs-3g driver then mount will fail

# mount -t ntfs-3g /dev/sdc1 /mnt
mount: /mnt: unknown filesystem type 'ntfs'.
NOTE:
By default NTFS is not supported in RHEL so you must install EPEL repo on RHEL node to access ntfs-3g driver.

ntfs-3g is an NTFS driver, NTFS supports several filename namespaces: DOS, Win32 and POSIX. While the ntfs-3g driver handles all of them, it always creates new files in the POSIX namespace for maximum portability and interoperability reasons

# yum -y install ntfs-3g.x86_64

Create a mount point

# mkdir /mnt/usb

Now try to mount USB drive using Linux mount command

# mount -t ntfs /dev/sdc1 /mnt/usb

Mount is successful

# df -h /mnt/
Filesystem      Size  Used Avail Use% Mounted on
/dev/sdc1        15G  364M   15G   3% /mnt/usb

Use similar fstab format as used in above examples to permanently mount usb drive with ntfs file system type. Below is fstab example to mount usb drive with ntfs file system.

# echo "UUID="B48646258645E886"       /mnt/usb        ntfs    defaults        0 0" >> /etc/fstab

 

USB Drive with FAT32 or vFAT File System

You will list USB devices, check USB ports and use blkid to check the file system type, as you see the file system type of this USB drive is vFAT. To mount USB drive with vfat file system type using Linux mount command we need vfat module.

# blkid /dev/sdc1
/dev/sdc1: LABEL="DEEPAK-16G" UUID="5E92CAC292CA9E41" TYPE="vfat" PARTUUID="2633de4d-01"

Check if vfat module is loaded on the system:

# lsmod | grep vfat 
vfat                   17411  0
fat                    65913  1 vfat

If the vfat is not loaded, load it by running:

# modprobe vfat

Next to mount USB drive with FAT32 or vFAT file system using Linux mount command:

# mount -t vfat /dev/sdc1 /mnt

Similar to NTFS file system type use same fstab format, use below fstab example to mount usb drive permanently using /etc/fstab

# echo "UUID="5E92CAC292CA9E41"       /mnt/usb        vfat    defaults        0 0" >> /etc/fstab

 

Mount Network Drive

I have a NFS server available at 192.168.0.121 and have shared /mydata directory on this server. To mount network drive from NFS

Syntax:

mount -t <fstype> -o vers=<version> <nfs_server>:<shared_path_on_nfs_server> <mount_point_on_localhost>

Mount NFS Network Drive using NFSv4

# mount -t nfs -o vers=4  192.168.0.121:/mydata /mnt

Mount NFS Network Drive using NFSv3

# mount -t nfs -o vers=3  192.168.0.121:/mydata /mnt

To mount network drive permanently use /etc/fstab the fstab format will remain the same, except the first column you have to give NFS server details and the source path. Below is fstab example from my NFS share (/mydata) on 192.168.0.121

# echo "192.168.0.121:/mydata   /mnt    nfs   defaults    0 0" >> /etc/fstab

 

How to unmount file system and other removable devices?

Use umount command to unmount any type of file system, usb drives, network drives or iso images.

umount <mount_point>

So if my file system is mounted on /mnt

# umount /mnt

You may face error "umount: /mnt/usb: target is busy" some times while truing to umount file system. This means that the file system is in use, this error is similar to the error we see in Windows while trying to eject a USB drive "The device is currently in use"

In such case you can use lazy umount using "-l"

# umount -l /mnt/usb

which means as soon as /mnt/usb is not used by any other process, it will unmount itself

Or alternatively you can look for processes which is using /usb/mnt using lsof

# lsof /mnt/usb/
COMMAND   PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
bash     7033 root  cwd    DIR   8,49     4096    5 /mnt/usb
lsof    12636 root  cwd    DIR   8,49     4096    5 /mnt/usb
lsof    12637 root  cwd    DIR   8,49     4096    5 /mnt/usb

Then you can decide to kill those process (kill -9 <PID>) but remember by doing so any ongoing task or operation will be killed.

WARNING:
Do not kill any process without any knowledge as it can be dangerous in production environment.

 

Lastly I hope the steps from this article on Linux mount command to mount ISO file, USB drive, network drive and file systems, list USB devices, check USB ports, understanding fstab options, fstab format and examples were helpful. So, let me know your suggestions and feedback using the comment section.

Deepak Prasad

Deepak Prasad

He is the founder of GoLinuxCloud and brings over a decade of expertise in Linux, Python, Go, Laravel, DevOps, Kubernetes, Git, Shell scripting, OpenShift, AWS, Networking, and Security. With extensive experience, he excels in various domains, from development to DevOps, Networking, and Security, ensuring robust and efficient solutions for diverse projects. You can connect with him on his LinkedIn profile.

Can't find what you're searching for? Let us assist you.

Enter your query below, and we'll provide instant results tailored to your needs.

If my articles on GoLinuxCloud has helped you, kindly consider buying me a coffee as a token of appreciation.

Buy GoLinuxCloud a Coffee

For any other feedbacks or questions you can send mail to admin@golinuxcloud.com

Thank You for your support!!

19 thoughts on “Linux mount command to access filesystems, iso image, usb, network drives”

  1. Thank you Admin !

    "//192.168.0.100/Disque\ dur" /mnt/freebox cifs username=eric,.....

    give ==> parse error at line 8 — ignored

    //192.168.0.100/Disque\040dur /mnt/freebox cifs username=eric,....

    is ok

    I will look how to rename the ‘Disque Dur‘ to avoid space, but it come with the provider (free), so I am not sure we can rename it. Anyways, it is ok with the magic ‘040‘ ASCII code, until a test after reboot to validate completely,

    Thank again Admin, have a good week,
    Regards
    Eric

    Reply
    • You can test without rebooting the node by manually unmounting /mnt/freebox then add the entry in /etc/fstab and execute

      # mount -a

      from the terminal as root user (or with sudo)
      This should mount all the filesystems from /etc/fstab

      Reply
  2. Hi admin,
    Again me, I have a pb that I can’t solve. Perhaps it is easy for you with one magic correct command ?
    I have my network drive on the box that I mount whithout problem with the following terminal command:

    mount.cifs //192.168.0.100/Disque\ dur  /mnt/freebox -o username=eric,vers=1.0

    But in FSTAB I don’t find the correct sentence.
    I tried this without success.

    //192.168.0.100/Disque\ dur /mnt/freebox cifs -o username=eric,file_mode=0760,vers=1.0 0 0  

    I have googled but no more success ?

    Do you know the correct command in FSTAB for this disk ?

    Again, Admin thank you

    Reply
    • Can you try to use following line in /etc/fstab:

      //192.168.0.100/Disque\040dur /mnt/freebox   cifs username=eric,file_mode=0760,vers=1.0    0  0 

      Here 040 is the ASCII code for space in octal numeral system. But mount.cifs will not support 040 code so you will have to use backslash or double quotes for the whitespace in your PATH NAME.

      alternatively you can use double quotes to ignore the whitespace in your PATH

      "//192.168.0.100/Disque dur" /mnt/freebox   cifs username=eric,file_mode=0760,vers=1.0    0  0 

      I would suggest to remove the whitespace and use Disque_dur instead which should be more appropriate. These spaces in names and paths can be really hectic when working with shares at times and should be avoided.

      Reply
  3. Hi admin,
    After severals attemps, it is impossible to format this disk to ext4. I tried what you propose, I tried severals things without succes, pb is with super-blocks.

    fdisk -l    
    Disk /dev/sdd: 233.8 GiB, 251000193024 bytes, 490234752 sectors
    Disk model: OneTouch II     
    Units: sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disklabel type: dos
    Disk identifier: 0x1c6cb762
    
    Device     Boot Start       End   Sectors   Size Id Type
    /dev/sdd1        2048 490234751 490232704 233.8G 83 Linux
    
    and
    
    edserv:~ # mkfs.ext4 /dev/sdd1
    mke2fs 1.43.8 (1-Jan-2018)
    Found a dos partition table in /dev/sdd1
    Proceed anyway? (y,N) n

    format with dd

    edserv:~ # dd if=/dev/null of=/dev/sdd1 bs=512 count=1
    0+0 records in
    0+0 records out
    0 bytes copied, 5.885e-05 s, 0.0 kB/s

    wipefs

    edserv:~ # wipefs -a /dev/sdd1
    wipefs: /dev/sdd1: ignoring nested "dos" partition table on non-whole disk device
    wipefs: Use the --force option to force erase.
    
    edserv:~ # wipefs -a /dev/sdd1 --force
    /dev/sdd1: 2 bytes were erased at offset 0x000001fe (dos): 55 aa

    Anyway, I have bought a new disk size of 4To, and everything are ok now for ext4.
    I format back to Fat32 for the ‘firewire’ with uid/gid and it is ok.

    Thank you

    Reply
    • Thanks for sharing the result. This mostly tells that your disk was corrupted, I am glad you bought a new hardware. May be time to retire the old one.

      Reply
  4. Hi admin,
    Thank you for information and advices. I have followed your instructions. Here the result:

    umount /firewire
    command (m for help): p
    Disk /dev/sdc: 233.8 GiB, 251000193024 bytes, 490234752 sectors
    Disk model: OneTouch II     
    Units: sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disklabel type: gpt
    Disk identifier: 6B9446D5-A68A-4B14-8339-8D1632E623A4
    
    Device     Start       End   Sectors   Size Type
    /dev/sdc1   2048 490234718 490232671 233.8G Microsoft basic data
    
    Command (m for help): p
    Disk /dev/sdc: 233.8 GiB, 251000193024 bytes, 490234752 sectors
    Disk model: OneTouch II     
    Units: sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disklabel type: gpt
    Disk identifier: 6B9446D5-A68A-4B14-8339-8D1632E623A4
    
    Device     Start       End   Sectors   Size Type
    /dev/sdc1   2048 490234718 490232671 233.8G Microsoft basic data
    
    Command (m for help): d
    Selected partition 1
    Partition 1 has been deleted.
    
    Command (m for help): n
    Partition number (1-128, default 1): 1
    First sector (34-490234718, default 2048): 2048
    Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-490234718, default 490234718): 490234718
    
    Created a new partition 1 of type 'Linux filesystem' and of size 233.8 GiB.
    Partition #1 contains a vfat signature.
    
    Do you want to remove the signature? [Y]es/[N]o: y
    
    The signature will be removed by a write command.
    
    Command (m for help): w
    The partition table has been altered.
    Calling ioctl() to re-read partition table.
    Re-reading the partition table failed.: Device or resource busy

    The kernel still uses the old table. The new table will be used at the next reboot or after you run partprobe(8) or kpartx(8).

    edserv:~ # partprobe /dev/sdc1
    Warning: Error fsyncing/closing /dev/sdc1: Remote I/O error
    Warning: Error fsyncing/closing /dev/sdc1: Remote I/O error
    Warning: Error fsyncing/closing /dev/sdc1: Remote I/O error
    Error: Partition(s) 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64 on /dev/sdc1 have been written, but we have been unable to inform the kernel of the change, probably because it/they are in use.  As a result, the old partition(s) will remain in use.  You should reboot now before making further changes.
    Warning: Error fsyncing/closing /dev/sdc1: Remote I/O error

    After reboot

    command (m for help): p
    Disk /dev/sdc: 233.8 GiB, 251000193024 bytes, 490234752 sectors
    Disk model: OneTouch II     
    Units: sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disklabel type: gpt
    Disk identifier: 6B9446D5-A68A-4B14-8339-8D1632E623A4
    
    Device     Start       End   Sectors   Size Type
    /dev/sdc1   2048 490234718 490232671 233.8G Linux filesystem
    edserv:~ # mkfs.ext4 /dev/sdc1
    mke2fs 1.43.8 (1-Jan-2018)
    Creating filesystem with 61279083 4k blocks and 15327232 inodes
    Filesystem UUID: a95d321d-f870-4c32-a0e3-b853083678be
    Superblock backups stored on blocks: 
            32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
            4096000, 7962624, 11239424, 20480000, 23887872
    
    Allocating group tables: done                            
    Writing inode tables: done                            
    Creating journal (262144 blocks): done
    Writing superblocks and filesystem accounting information:          
    Warning, had trouble writing out superblocks.

    and

    edserv:~ # fsck /dev/sdc1 -y -f
    fsck from util-linux 2.33.1
    e2fsck 1.43.8 (1-Jan-2018)
    ext2fs_open2: Bad magic number in super-block
    fsck.ext2: Superblock invalid, trying backup blocks...
    Pass 1: Checking inodes, blocks, and sizes
    Inode 107027 block 295063 conflicts with critical metadata, skipping block checks.
    Inode 107027 block 295064 conflicts with critical metadata, skipping block checks.
    Inode 107027 block 295065 conflicts with critical metadata, skipping block checks.
    ....
    ....
    e2fsck: aborted
    
    /dev/sdc1: ***** FILE SYSTEM WAS MODIFIED *****
    
    again now after removing sdc1:
    Command (m for help): w
    The partition table has been altered.
    Calling ioctl() to re-read partition table.
    /dev/sdc: close device failed: Remote I/O error

    If I go back to Fat32 (gparted) it should be ok for format the sdc1, so I don’t really understand what happen,
    thank you for any help

    Reply
    • This is really weird but I see there are a number of users who seem to face similar issues reported on multiple forums. Can you try wiping the filesystem from your pen drive using

      # dd if=/dev/null of=/dev/sdX bs=512 count=1

      and also

      # wipefs -a /dev/sdX

      Replace sdx with your USB device. Run this command carefully as this can destroy your Linux FS

      and then try to use fdisk /dev/sdc, delete the partition and save the changes using “w” (Do not create a new partition here)
      Next remove the external disk and replug it. Now you can create new partition using fdisk /dev/sdc
      and then try to use mkfs.ext4 /dev/sdc1

      Reply
  5. Hi admin,
    Again me, below the result of format to ext4 :

    edserv:~ # mkfs -L Firewire -v -t ext4 /dev/sdc1
    mke2fs 1.43.8 (1-Jan-2018)
    /dev/sdc1 contains a vfat file system
    Proceed anyway? (y,N) y
    fs_types for mke2fs.conf resolution: 'ext4'
    Filesystem label=Firewire
    OS type: Linux
    Block size=4096 (log=2)
    Fragment size=4096 (log=2)
    Stride=0 blocks, Stripe width=0 blocks
    15327232 inodes, 61279083 blocks
    3063954 blocks (5.00%) reserved for the super user
    First data block=0
    Maximum filesystem blocks=2210398208
    1871 block groups
    32768 blocks per group, 32768 fragments per group
    8192 inodes per group
    Filesystem UUID: 8ccf4284-be23-42cd-bce2-305e51ef7dbe
    Superblock backups stored on blocks: 
            32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
            4096000, 7962624, 11239424, 20480000, 23887872
    
    Allocating group tables: done                            
    Writing inode tables: done                            
    Creating journal (262144 blocks): done
    Writing superblocks and filesystem accounting information:          
    Warning, had trouble writing out superblocks.

    and

    edserv:~ # blkid /dev/sdc1
    /dev/sdc1: PARTUUID="f2553933-a93e-46a4-b709-62aa4c73248e"

    there is no UUID, it is normal ?

    edserv:~ # tune2fs -U new_uuid /dev/sdc1
    tune2fs 1.43.8 (1-Jan-2018)
    tune2fs: Bad magic number in super-block while trying to open /dev/sdc1

    Thank a lot for advice,

    Reply
    • Here is the problem:

      edserv:~ # mkfs -L Firewire -v -t ext4 /dev/sdc1
      mke2fs 1.43.8 (1-Jan-2018)
      /dev/sdc1 contains a vfat file system
      Proceed anyway? (y,N) y
      fs_types for mke2fs.conf resolution: ‘ext4’

      If you read my previous comments, you cannot directly assign a file system on NTFS/vFAT device. So you must delete the partition first and then create a new partition.

      fdisk /dev/sdc
      p <-- to print the available partitions
      d <-- to delete any available partitions THIS WILL DELETE ALL YOUR DATA
      n <-- new partition
      provide the size information
      w <-- save the partition table
      partprobe /dev/sdc1  <-- to activate the changes
      mkfs.ext4 /dev/sdc1 <-- to format as ext4
      Reply
  6. Hi admin,
    I have a backup script that is intended to preserve rights/credentials ( I want to say owner/permission of uid,gid), like this :

    cp -r -v -p -d -u -f /stock/11Save/ /firewire/ 

    The -p option should preserve attributs of the owner from the source to the target, but when it is executed :

    cp: conservation des droits pour « /firewire/11Save/mdport/Maeva/AFFICHES/fete1.jpg »: Opération non supportée

    In English it means that it doesn’t support to keep the owner permissions to the target, because the target is Fat32 and you explain me I can’t change these permissions after FSTAB.

    So now, I will try to pass the disk under ext4. I will give you if you agree the exact error and what I do.

    Thank you again,
    Regards
    Eric

    Reply
    • If you are taking a backup then it should not fail unless you are trying to overwrite a file with the same name in which case you will get the permission issue.
      So to overcome this you can create a new directory every time you take a backup and it should work

      Reply
  7. Hello admin,
    Thank you! UID and GID options do the job.

    Now I am owner of the folders/files, but I am not sur that it will be suficient for the backup script to preserve credentails because I have understand that now I will be the owner of all the files (old and news ) even the source is different and the user is under the GID . right ?

    Here are the results of fdisk

    Disk /dev/sdc: 233.8 GiB, 251000193024 bytes, 490234752 sectors
    Disk model: OneTouch II     
    Units: sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disklabel type: gpt
    Disk identifier: 2BAFA0F3-97B3-46F9-8937-CBF53ED4E9D6
    
    Device     Start       End   Sectors   Size Type
    /dev/sdc1   2048 490234718 490232671 233.8G Microsoft basic data

    As you can guess my pb is that I want to preserve credentials from a backup and 2° pb I can’t save More 4GB on this disk, that why I tri to pass it under ext4, to save some VMachines.

    Thank for any help,
    Eric

    Reply
  8. Hi admin,
    Thank you for trying helping me.
    Here my last /etc/fstab for the external DD (maxtor old 20 years):

    UUID=4370-94E4                             /firewire  vfat  rw,user,exec,dmask=000,fmask=111,umask=000,iocharset=utf8  0  0

    As you see I mounted directly the disk on the root like this : /firewire (but it is usb link). I have tried under /mnt/firewire but it is the same. Do you think this point is important ?

    Here the mistake I have when I want to change the owner :

    edserv:/firewire # ls -al      
    total 164
    drwxr-xr-x  6 root root 32768 Jan  1  1970 .
    drwxr-xr-x 26 root root  4096 Mar 10 20:36 ..
    drwxr-xr-x  7 root root 32768 Mar 10 15:13 10Multimedias
    drwxr-xr-x  9 root root 32768 Mar 10 22:07 11Save
    drwxr-xr-x  6 root root 32768 Dec  6 13:08 9Install
    drwxr-xr-x  2 root root 32768 Mar 11 02:01 Sav Vms
    
    edserv:/firewire # chown -R eric:localUsers 11Save/                                          
    chown: changing ownership of '11Save/edserv/7Prod/datas/mysql/indienne': Operation not permitted
    chown: changing ownership of '11Save/edserv/7Prod/datas/mysql/mysql': Operation not permitted......

    I am under opensuse Leap 15.2.

    So I tried first to format with yast to ext4 and it said that an error was raised, but I don’t remember exactly the details. If you think it is important I can try to format again and give you the exact error. I’ve tried also under command line, but gave the same : some error I don’t remember exactly

    Thank again for any idea / clue,
    eric

    Reply
    • Hello Dienot,

      Thanks for sharing these details.

      Unfortunately we cannot change permissions of existing files and folders on an external driver with NTFS and vFAT file system so you can mount these drives using uid=XXX and gid=XXX options where you can add the UID and UID of the respective user to which you wanted to change the ownership.

      Regarding the formatting an vfat with ext4, it worked for me properly using fdisk. If you can share any error snippet then I can try to reproduce and help you recover.
      Here would be the brief steps. For example your external drive is on /dev/sdb

      WARNING: This step would delete all your DATA

      fdisk /dev/sdb
      p <-- to print the available partitions
      d <-- to delete any available partitions THIS WILL DELETE ALL YOUR DATA
      n <-- new partition
      provide the size information
      w <-- save the partition table
      partprobe /dev/sdc1  <-- to activate the changes
      mkfs.ext4 /dev/sdc1 <-- to format as ext4
      Reply
  9. Hello,
    Thank you for this article, very helpfull. I mounted an external DD with USB and put this in FSTAB

    UUID=09B1-F7B2 /firewire vfat rw,user,exec,umask=000,iocharset=utf8 0 0

    The disk is mounted, work fine, but I can’t change the owner of the folders (Operation not permitted
    ).
    It is always Root:root the owners, and I want to change, because when I make backup from system files I want to preserve the owner from the source.

    I have tried to format the disk in ext4 but it seems that it is not possible ? How can I know if the disk is copatible to ext4 ?

    In advance thanks for any help

    Eric from France

    Reply
    • Hi Eric,

      1. If the external Disk is mounted as read write then I don’t think you should get that error. Which folder permission are you trying to change? The folder where the disk is mounted or any other folders inside the mounted path
      2. What error you get while trying to format the disk with ext4?

      Reply

Leave a Comment