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/loop0device was free
I was able to mount the loop-device with a fs attached but no GPT or partition. After running
gdiskand 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
- 158 LFX Mentorship
- 158 LFX Mentorship: Linux Kernel
- 864 Linux Foundation IT Professional Programs
- 392 Cloud Engineer IT Professional Program
- 189 Advanced Cloud Engineer IT Professional Program
- 92 DevOps IT Professional Program
- DevOps & GitOps IT Professional Program
- 160 Cloud Native Developer IT Professional Program
- 153 Express Training Courses & Microlearning
- 150 Express Courses - Discussion Forum
- 3 Microlearning - Discussion Forum
- 7.2K Training Courses
- 50 LFC110 Class Forum - Discontinued
- 74 LFC131 Class Forum - DISCONTINUED
- 57 LFD102 Class Forum
- 259 LFD103 Class Forum
- LFD103-JP クラス フォーラム
- 27 LFD110 Class Forum
- 50 LFD121 Class Forum
- 3 LFD123 Class Forum
- 1 LFD125 Class Forum
- 19 LFD133 Class Forum
- 10 LFD134 Class Forum
- 19 LFD137 Class Forum
- 1 LFD140 Class Forum
- 73 LFD201 Class Forum
- 8 LFD210 Class Forum
- 6 LFD210-CN Class Forum
- 2 LFD213 Class Forum - Discontinued
- LFD221 Class Forum
- 128 LFD232 Class Forum - Discontinued
- 3 LFD233 Class Forum - Discontinued
- 5 LFD237 Class Forum
- 25 LFD254 Class Forum
- 753 LFD259 Class Forum
- 111 LFD272 Class Forum - Discontinued
- 4 LFD272-JP クラス フォーラム - Discontinued
- 20 LFD273 Class Forum
- 491 LFS101 Class Forum
- 4 LFS111 Class Forum
- 4 LFS112 Class Forum
- LFS114 Class Forum
- 5 LFS116 Class Forum
- 9 LFS118 Class Forum
- 2 LFS120 Class Forum
- LFS140 Class Forum
- 12 LFS142 Class Forum
- 9 LFS144 Class Forum
- 6 LFS145 Class Forum
- 6 LFS146 Class Forum
- 7 LFS147 Class Forum
- 22 LFS148 Class Forum
- 18 LFS151 Class Forum
- 6 LFS157 Class Forum
- 91 LFS158 Class Forum
- 1 LFS158-JP クラス フォーラム
- 14 LFS162 Class Forum
- 2 LFS166 Class Forum - Discontinued
- 9 LFS167 Class Forum
- 5 LFS170 Class Forum
- 2 LFS171 Class Forum - Discontinued
- 4 LFS178 Class Forum - Discontinued
- 4 LFS180 Class Forum
- 3 LFS182 Class Forum
- 7 LFS183 Class Forum
- 2 LFS184 Class Forum
- 41 LFS200 Class Forum
- 737 LFS201 Class Forum - Discontinued
- 3 LFS201-JP クラス フォーラム - Discontinued
- 23 LFS203 Class Forum
- 142 LFS207 Class Forum
- 3 LFS207-DE-Klassenforum
- 3 LFS207-JP クラス フォーラム
- 302 LFS211 Class Forum - Discontinued
- 56 LFS216 Class Forum - Discontinued
- 60 LFS241 Class Forum
- 51 LFS242 Class Forum
- 41 LFS243 Class Forum
- 17 LFS244 Class Forum
- 8 LFS245 Class Forum
- 1 LFS246 Class Forum
- 1 LFS248 Class Forum
- 125 LFS250 Class Forum
- 3 LFS250-JP クラス フォーラム
- 2 LFS251 Class Forum - Discontinued
- 164 LFS253 Class Forum
- 1 LFS254 Class Forum - Discontinued
- 3 LFS255 Class Forum
- 16 LFS256 Class Forum
- 2 LFS257 Class Forum
- 1.4K LFS258 Class Forum
- 12 LFS258-JP クラス フォーラム
- 142 LFS260 Class Forum
- 165 LFS261 Class Forum
- 45 LFS262 Class Forum
- 82 LFS263 Class Forum - Discontinued
- 15 LFS264 Class Forum - Discontinued
- 11 LFS266 Class Forum - Discontinued
- 25 LFS267 Class Forum
- 27 LFS268 Class Forum
- 38 LFS269 Class Forum
- 11 LFS270 Class Forum
- 202 LFS272 Class Forum - Discontinued
- 2 LFS272-JP クラス フォーラム - Discontinued
- 2 LFS274 Class Forum - Discontinued
- 4 LFS281 Class Forum - Discontinued
- 31 LFW111 Class Forum
- 265 LFW211 Class Forum
- 190 LFW212 Class Forum
- 17 SKF100 Class Forum
- 2 SKF200 Class Forum
- 3 SKF201 Class Forum
- 800 Hardware
- 200 Drivers
- 68 I/O Devices
- 37 Monitors
- 104 Multimedia
- 175 Networking
- 92 Printers & Scanners
- 85 Storage
- 765 Linux Distributions
- 82 Debian
- 67 Fedora
- 20 Linux Mint
- 13 Mageia
- 23 openSUSE
- 149 Red Hat Enterprise
- 31 Slackware
- 13 SUSE Enterprise
- 356 Ubuntu
- 472 Linux System Administration
- 39 Cloud Computing
- 71 Command Line/Scripting
- Github systems admin projects
- 96 Linux Security
- 78 Network Management
- 102 System Management
- 48 Web Management
- 74 Mobile Computing
- 19 Android
- 42 Development
- 1.2K New to Linux
- 1K Getting Started with Linux
- 390 Off Topic
- 121 Introductions
- 180 Small Talk
- 28 Study Material
- 896 Programming and Development
- 312 Kernel Development
- 566 Software Development
- 1.8K Software
- 273 Applications
- 183 Command Line
- 5 Compiling/Installing
- 988 Games
- 320 Installation
- 110 All In Program
- 110 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)
