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:
luis@ubuntu20:~$ sudo losetup -f
/dev/loop9==> That means I could start working with /dev/loop9, not anything below that.
So, just to check on it:
luis@ubuntu20:~$ 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:
luis@ubuntu20:~$ 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
- All Categories
- 238 LFX Mentorship
- 238 LFX Mentorship: Linux Kernel
- 812 Linux Foundation IT Professional Programs
- 365 Cloud Engineer IT Professional Program
- 183 Advanced Cloud Engineer IT Professional Program
- 82 DevOps Engineer IT Professional Program
- 129 Cloud Native Developer IT Professional Program
- 140 Express Training Courses & Microlearning
- 140 Express Courses - Discussion Forum
- Microlearning - Discussion Forum
- 6.5K Training Courses
- 40 LFC110 Class Forum - Discontinued
- 66 LFC131 Class Forum
- 49 LFD102 Class Forum
- 233 LFD103 Class Forum
- 16 LFD110 Class Forum
- 29 LFD121 Class Forum
- LFD123 Class Forum
- LFD125 Class Forum
- 16 LFD133 Class Forum
- 6 LFD134 Class Forum
- 18 LFD137 Class Forum
- 70 LFD201 Class Forum
- 3 LFD210 Class Forum
- 2 LFD210-CN Class Forum
- 2 LFD213 Class Forum - Discontinued
- 128 LFD232 Class Forum - Discontinued
- 1 LFD233 Class Forum
- 2 LFD237 Class Forum
- 23 LFD254 Class Forum
- 718 LFD259 Class Forum
- 111 LFD272 Class Forum - Discontinued
- 3 LFD272-JP クラス フォーラム
- 13 LFD273 Class Forum
- 213 LFS101 Class Forum
- 1 LFS111 Class Forum
- 2 LFS112 Class Forum
- 1 LFS116 Class Forum
- 3 LFS118 Class Forum
- LFS120 Class Forum
- 1 LFS142 Class Forum
- 2 LFS144 Class Forum
- 3 LFS145 Class Forum
- 4 LFS146 Class Forum
- 15 LFS148 Class Forum
- 15 LFS151 Class Forum
- 1 LFS157 Class Forum
- 6 LFS158 Class Forum
- LFS158-JP クラス フォーラム
- 4 LFS162 Class Forum
- 1 LFS166 Class Forum
- 2 LFS167 Class Forum
- 1 LFS170 Class Forum
- 1 LFS171 Class Forum
- 1 LFS178 Class Forum
- 2 LFS180 Class Forum
- 1 LFS182 Class Forum
- 3 LFS183 Class Forum
- 30 LFS200 Class Forum
- 737 LFS201 Class Forum - Discontinued
- 2 LFS201-JP クラス フォーラム
- 20 LFS203 Class Forum
- 109 LFS207 Class Forum
- 1 LFS207-DE-Klassenforum
- 2 LFS207-JP クラス フォーラム
- 301 LFS211 Class Forum
- 55 LFS216 Class Forum
- 48 LFS241 Class Forum
- 43 LFS242 Class Forum
- 37 LFS243 Class Forum
- 16 LFS244 Class Forum
- 1 LFS245 Class Forum
- LFS246 Class Forum
- LFS248 Class Forum
- 44 LFS250 Class Forum
- 1 LFS250-JP クラス フォーラム
- LFS251 Class Forum
- 156 LFS253 Class Forum
- LFS254 Class Forum
- LFS255 Class Forum
- 6 LFS256 Class Forum
- LFS257 Class Forum
- 1.3K LFS258 Class Forum
- 9 LFS258-JP クラス フォーラム
- 113 LFS260 Class Forum
- 150 LFS261 Class Forum
- 41 LFS262 Class Forum
- 82 LFS263 Class Forum - Discontinued
- 15 LFS264 Class Forum - Discontinued
- 11 LFS266 Class Forum - Discontinued
- 21 LFS267 Class Forum
- 18 LFS268 Class Forum
- 29 LFS269 Class Forum
- 7 LFS270 Class Forum
- 199 LFS272 Class Forum
- 1 LFS272-JP クラス フォーラム
- 2 LFS147 Class Forum
- LFS274 Class Forum
- 3 LFS281 Class Forum
- 2 LFW111 Class Forum
- 257 LFW211 Class Forum
- 176 LFW212 Class Forum
- 15 SKF100 Class Forum
- SKF200 Class Forum
- 2 SKF201 Class Forum
- 797 Hardware
- 198 Drivers
- 68 I/O Devices
- 37 Monitors
- 96 Multimedia
- 174 Networking
- 91 Printers & Scanners
- 83 Storage
- 752 Linux Distributions
- 82 Debian
- 67 Fedora
- 16 Linux Mint
- 13 Mageia
- 23 openSUSE
- 147 Red Hat Enterprise
- 31 Slackware
- 13 SUSE Enterprise
- 349 Ubuntu
- 463 Linux System Administration
- 39 Cloud Computing
- 71 Command Line/Scripting
- Github systems admin projects
- 91 Linux Security
- 78 Network Management
- 101 System Management
- 46 Web Management
- 55 Mobile Computing
- 18 Android
- 28 Development
- 1.2K New to Linux
- 1K Getting Started with Linux
- 364 Off Topic
- 115 Introductions
- 170 Small Talk
- 26 Study Material
- 518 Programming and Development
- 304 Kernel Development
- 211 Software Development
- 1.1K Software
- 211 Applications
- 180 Command Line
- 3 Compiling/Installing
- 405 Games
- 311 Installation
- 78 All In Program
- 78 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)