Lanchon / REPIT

A Device-Only Data-Sparing Repartitioning Tool For Android
159 stars 25 forks source link

Broke partition label? #98

Closed vitaly-zdanevich closed 4 years ago

vitaly-zdanevich commented 4 years ago

Good day, I am afraid to check (I do not know how to revert partitions to "original" state), but looks like after REPIT I got broken label. I am not sure, but maybe. mount return:

rootfs on / type rootfs (ro,seclabel,relatime)
tmpfs on /dev type tmpfs (rw,seclabel,nosuid,relatime,mode=755)
devpts on /dev/pts type devpts (rw,seclabel,relatime,mode=600)
proc on /proc type proc (rw,relatime)
sysfs on /sys type sysfs (rw,seclabel,relatime)
selinuxfs on /sys/fs/selinux type selinuxfs (rw,relatime)
none on /acct type cgroup (rw,relatime,cpuacct)
tmpfs on /mnt type tmpfs (rw,seclabel,relatime,mode=755,gid=1000)
none on /dev/memcg type cgroup (rw,relatime,memory)
none on /dev/cpuctl type cgroup (rw,relatime,cpu)
/dev/block/mmcblk0p9 on /system type ext4 (ro,seclabel,noatime,user_xattr,barrier=1,data=ordered)
/dev/block/mmcblk0p7 on /cache type ext4 (rw,seclabel,nosuid,nodev,noatime,errors=panic,user_xattr,barrier=1,journal_async_commit,data=ordered)
/dev/block/mmcblk0p1 on /efs type ext4 (rw,seclabel,nosuid,nodev,noatime,user_xattr,barrier=1,journal_async_commit,data=ordered)
/dev/block/mmcblk0p10 on /data type ext4 (rw,seclabel,nosuid,nodev,noatime,errors=panic,user_xattr,barrier=1,journal_async_commit,data=ordered,noauto_da_alloc)
tmpfs on /storage type tmpfs (rw,seclabel,relatime,mode=755,gid=1000)
/sys/kernel/debug on /sys/kernel/debug type debugfs (rw,seclabel,relatime)
/dev/block/vold/public:179_11 on /mnt/media_rw/S}M-^^M-~4M-9^DK $t type vfat (rw,dirsync,nosuid,nodev,noexec,relatime,uid=1023,gid=1023,fmask=0007,dmask=0007,allow_utime=0020,codepage=cp437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro)
/dev/block/vold/public:179_11 on /mnt/secure/asec type vfat (rw,dirsync,nosuid,nodev,noexec,relatime,uid=1023,gid=1023,fmask=0007,dmask=0007,allow_utime=0020,codepage=cp437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro)
/dev/fuse on /mnt/runtime/default/S}M-^^M-~4M-9^DK $t type fuse (rw,nosuid,nodev,noexec,noatime,user_id=1023,group_id=1023,default_permissions,allow_other)
/dev/fuse on /storage/S}M-^^M-~4M-9^DK $t type fuse (rw,nosuid,nodev,noexec,noatime,user_id=1023,group_id=1023,default_permissions,allow_other)
/dev/fuse on /mnt/runtime/read/S}M-^^M-~4M-9^DK $t type fuse (rw,nosuid,nodev,noexec,noatime,user_id=1023,group_id=1023,default_permissions,allow_other)
/dev/fuse on /mnt/runtime/write/S}M-^^M-~4M-9^DK $t type fuse (rw,nosuid,nodev,noexec,noatime,user_id=1023,group_id=1023,default_permissions,allow_other)

And looks like because of this label S}M-^^M-~4M-9^DK $t browser try to save into /dev/null/Download.

My ROM is https://forum.xda-developers.com/galaxy-note/development/rom-nightowl-preview-t3455847

My starting point is this question https://android.stackexchange.com/questions/218266/browsers-cannot-download-files-looks-like-some-problem-with-storage-layer

Please share your advice if you can.

vitaly-zdanevich commented 4 years ago

Link to my ROM: https://github.com/bauner/cm-android_device_samsung_n7000

I grepped for 4M-9 but found nothing.

Lanchon commented 4 years ago

that is not a partition label, it is a mount point. your rom is doing that, and i am sure it was doing it before REPIT. seems to be an autogenerated mount point. there might be nothing wrong with it btw.

boot into a recent TWRP and check your partitions from its command line through adb. there you'll see the labels (which are ignored by android anyway).

Lanchon commented 4 years ago

i just saw your other post:

I do not remember when I faced with this problem, maybe after repartitioning with REPIT

very much maybe not.

boot recent twrp, get in via adb, and start exploring with the command line. get a lists of partitions and their metadata, AND DONT MODIFY ANYTHING AT ALL.

I found that I have partition sdcard1 that is 0 bytes in size. Maybe if I remove this partition it will fix my storage problem?

DONT !!!

cat the fstab. mount everything that you can on the UI and get mount's output. next, the commands you could find useful to explore partitions are blkid, parted, gdisk, fdisk, etc...

log everything and post here if you want help. be very careful not to modify ANYTHING.

vitaly-zdanevich commented 4 years ago

blkid:

/dev/block/zram0: UUID="da191bea-c7ca-4b27-af09-ce87c7f99943" TYPE="swap" 
/dev/block/mmcblk0p1: UUID="57f8f4bc-abf4-0000-675f-946fc0f9f25b" TYPE="ext4" 
/dev/block/mmcblk0p7: UUID="57f8f4bc-abf4-655f-bf67-946fc0f9f25b" TYPE="ext4" 
/dev/block/mmcblk0p9: LABEL="system" UUID="da594c53-9beb-f85c-85c5-cedf76546f7a" TYPE="ext4" 
/dev/block/mmcblk0p10: UUID="57f8f4bc-abf4-655f-bf67-946fc0f9f25b" TYPE="ext4" 
/dev/block/mmcblk0p11: LABEL="S}M-^^M-~4M-9^DK $t" UUID="7F73-0B1A" TYPE="vfat" 
/dev/block/mmcblk0p12: UUID="49f005e2-2f62-448b-9ba1-3e4da2ee1b41" TYPE="ext4" 

# cat fstab.smdk4210:

# Android fstab file.
#<src>                                      <mnt_point>             <type>    <mnt_flags and options>                                   <fs_mgr_flags>
# The filesystem that contains the filesystem checker binary (typically /system) cannot
# specify MF_CHECK, and must come before any filesystems that do specify MF_CHECK
# data partition must be located at the bottom for supporting device encryption

/dev/block/mmcblk0p9                        /system                 ext4      ro,noatime                                                wait
/dev/block/mmcblk0p7                        /cache                  ext4      noatime,nosuid,nodev,journal_async_commit,errors=panic    wait,check,formattable
/dev/block/mmcblk0p7                        /cache                  f2fs      noatime,nosuid,nodev,inline_data,inline_xattr,discard     wait,check,formattable
/dev/block/mmcblk0p1                        /efs                    ext4      noatime,nosuid,nodev,journal_async_commit,errors=panic    wait,check,notrim
/dev/block/mmcblk0p10                       /data                   ext4      noatime,nosuid,nodev,noauto_da_alloc,journal_async_commit,errors=panic    wait,check,formattable,encryptable=/efs/metadata
/dev/block/mmcblk0p10                       /data                   f2fs      noatime,nosuid,nodev,inline_data,inline_xattr,discard     wait,check,formattable,encryptable=/efs/metadata
# /dev/block/mmcblk0p12                       /preload                ext4      noatime,nosuid,nodev,journal_async_commit                 wait

# vold-managed volumes ("block device" is actually a sysfs devpath)
/devices/platform/dw_mmc/mmc_host/mmc0/mmc0*     auto    auto    defaults        voldmanaged=sdcard0:11,nonremovable,noemulatedsd
/devices/platform/s3c-sdhci.2/mmc_host/mmc1*     auto    auto    defaults        voldmanaged=sdcard1:auto,encryptable=userdata
/devices/platform/s3c_otghcd/usb*                auto    auto    defaults        voldmanaged=usb:auto

# recovery
/dev/block/mmcblk0p5                        /boot                   emmc      defaults      recoveryonly
/dev/block/mmcblk0p6                        /recovery               emmc      defaults      recoveryonly

# zRAM
/dev/block/zram0    

parted and gdisk are missing. Somewhere I found binary of parted for ARM but permission denied to run in, when whoami return root and after chmod 777.

What you mean by mount everything that you can on the UI and get mount's output? On the UI you mean system GUI, not in TWRP?

Lanchon commented 4 years ago

be explicit. where did you get these outputs? android or TWRP?

i mean the UI of TWRP, it has a big MOUNT button in the main menu. mount is the command.

parted and gdisk are missing

you are running an obsolete TWRP, why?

permission denied

if you chmod +x (as you did) then there's something wrong with the binary or your TWRP. get a current TWRP

/dev/block/mmcblk0p10 /data ext4 noatime,nosuid,nodev,noauto_da_alloc,journal_async_commit,errors=panic wait,check,formattable,encryptable=/efs/metadata /dev/block/mmcblk0p10 /data f2fs noatime,nosuid,nodev,inline_data,inline_xattr,discard wait,check,formattable,encryptable=/efs/metadata

options like journal_async_commit are dangerous.

vitaly-zdanevich commented 4 years ago

The output above is from Android.

There is no official TWRP for Samsung Galaxy Note N7000:

The Samsung Galaxy Note 1 n7000 model will NEVER receive official TWRP support. The n7000 does not have a separately bootable recovery partition. Instead, you are stuck with whatever recovery is included in your ROM or kernel or boot image. You may find TWRP included in some ROMs, kernels, or boot images, especially if you can find OmniROM for your device.

I am using the TWRP from the page about this ROM, version is 3.1.0-0.

About mount: inside TWRP when I mount anything - I see USB Storage Mounted and Be sure to safely remove your device from your computer before unmounting!, and only one button: Unmount, I do not know how can I get any logs from here.

Lanchon commented 4 years ago

The output above is from Android.

i don't care about the output from android.

as i said before, boot twrp, and adb to it. then you'll have a useful command line.

There is no official TWRP for Samsung Galaxy Note N7000

still??? wow! well you can grab latest official for the i9100 and run my twrp patcher on it to convert it to n7000.

but i don't think that's needed, night owls 3.1 should be fine.

Lanchon commented 4 years ago

have you fixed this? is this issue abandoned?

vitaly-zdanevich commented 4 years ago

1) Flashed official TWRP for i9100 2) Flashing your https://github.com/Lanchon/TWRP-Patcher-SGS2, stopped error No space left on device, now I will try to remove something from some storage...

Lanchon commented 4 years ago

no. just go ahead with night owls TWRP 3.1.

Lanchon commented 4 years ago

make sure you flash a recovery for n7000 before rebooting!!!

vitaly-zdanevich commented 4 years ago

From TWRP 3.1:

# cat fstab.smdk4210:

# Android fstab file.
#<src>                                      <mnt_point>             <type>    <mnt_flags and options>                                   <fs_mgr_flags>
# The filesystem that contains the filesystem checker binary (typically /system) cannot
# specify MF_CHECK, and must come before any filesystems that do specify MF_CHECK
# data partition must be located at the bottom for supporting device encryption

/dev/block/mmcblk0p9                        /system                 ext4      ro,noatime                                                wait
/dev/block/mmcblk0p7                        /cache                  ext4      noatime,nosuid,nodev,journal_async_commit,errors=panic    wait,check_spo
/dev/block/mmcblk0p7                        /cache                  f2fs      noatime,nosuid,nodev,inline_data,inline_xattr,discard     wait,check_spo
/dev/block/mmcblk0p1                        /efs                    ext4      noatime,nosuid,nodev,journal_async_commit,errors=panic    wait,check
/dev/block/mmcblk0p10                       /data                   ext4      noatime,nosuid,nodev,nodiscard,noauto_da_alloc,journal_async_commit,errors=panic    wait,check_spo,encryptable=/efs/metadata
/dev/block/mmcblk0p10                       /data                   f2fs      noatime,nosuid,nodev,inline_data,inline_xattr,discard     wait,check_spo,encryptable=/efs/metadata
# /dev/block/mmcblk0p12                       /preload                ext4      noatime,nosuid,nodev,journal_async_commit                 wait

# vold-managed volumes ("block device" is actually a sysfs devpath)
/devices/platform/dw_mmc/mmc_host/mmc0/mmc0*    auto       auto      defaults      wait,voldmanaged=sdcard0:11,nonremovable,noemulatedsd
/devices/platform/s3c-sdhci.2/mmc_host/mmc1*    auto       auto      defaults      wait,voldmanaged=sdcard1:auto,noemulatedsd
/devices/platform/s3c_otghcd/usb*               auto       auto      defaults      voldmanaged=usbdisk0:auto

# recovery
/dev/block/mmcblk0p5                        /boot                   emmc      defaults      recoveryonly
/dev/block/mmcblk0p6                        /recovery               emmc      defaults      recoveryonly

# zRAM
/dev/block/zram0                            none                    swap      defaults      zramsize=367001600

blkid:

/dev/block/mmcblk0p12: UUID="49f005e2-2f62-448b-9ba1-3e4da2ee1b41" TYPE="ext4"
/dev/block/mmcblk0p11: UUID="7F73-0B1A" TYPE="vfat"
/dev/block/mmcblk0p10: UUID="57f8f4bc-abf4-655f-bf67-946fc0f9f25b" TYPE="ext4"
/dev/block/mmcblk0p9: LABEL="system" UUID="da594c53-9beb-f85c-85c5-cedf76546f7a" TYPE="ext4"
/dev/block/mmcblk0p7: UUID="57f8f4bc-abf4-655f-bf67-946fc0f9f25b" TYPE="ext4"
/dev/block/mmcblk0p1: UUID="57f8f4bc-abf4-0000-675f-946fc0f9f25b" TYPE="ext4"

fdisk:

BusyBox v1.22.1 bionic (2017-03-15 15:28 +0100) multi-call binary.

Usage: fdisk [-ul] [-C CYLINDERS] [-H HEADS] [-S SECTORS] [-b SSZ] DISK

Change partition table

    -u      Start and End are in sectors (instead of cylinders)
    -l      Show partition table for each DISK, then exit
    -b 2048     (for certain MO disks) use 2048-byte sectors
    -C CYLINDERS    Set number of cylinders/heads/sectors
    -H HEADS
    -S SECTORS

# fdisk /dev/block/mmcblk0p11:

The number of cylinders for this disk is set to 209792.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)

What else I can run?

vitaly-zdanevich commented 4 years ago

df -h:

Filesystem                Size      Used Available Use% Mounted on
tmpfs                   404.4M     56.0K    404.3M   0% /dev
tmpfs                   404.4M     13.6M    390.8M   3% /tmp
/dev/block/mmcblk0p11
                          6.4G      4.0G      2.4G  62% /sdcard0
/dev/block/mmcblk0p11
                          6.4G      4.0G      2.4G  62% /and-sec
/dev/block/mmcblk0p7    196.8M      4.1M    192.7M   2% /cache
/dev/block/mmcblk0p10
                          5.9G      2.4G      3.5G  41% /data
vitaly-zdanevich commented 4 years ago

mount:

rootfs on / type rootfs (rw,seclabel)
tmpfs on /dev type tmpfs (rw,seclabel,nosuid,relatime,mode=755)
devpts on /dev/pts type devpts (rw,seclabel,relatime,mode=600)
proc on /proc type proc (rw,relatime)
sysfs on /sys type sysfs (rw,seclabel,relatime)
selinuxfs on /sys/fs/selinux type selinuxfs (rw,relatime)
tmpfs on /tmp type tmpfs (rw,seclabel,relatime)
/dev/block/mmcblk0p11 on /sdcard0 type vfat (rw,relatime,fmask=0000,dmask=0000,allow_utime=0022,codepage=cp437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro)
/dev/block/mmcblk0p11 on /and-sec type vfat (rw,relatime,fmask=0000,dmask=0000,allow_utime=0022,codepage=cp437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro)
/dev/block/mmcblk0p7 on /cache type ext4 (rw,seclabel,relatime,user_xattr,barrier=1,data=ordered)
/dev/block/mmcblk0p10 on /data type ext4 (rw,seclabel,relatime,user_xattr,barrier=1,data=ordered)
vitaly-zdanevich commented 4 years ago

I found that inside TWRP's cli is available sgdisk - maybe I can somehow utilize it?

Lanchon commented 4 years ago

you have to list partitions of the device using fdisk gdisk sgdisk parted or what you find.

Lanchon commented 4 years ago

or you can run repit-dump and post the output if you want.

Lanchon commented 4 years ago

the device is /dev/block/mmcblk0

vitaly-zdanevich commented 4 years ago

# fdisk /dev/block/mmcblk0 -l

Disk /dev/block/mmcblk0: 30777344 sectors, 2740M
Logical sector size: 512
Disk identifier (GUID): 52444e41-494f-2044-4d4d-43204449534b
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 30777310

Number  Start (sector)    End (sector)  Size       Code  Name
   1            8192           49151       20.0M   0700  EFS
   2           49152           51711       1280K   0700  SBL1
   3           53248           55807       1280K   0700  SBL2
   4           57344           73727       8192K   0700  PARAM
   5           73728           90111       8192K   0700  KERNEL
   6           90112          106495       8192K   0700  RECOVERY
   7          106496          516095        200M   0700  CACHE
   8          516096          548863       16.0M   0700  MODEM
   9          548864         4743167       2048M   0700  FACTORYFS
  10         4743168        17326079       6144M   0700  DATAFS
  11        17326080        30752767       6556M   0700  UMS
  12        30752768        30769151       8192K   0700  HIDDEN
Lanchon commented 4 years ago

the partition labels in the partition table are all ok as you can see: https://github.com/Lanchon/REPIT/blob/07be97530196054e1676f7a3bede5c224b752e74/device/galaxy-s2/common.sh#L58-L61

the volume label, when it exists, is part of the filesystem inside a partition.

this looks like it is part of the sdcard partition (# 11):

/dev/block/mmcblk0p11: LABEL="S}M-^^M-~4M-9^DK $t" UUID="7F73-0B1A" TYPE="vfat"

you seem to have 2.5 GB of data in this partition. is it accessible? can you browse /sdcard from Android? from TWRP? what is in there? can you wipe this partition or does it have data you care about?

vitaly-zdanevich commented 4 years ago

cd /sdcard:

/sbin/sh: cd: can't cd to /sdcard

But I have sdcard0 with all my files:

Alarms
Android
Audiobooks
CastBox
Download
LOST.DIR
MapsWithMe
Movies
Music
Notifications
OTAUpdates
Pictures
Ringtones
Slack
TWRP
VK
clockworkmod
lanchon-repit-20170115-system=2G+keep-data=6G+keep-sdcard=max+keep-preload=min+wipe-n7000.zip
lanchon-twrp-patcher-20160417-crossflash-n7000.zip
parted
recovery-twrp3.1.0-build2-isorec-n7000.zip
twrp-3.3.1-0-i9100.img

And empty sdcard1.

vitaly-zdanevich commented 4 years ago

From Android I can browse sdcard0 (my main and only storage for files).

vitaly-zdanevich commented 4 years ago

I can wipe this partition sdcard0...

Lanchon commented 4 years ago

sdcard0 is the internal sdcard partition (probably in /sdcard when android is booted?). sdcard1 is the physical sdcard slot. it will be zero length because there is no media.

you can run repit with all partitions set to =same. it will check and repair all filesystems.

you can change the label of the sdcard0 vfat partition with fatlabel or similar cmd in recovery.

strange that you don't have a DCIM folder in your sdcard...

but i don't think this will help. i suppose it's an issue with your rom.

some roms have been converted to emulated sdcard. you shrink the sdcard to nothing and you grow data, then you have dynamic allocation between sdcard and data, encryption of sdcard, support for multiusers, etc.

Lanchon commented 4 years ago

some roms have been converted to emulated sdcard

but to be clear, your rom isn't. but you could use one of the more modern ones. i know they exist for the i9100 at least.

Lanchon commented 4 years ago

as a last resort you can wipe sdcard (you can use REPIT for that). but i don't think it will help.

vitaly-zdanevich commented 4 years ago

Wiped sdcard1 through the TWRP, booted into Android.

Broken label is gone: blkid:

/dev/block/zram0: UUID="8d4b4699-313d-42b4-8862-7abe39b02592" TYPE="swap" 
/dev/block/mmcblk0p1: UUID="57f8f4bc-abf4-0000-675f-946fc0f9f25b" TYPE="ext4" 
/dev/block/mmcblk0p7: UUID="57f8f4bc-abf4-655f-bf67-946fc0f9f25b" TYPE="ext4" 
/dev/block/mmcblk0p9: LABEL="system" UUID="da594c53-9beb-f85c-85c5-cedf76546f7a" TYPE="ext4" 
/dev/block/mmcblk0p10: UUID="57f8f4bc-abf4-655f-bf67-946fc0f9f25b" TYPE="ext4" 
/dev/block/mmcblk0p11: UUID="F726-1A16" TYPE="vfat" 
/dev/block/mmcblk0p12: UUID="49f005e2-2f62-448b-9ba1-3e4da2ee1b41" TYPE="ext4"

Settings -> Storage is not crash anymore.

Tried to save image in browser: SUCCESS!

Camera works again!

So the solution was to mkfs.vfat to sdcard1.

thank you for help!

Lanchon commented 4 years ago

fat partitions get corrupted.

you can run repit with all partitions set to =same. it will check and repair all filesystems.

for next time. take care