Write protected error when mounting a loop device with a GPT and single partition

I'm trying to mount a loop device that I've created with the following steps but receive an error telling me that the fs is of an unknown type. If I don't add a partition to the fs it will mount as expected.
$ sudo dd if=/dev/zero of=secOps bs=1M count=512 512+0 records in 512+0 records out 536870912 bytes (537 MB) copied, 0.244399 s, 2.2 GB/s
$ sudo mkfs.ext4 secOps mke2fs 1.42.9 (28-Dec-2013) secOps is not a block special device. Proceed anyway? (y,n) y Discarding device blocks: done Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 32768 inodes, 131072 blocks 6553 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=134217728 4 block groups 32768 blocks per group, 32768 fragments per group 8192 inodes per group Superblock backups stored on blocks: 32768, 98304 Allocating group tables: done Writing inode tables: done Creating journal (4096 blocks): done Writing superblocks and filesystem accounting information: done
$ sudo gdisk secOps GPT fdisk (gdisk) version 0.8.10 Partition table scan: MBR: not present BSD: not present APM: not present GPT: not present Creating new GPT entries. Command (? for help): o This option deletes all partitions and creates a new protective MBR. Proceed? (Y/N): Y Command (? for help): n Partition number (1-128, default 1): First sector (34-1048542, default = 2048) or {+-}size{KMGTP}: Last sector (2048-1048542, default = 1048542) or {+-}size{KMGTP}: +256M Current type is 'Linux filesystem' Hex code or GUID (L to show codes, Enter = 8300): Changed type of partition to 'Linux filesystem' Command (? for help): p Disk secOps: 1048576 sectors, 512.0 MiB Logical sector size: 512 bytes Disk identifier (GUID): 941146DD-99DB-4A90-B400-8D7D1534AF21 Partition table holds up to 128 entries First usable sector is 34, last usable sector is 1048542 Partitions will be aligned on 2048-sector boundaries Total free space is 524221 sectors (256.0 MiB) Number Start (sector) End (sector) Size Code Name 1 2048 526335 256.0 MiB 8300 Linux filesystem Command (? for help): w Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING PARTITIONS!! Do you want to proceed? (Y/N): Y OK; writing new GUID partition table (GPT) to secOps. Warning: The kernel is still using the old partition table. The new table will be used at the next reboot. The operation has completed successfully.
$ sudo losetup /dev/loop0 secOps $ sudo lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 20G 0 disk ├─sda1 8:1 0 200M 0 part /boot/efi └─sda2 8:2 0 19.8G 0 part / loop0 7:0 0 512M 0 loop └─loop0p1 259:0 0 256M 0 loop
$ sudo blkid /dev/sda1: SEC_TYPE="msdos" UUID="8939-51F5" TYPE="vfat" PARTLABEL="EFI System Partition" PARTUUID="c8b5c89a-17ed-480e-b9f6-0e811c16fee3" /dev/sda2: LABEL="root" UUID="a8ee4848-df7a-4cc9-a9f0-07e423353d28" TYPE="xfs" PARTUUID="e8d78e3d-29f6-44f1-bd31-977ffd4b3d7d" /dev/loop0: PTTYPE="gpt" /dev/loop0p1: PARTLABEL="Linux filesystem" PARTUUID="b0ad9144-89bf-49ce-9038-f70d9d69d7ea"
I notice here that the partition does not have a UUID. Why might that be?
And then when attempting to mount the loop device.
$ sudo mount /dev/loop0 /secOpsMnt/ mount: /dev/loop0 is write-protected, mounting read-only mount: unknown filesystem type '(null)'
Comments
-
Hi @GRO 108 , I have the following questions:
1.- What OS and version are you working with?
2.- Did you do "losetup -f" before using /dev/loop0 ? "losetup -f" gives the first available loop device. And it's probably you are messing something up if /dev/loop0 was busy. This is how it looks on Ubuntu 20.04:
[email protected]:~$ sudo losetup -f
/dev/loop9==> That means I could start working with /dev/loop9, not anything below that.
So, just to check on it:
[email protected]:~$ ls -l /dev/loop*
brw-rw---- 1 root disk 7, 0 Kun 19 18:25 /dev/loop0
brw-rw---- 1 root disk 7, 1 Kun 19 18:25 /dev/loop1
brw-rw---- 1 root disk 7, 2 Kun 19 18:25 /dev/loop2
brw-rw---- 1 root disk 7, 3 Kun 19 18:25 /dev/loop3
brw-rw---- 1 root disk 7, 4 Kun 19 18:25 /dev/loop4
brw-rw---- 1 root disk 7, 5 Kun 19 18:26 /dev/loop5
brw-rw---- 1 root disk 7, 6 Kun 19 18:26 /dev/loop6
brw-rw---- 1 root disk 7, 7 Kun 19 18:26 /dev/loop7
brw-rw---- 1 root disk 7, 8 Kun 19 18:26 /dev/loop8
brw-rw---- 1 root disk 7, 9 Kun 19 19:12 /dev/loop9
crw-rw---- 1 root disk 10, 237 Kun 19 18:25 /dev/loop-controlAnd lsblk shows that /dev/loop0 is being used:
[email protected]:~$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
loop0 7:0 0 49,8M 1 loop /snap/snap-store/433
loop1 7:1 0 27,1M 1 loop /snap/snapd/7264
loop2 7:2 0 55M 1 loop /snap/core18/1705
loop3 7:3 0 62,1M 1 loop /snap/gtk-common-themes/1506
loop4 7:4 0 240,8M 1 loop /snap/gnome-3-34-1804/24
loop5 7:5 0 29,9M 1 loop /snap/snapd/8542
loop6 7:6 0 55M 1 loop /snap/core18/1880
loop7 7:7 0 49,8M 1 loop /snap/snap-store/467
loop8 7:8 0 255,6M 1 loop /snap/gnome-3-34-1804/36
sda 8:0 0 15G 0 disk
├─sda1 8:1 0 512M 0 part /boot/efi
├─sda2 8:2 0 1K 0 part
└─sda5 8:5 0 14,5G 0 part /
sr0 11:0 1 57,7M 0 rom /media/luis/VBox_GAs_6.1.10So, please unmont the device and start again.
Many regards,
Luis.0 -
- CentOS 7 - kernel version 3.10.0-1127.10.1.el7.x86_64
- I did know previous to running these steps that the
/dev/loop0
device was free
I was able to mount the loop-device with a fs attached but no GPT or partition. After running
gdisk
and adding those it wasn't possible to mount it.0 -
I will try to repeate your steps later, but please note you did mkfs.ext4 on the file, sec04fs or whatever you called it, then you tried to moutnt dev/loop0 after you wiped out the entire disk with gpart as it said it did. So why should there be a fs there now? A quick glance tells me the mkfs.ext4 was discarded. It would certainly be the case if you did say "mkfs.ext4 /dev/sde ; then ran fdisk to set up partitions on sde ; and then tried to mount any of them, include /dev/sde1 .
1
Categories
- 10.1K All Categories
- 35 LFX Mentorship
- 88 LFX Mentorship: Linux Kernel
- 504 Linux Foundation Boot Camps
- 279 Cloud Engineer Boot Camp
- 103 Advanced Cloud Engineer Boot Camp
- 48 DevOps Engineer Boot Camp
- 41 Cloud Native Developer Boot Camp
- 2 Express Training Courses
- 2 Express Courses - Discussion Forum
- 1.7K Training Courses
- 17 LFC110 Class Forum
- 5 LFC131 Class Forum
- 19 LFD102 Class Forum
- 148 LFD103 Class Forum
- 12 LFD121 Class Forum
- 61 LFD201 Class Forum
- LFD210 Class Forum
- 1 LFD213 Class Forum - Discontinued
- 128 LFD232 Class Forum
- 23 LFD254 Class Forum
- 569 LFD259 Class Forum
- 100 LFD272 Class Forum
- 1 LFD272-JP クラス フォーラム
- 1 LFS145 Class Forum
- 23 LFS200 Class Forum
- 739 LFS201 Class Forum
- 1 LFS201-JP クラス フォーラム
- 1 LFS203 Class Forum
- 45 LFS207 Class Forum
- 298 LFS211 Class Forum
- 53 LFS216 Class Forum
- 46 LFS241 Class Forum
- 41 LFS242 Class Forum
- 37 LFS243 Class Forum
- 10 LFS244 Class Forum
- 27 LFS250 Class Forum
- 1 LFS250-JP クラス フォーラム
- 131 LFS253 Class Forum
- 995 LFS258 Class Forum
- 10 LFS258-JP クラス フォーラム
- 87 LFS260 Class Forum
- 126 LFS261 Class Forum
- 31 LFS262 Class Forum
- 79 LFS263 Class Forum
- 15 LFS264 Class Forum
- 10 LFS266 Class Forum
- 17 LFS267 Class Forum
- 17 LFS268 Class Forum
- 21 LFS269 Class Forum
- 200 LFS272 Class Forum
- 1 LFS272-JP クラス フォーラム
- 212 LFW211 Class Forum
- 153 LFW212 Class Forum
- 899 Hardware
- 217 Drivers
- 74 I/O Devices
- 44 Monitors
- 115 Multimedia
- 208 Networking
- 101 Printers & Scanners
- 85 Storage
- 749 Linux Distributions
- 88 Debian
- 64 Fedora
- 14 Linux Mint
- 13 Mageia
- 24 openSUSE
- 133 Red Hat Enterprise
- 33 Slackware
- 13 SUSE Enterprise
- 355 Ubuntu
- 473 Linux System Administration
- 38 Cloud Computing
- 69 Command Line/Scripting
- Github systems admin projects
- 94 Linux Security
- 77 Network Management
- 108 System Management
- 49 Web Management
- 63 Mobile Computing
- 22 Android
- 27 Development
- 1.2K New to Linux
- 1.1K Getting Started with Linux
- 528 Off Topic
- 127 Introductions
- 213 Small Talk
- 20 Study Material
- 794 Programming and Development
- 262 Kernel Development
- 498 Software Development
- 923 Software
- 258 Applications
- 182 Command Line
- 2 Compiling/Installing
- 76 Games
- 316 Installation
- 53 All In Program
- 53 All In Forum
Upcoming Training
-
August 20, 2018
Kubernetes Administration (LFS458)
-
August 20, 2018
Linux System Administration (LFS301)
-
August 27, 2018
Open Source Virtualization (LFS462)
-
August 27, 2018
Linux Kernel Debugging and Security (LFD440)