LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-03-2020, 12:33 PM   #1
marianaf
LQ Newbie
 
Registered: Nov 2020
Posts: 1

Rep: Reputation: Disabled
SD card keeps restoring partitions


Hello,

My SD card refuses to update the changes I 'write' with fdisk or gdisk. After making modifications (such as deleting or creating partitions) & rebooting or calling 'partprobe', the SD card old contents are back.
Anyone has an idea how to wipe everything out so to use it again? Thanks.

Code:
sudo gdisk /dev/sdb
GPT fdisk (gdisk) version 1.0.5

Partition table scan:
  MBR: hybrid
  BSD: not present
  APM: not present
  GPT: present

Found valid GPT with hybrid MBR; using GPT.

Command (? for help): p
Disk /dev/sdb: 31422464 sectors, 15.0 GiB
Model: Storage Device  
Sector size (logical/physical): 512/512 bytes
Disk identifier (GUID): BF40D979-29F5-429B-B57F-29690F8CB39A
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 34, last usable sector is 31422430
Partitions will be aligned on 2048-sector boundaries
Total free space is 2014 sectors (1007.0 KiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048           67583   32.0 MiB    0C01  hassos-boot
   2           67584          116735   24.0 MiB    8300  hassos-kernel0
   3          116736          641023   256.0 MiB   8300  hassos-system0
   4          641024          690175   24.0 MiB    8300  hassos-kernel1
   5          690176         1214463   256.0 MiB   8300  hassos-system1
   6         1214464         1230847   8.0 MiB     8300  hassos-bootstate
   7         1230848         1427455   96.0 MiB    8300  hassos-overlay
   8         1427456        31422430   14.3 GiB    8300  hassos-data
Code:
sudo fdisk /dev/sdb

Welcome to fdisk (util-linux 2.35.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

A hybrid GPT was detected. You have to sync the hybrid MBR manually (expert command 'M').
(to remove the 'A hybrid GPT was detected. You have to ...' message on gdisk I do:

Code:
Command (? for help): x

Expert command (? for help): n

Expert 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 /dev/sdb.
Warning: The kernel is still using the old partition table.
The new table will be used at the next reboot or after you
run partprobe(8) or kpartx(8)
The operation has completed successfully.
which seems to work, but then when attempting to delete the partitions with fdisk I get the error message:

Code:
sudo fdisk /dev/sdb

Welcome to fdisk (util-linux 2.35.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): p
Disk /dev/sdb: 14.101 GiB, 16088301568 bytes, 31422464 sectors
Disk model: Storage Device  
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: BF40D979-29F5-429B-B57F-29690F8CB39A

Device       Start      End  Sectors  Size Type
/dev/sdb1     2048    67583    65536   32M Microsoft reserved
/dev/sdb2    67584   116735    49152   24M Linux filesystem
/dev/sdb3   116736   641023   524288  256M Linux filesystem
/dev/sdb4   641024   690175    49152   24M Linux filesystem
/dev/sdb5   690176  1214463   524288  256M Linux filesystem
/dev/sdb6  1214464  1230847    16384    8M Linux filesystem
/dev/sdb7  1230848  1427455   196608   96M Linux filesystem
/dev/sdb8  1427456 31422430 29994975 14.3G Linux filesystem

Command (m for help): d
Partition number (1-8, default 8): 

Partition 8 has been deleted.

Command (m for help): d
Partition number (1-7, default 7): 

Partition 7 has been deleted.

Command (m for help): d
Partition number (1-6, default 6): 

Partition 6 has been deleted.

Command (m for help): d
Partition number (1-5, default 5): 

Partition 5 has been deleted.

Command (m for help): d
Partition number (1-4, default 4): 

Partition 4 has been deleted.

Command (m for help): d
Partition number (1-3, default 3): 

Partition 3 has been deleted.

Command (m for help): d
Partition number (1,2, default 2): 

Partition 2 has been deleted.

Command (m for help): d
Selected partition 1
Partition 1 has been deleted.

Command (m for help): p
Disk /dev/sdb: 14.101 GiB, 16088301568 bytes, 31422464 sectors
Disk model: Storage Device  
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: BF40D979-29F5-429B-B57F-29690F8CB39A

Command (m for help): w
The partition table has been altered.
Failed to remove partition 2 from system: Device or resource busy
Failed to remove partition 3 from system: Device or resource busy
Failed to remove partition 7 from system: Device or resource busy
Failed to remove partition 8 from system: Device or resource busy

The kernel still uses the old partitions. The new table will be used at the next reboot. 
Syncing disks.
and, after calling 'partprobe', I'm back with having 8 partitions & MBR:hybrid in gdisk)

Any hint would be highly appreciated.

Last edited by marianaf; 11-03-2020 at 02:04 PM. Reason: added full code on command
 
Old 11-03-2020, 12:48 PM   #2
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora
Posts: 4,153

Rep: Reputation: 1265Reputation: 1265Reputation: 1265Reputation: 1265Reputation: 1265Reputation: 1265Reputation: 1265Reputation: 1265Reputation: 1265
Writing to the disk has no effect on the kernel's partition table. To update that, do:
Code:
blockdev --rereadpt /dev/sdb
If any partition has a mounted filesystem, it must be unmounted first. If any partition has a volume group, it must be deactivated.
 
Old 11-03-2020, 12:52 PM   #3
computersavvy
Senior Member
 
Registered: Aug 2016
Posts: 3,345

Rep: Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484
Code:
The partition table has been altered.
Failed to remove partition 2 from system: Device or resource busy
Failed to remove partition 3 from system: Device or resource busy
Failed to remove partition 7 from system: Device or resource busy
Failed to remove partition 8 from system: Device or resource busy

The kernel still uses the old partitions. The new table will be used at the next reboot. 
Syncing disks.
This might be a clue!
Was anything on the device mounted or in use when you ran gdisk? It says 4 partitions were busy.
Did you delete all the partitions or just modify something. I am not thoroughly familiar with the expert mode so your shorthand commands are greek to me. Looking at the commands for expert mode it seems you wrote a new protective mbr, but did not change any partitions. If you wanted a new partition table then an "o" from the standard menu gives that.
Did you reboot as suggested?

Last edited by computersavvy; 11-03-2020 at 01:03 PM.
 
Old 11-03-2020, 01:03 PM   #4
fatmac
LQ Guru
 
Registered: Sep 2011
Location: Upper Hale, Surrey/Hants Border, UK
Distribution: Mainly Devuan, antiX, & Void, with Tiny Core, Fatdog, & BSD thrown in.
Posts: 5,510

Rep: Reputation: Disabled
Remove & re insert the card, the changes should then show - otherwise use dd to clear the first 4MB or so of the card, & then create a new partition table.
 
Old 11-05-2020, 04:40 PM   #5
Hermani
Member
 
Registered: Apr 2018
Location: Delden, NL
Distribution: Ubuntu
Posts: 261
Blog Entries: 3

Rep: Reputation: 113Reputation: 113
Today I just learned that when SD cards get corrupted or damaged, they can go into some kind of read-only mode. If a SD card is giving you problems, please discard it and get a new one.
 
Old 11-05-2020, 11:01 PM   #6
computersavvy
Senior Member
 
Registered: Aug 2016
Posts: 3,345

Rep: Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484
Quote:
Originally Posted by Hermani View Post
Today I just learned that when SD cards get corrupted or damaged, they can go into some kind of read-only mode. If a SD card is giving you problems, please discard it and get a new one.
Yes, in that respect SD cards are similar to flash drives. When they get old and begin to reach EOL they go to read only (apparently to protect your remaining data)
 
Old 11-06-2020, 03:06 AM   #7
beachboy2
Senior Member
 
Registered: Jan 2007
Location: Wild West Wales, UK
Distribution: Linux Mint 21 MATE, EndeavourOS, antiX, MX Linux
Posts: 3,988
Blog Entries: 33

Rep: Reputation: 1471Reputation: 1471Reputation: 1471Reputation: 1471Reputation: 1471Reputation: 1471Reputation: 1471Reputation: 1471Reputation: 1471Reputation: 1471
marianaf,

Welcome to LQ forums.

As others have stated, your SD card may be faulty and is now in read-only mode.

You could install dcfldd and then check the card (see post #9):
https://www.linuxquestions.org/quest...ly-4175682962/

Alternatively, you could just replace the SD card.
 
1 members found this post helpful.
Old 11-06-2020, 06:13 AM   #8
JJJCR
Senior Member
 
Registered: Apr 2010
Posts: 2,162

Rep: Reputation: 449Reputation: 449Reputation: 449Reputation: 449Reputation: 449
Some SD Card has a mechanical switch, to set the mode either to read only or read/write.

Have you checked this?
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Mepis 6.5 keeps restoring default screen res drudge MEPIS 3 09-19-2007 12:42 PM
Linspire keeps freezing on "restoring session" sonicwaveintl Linux - Laptop and Netbook 2 07-27-2006 07:30 PM
Restoring MBR :partitions are detected only after the reboot after MBR restoration? sharathksin Linux - Newbie 2 04-14-2006 07:48 AM
Restoring corrupted partitions lasagne_of_doom Linux - Software 2 06-07-2004 10:08 PM
Partitions, partitions, partitions..... Clueless in VA Linux - Newbie 7 08-08-2001 03:01 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:52 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration