[Q] How to read/write ext3 filesystem image in Ubuntu?? - Android Q&A, Help & Troubleshooting

I developed a cramfs rom for the np7 after user dochoppy found root for the nextbook premium 7 tablet, but he then converted to ext3 which because its packed with features will be more popular. So I am trying to edit his ext3 rom in Ubuntu 11.10 and here is what I do:
1. Copy and paste system.img to desktop
2. Create a folder called system on desktop
3. In command prompt:
cd ~/Desktop
Sudo mount -t ext3 -o loop system.img system
(Asks for pw)
4. Doc said something about only being able to edit as root, so after some Googling I find out how to create a program that grants root.
5. (Open "run as" program) then I type "nautilus /home"
(Asks for pw)
6. Navigate to mounted system and I have read/write privileges (but only in this window)
HERE IS THE PROBLEM!!!
7. View the system mount properties, and it says I have 14.2 mb free space on device
8. Delete files throughout the system folder to make room (but when I refresh properties, free space increase doesn't show)
9. Try to add my own files after deleting some others, ans rather than using the increased space, it just fills the fourteen megs before telling me "device is out ofmemory "
What am I doing wrong, why is the system not physically making the proper system increase and decreases.

ognimnella said:
8. Delete files throughout the system folder to make room (but when I refresh properties, free space increase doesn't show)
Click to expand...
Click to collapse
If you use nautilus, there are chances that your files get just moved to Trash.
Try empting the trash, or remove them from command line (with sudo).

You have to be superuser (ie root) to be able to use mount in Ubuntu. Type 'sudo -' in the terminal again, enter your usernames password. (Default root password is your usernames pwd) then you can mount the image, edit it, etc.
When you open the terminal, type id . It'll show you your username, and uid. After you sudo, type id again. It'll show you're root with uid 0
Sent from my HTC EVO 3D using XDA App

Related

[Q] mount -o bind at boot on stock rom

Hi !
I have an application (CamScanner) with large amount of data (~8Gb). This app doesn't support transfering data do external SD card, so I checked mount -o bind command to bind directory with data stored on external SD to directory in /sdcard and it's working correctly. Question is where I can put this command so that system will run it at boot time after external sd card is ready. There is no /etc/init.d directory on my SGS2 (stock XXKI4). I prefer not to install any applications to perform such a simple task...
Thanks for help, regards !
slig said:
I prefer not to install any applications to perform such a simple task...
Click to expand...
Click to collapse
I think you have no choice, as stock kernels do not have init.d support. You'd need to go down the route of either using an app to run a script on boot, install a kernel with init.d support, or stick with your current method of manually running a script when you need to use the app.
Also, you could try asking the developers kindly to allow saving to external_sd. There's an Email Developer link on the Android market, and a Contact Us link on their website
Thanks for response. I found script named init.rc located in "/", it has several mount commands inside, wonder if it can be used...
Also discovered that app Tasked has ability to run shell scripts with root privileges (at boot or at application start). I suppose I have to put this shell script in /system because in /sdcard owner permissions cannot be set so that file cannot be modified (vfat does not support that) and a security hole would be created...
I think that I'll also ask developer for this feature as You suggest.
slig said:
Thanks for response. I found script named init.rc located in "/", it has several mount commands inside, wonder if it can be used...
Click to expand...
Click to collapse
Everything in "/" is initramfs, a volatile ramdisk changes to which would be lost
on reboot. Only exception are directories in which actual partitions are mounted,
like /system and /data (you can check which directories with "mount" command).
Have you tried just using symbolic link?
INFO
This may be the best solution, try something like:
Code:
mkdir /sdcard/AppFolder
ln -s /sdcard/AppFolder /data/data/com.your.application.data.folder
Just in case you don't know, you can execute those command using
Terminal Emulator. You were considering modifications to /, so I guess you already have root.
Yes, I have rooted my SGS2 via ZergRush.
I didn't know that / is volatile initramfs, thanks for that information.
As for symbolic link - unfortunately on my stock ROM both /sdcard and /sdcard/external_sd filesystems are vfat and don't support symbolic linking. Only working way I discovered is bind mount.
In my case, I have the following:
mount -o bind /sdcard/external_sd/CamScanner /sdcard/CamScanner
And application runs OK, all data is accessible and doesn't consume internal flash memory.
I'll take a look how hard would be to write some small application to do just this task - define some pairs of source and target directories and mount - bind them at start.
I've somehow missed the fact that you're need redirection from /sdcard
to /sdcard/external_sd, I was thinking about symlink on /data...
Anyways, there another nice trick you can do - if you can devote your SD card
to this one application, then just edit /system/etc/vold.fstab to make SD card
mount in /sdcard/CamScanner instead of /sdcard/external_sd.

Eclipse Android - add superuser permission

Hi, i'm trying to access /system/app/ so i can put apps in there, since i couldt figure out how to install apk files form Eclipse. I'm running Eclipse with the SDK installed, any help or example would be awesome. Thanks
/system is typically read-only (is on every android I know of). On many (most?) devices, the partition containing /system is also write-locked in the eMMC firmware. User apps should be installed into the /data partition.
What do you mean by installing from eclipse? Eclipse uses adb to push the package to the device and launch the package installer.
Please use the Q&A Forum for questions Thanks
Moving to Q&A
There are two ways that may be of help that I know of.
ADB Install:
1. In your Android SDK manager you should have a tool called ADB (Google how to add it to your system path to make life easier)
2. Navigate to your apk file you are trying to install and shift right click in the windows explorer windo and select Open Command line here.
3. then using command line (Console) type in:
Code:
adb install nameofapphere.apk
Note: If the app has spaces in the installer name either take out the spaces or add quotes to the command line as shown below.
Code:
adb install "name of app here.apk"
Second choice is gaining command line root and remounting the system directory with rw permissions.
1. Gain console root access.
2. in console type in:
Code:
adb shell
Note if you see $ you are not in root and # if you are in root.
3. (Please double check)
Code:
mount -o remount,rw /dev/null /system
This will remount your system drive so you have read/write access to it.
4. Push the file to /system/app
5. Set the permissions you want for the application
JavaChips said:
There are two ways that may be of help that I know of.
ADB Install:
1. In your Android SDK manager you should have a tool called ADB (Google how to add it to your system path to make life easier)
2. Navigate to your apk file you are trying to install and shift right click in the windows explorer windo and select Open Command line here.
3. then using command line (Console) type in:
Code:
adb install nameofapphere.apk
Note: If the app has spaces in the installer name either take out the spaces or add quotes to the command line as shown below.
Code:
adb install "name of app here.apk"
Second choice is gaining command line root and remounting the system directory with rw permissions.
1. Gain console root access.
2. in console type in:
Code:
adb shell
Note if you see $ you are not in root and # if you are in root.
3. (Please double check)
Code:
mount -o remount,rw /dev/null /system
This will remount your system drive so you have read/write access to it.
4. Push the file to /system/app
5. Set the permissions you want for the application
Click to expand...
Click to collapse
What i mean i'm writing an app in eclipse. And i have a listview with the apk's, i want when the user clicks on the items, it gets installed. Any ideas?
spxc said:
What i mean i'm writing an app in eclipse. And i have a listview with the apk's, i want when the user clicks on the items, it gets installed. Any ideas?
Click to expand...
Click to collapse
Why did this thread get moved. Took me forever to find it.
Anyway, it seems you want to programmatically install an APK from within an android app, is that correct? Just launch an intent with the package installer as a target:
Code:
Intent installIntent = new Intent(Intent.ACTION_VIEW);
installIntent.setDataAndType("/path/to/my/apk","application/vnd.android.package-archive");
startActivity(installIntent);
Moderator: this is definitely development related. Why was it moved to Q&A?
Gene Poole said:
Code:
Intent installIntent = new Intent(Intent.ACTION_VIEW);
installIntent.setDataAndType("/path/to/my/apk","application/vnd.android.package-archive");
startActivity(installIntent);
Moderator: this is definitely development related. Why was it moved to Q&A?
Click to expand...
Click to collapse
I'll agree, and secondly I think it was moved to Q&A because the original question was asked in a way that was not clear to it's intents.
So yeah, just pointing the apks to be run by the package installer via intent will launch the installer and install the app selected.

File copy and replacing in /system directory with root permission programmatically?

Can anyone kind enough show me how to copy files from my app assets folder to /system folder? I know how to get root access and all. For example: I want to copy file from "/assets/lib/libs.so" and check if this file already exist, if it does replace it to new "/system/lib/libs.so".
I think You could create a script (its language should not be too difficult) and make it start on every boot (every scripter Can do this) But I don't know how much time it would take and if You reboot often... Try to look for an app that runs script programmatically
Sent from R'lyeh using Cthulhu app
tsirhcitna said:
I think You could create a script (its language should not be too difficult) and make it start on every boot (every scripter Can do this) But I don't know how much time it would take and if You reboot often... Try to look for an app that runs script programmatically
Sent from R'lyeh using Cthulhu app
Click to expand...
Click to collapse
Sorry I haven't been clearly state that I want to write an app that does this, like in java.
Ooops my fault! I know java for PC but I never studied it for Android (when I tried to program for android the emulator taking twenty minutes to start stopped me). I don't know how to help you but seeing nobody is answering I can suggest you to go on Stack Overflow, it's all about coding, and all the answer I've seen on it where very good (You can also look for file manipulation on some android java tutorial)
Sorry I can't help you more
tsirhcitna said:
Ooops my fault! I know java for PC but I never studied it for Android (when I tried to program for android the emulator taking twenty minutes to start stopped me). I don't know how to help you but seeing nobody is answering I can suggest you to go on Stack Overflow, it's all about coding, and all the answer I've seen on it where very good (You can also look for file manipulation on some android java tutorial)
Sorry I can't help you more
Click to expand...
Click to collapse
can u write java code that wrap around command line that copy file to system folder? this will work, cos i can get su, just need to mount rw /system/lib then copy file from my app assets folder and replace the file in /system/lib
homi3kh said:
Can anyone kind enough show me how to copy files from my app assets folder to /system folder? I know how to get root access and all. For example: I want to copy file from "/assets/lib/libs.so" and check if this file already exist, if it does replace it to new "/system/lib/libs.so".
Click to expand...
Click to collapse
I suppose you're getting Root Permission running su command with Runtime.getRuntime().exec... right?
That's fine, you now need to run another commands:
To check if /assets/lib/libs.so (or any other file) exists:
Code:
ls /assets/lib | grep libs.so
If the file exists, you'll get "libs.so" as output of that command (otherwise, you will not get anything).
To remount /system in RW mode:
Code:
mount -o rw, remount -t yaffs2 /dev/block/mtdblock4 /system
Ok, now you can copy your file (or files, I dunno):
Code:
cp /assets/lib/libs.so /system/lib/libs.so
And finally, remount /system in RO mode again:
Code:
mount -o ro, remount -t yaffs2 /dev/block/mtdblock4 /system
Pretty easy, it isn't? :highfive:
Note: I highly recommend you to use RootTools, it's a lib to run commands as root very easily
RoberGalarga said:
I suppose you're getting Root Permission running su command with Runtime.getRuntime().exec... right?
That's fine, you now need to run another commands:
To check if /assets/lib/libs.so (or any other file) exists:
Code:
ls /assets/lib | grep libs.so
If the file exists, you'll get "libs.so" as output of that command (otherwise, you will not get anything).
To remount /system in RW mode:
Code:
mount -o rw, remount -t yaffs2 /dev/block/mtdblock4 /system
Ok, now you can copy your file (or files, I dunno):
Code:
cp /assets/lib/libs.so /system/lib/libs.so
And finally, remount /system in RO mode again:
Code:
mount -o ro, remount -t yaffs2 /dev/block/mtdblock4 /system
Pretty easy, it isn't? :highfive:
Note: I highly recommend you to use RootTools, it's a lib to run commands as root very easily
Click to expand...
Click to collapse
yes this is what i'm asking for but can you wrap it with RootTools code for me too? it's a bit confusing cos I don't know much about command line.
Ok. It's kinda easy, BTW:
To grant root permissions (If you already have root permissions in other way, you don't need to do this again):
Code:
if (RootTools.isAccessGiven()) {
// your device is rooted!! The fun can begin :)
}else{
// Not rooted... no fun here :(
}
Now, an example using 1 command (you'll need to develop the rest). Checking if /assets/lib/libs.so exists:
Code:
try {
List<String> output = RootTools.sendShell("ls /assets/lib | grep libs.so",-1);
if (output.get(0).equals("libs.so")){ //output.get(0) is the way to read 1 line of the command output
//the file exist... you can continue
}else{
//something is wrong, or the file is missing... =/
}
} catch (Exception e) {
// something went wrong, deal with it here
}
Proceed in the same way to run the other commands. Note that there are ways to run several commands using RootTools, you can check them in the Usage Page (I think will be a bit easy, since you don't need to read the output of the other commands).

[GUIDE][TUTORIAL][SHARE] How to make a nandroid backup directly to your computer with

Note: I'm just sharing the work of the XDA member.This guide was tested on Galaxy Y GT-S5360.Here's a little introduction:
scandiun said:
INFORMATION
This guide is intended to make a full backup of your android phone (the entire memory block with all partitions) or a single partition (including sdcards, etc) directly to your computer, in either
Block level (with dd): for single partitions or whole memory block (all partitions in one piece). The backup always has the same size which is the size of the partition.
File level (with tar): only for individual partitions. This only includes files and folders, so occupies much less space, depending on how much filled is the partition.
It can be done with the phone powered on or from ClockWorkMod Recovery (from both ADB works, while in Fastboot doesn't so won't apply). Unless specified the commands meant to be used from Windows. For Linux and Unix is similar.
REQUIREMENTS
Rooted Android Phone
Busybox installed on your phone
If you are using Linux / OS X you have native tools, for Windows download Cygwin, and install with it netcat, pv and util-linux. Get them from Cygwin's setup.exe
ADB installed.
Make sure adb.exe is in your windows' path. See here and here, or use Path Manager.
Android phone with USB Debugging enabled, and the proper drivers installed on Windows so the phone is recognized. Typing 'adb devices' on a terminal should show your device.
PARTITION IDENTIFICATION
You now have to identify the partition or block device that you want to backup. For a single partition you can use either tar or dd, while for the entire memory block you can only use dd.
For example, on Galaxy Nexus you have the list of partitions here and for Galaxy S2 here.
Usually on android, the entire block containing all partitions is located at /dev/block/mmcblk0 and the data partitions is a subpartition of it. You can push parted with GPT support to your device and see all information on a partition or block.
Whole phone memory -> /dev/block/mmcblk0 (may vary, in some phones this is the sdcard)
Subpartitions -> depends on each device. Usually at /dev/block/platform/dw_mmc/by-name/ there are listed by name linking to the real device.
Back up of the whole memory block (via adb)
Connect the phone in ADB mode and unlock the screen.
Open one Cygwin Terminal and enter (replace mmcblk0 if needed):
Code:
adb forward tcp:5555 tcp:5555
adb shell
su
/system/xbin/busybox nc -l -p 5555 -e /system/xbin/busybox dd if=/dev/block/mmcblk0
You will see the cursor blinking at the left. Now the phone is waiting to send the block over the network.
Open another Cygwin terminal and type:
Code:
adb forward tcp:5555 tcp:5555
cd /path/to/store/the/backup
nc 127.0.0.1 5555 | pv -i 0.5 > mmcblk0.raw
You will see how the image size is growing until it finishes. Now you have the whole phone backed up in raw format. You can see the contents of the GPT partition with gptfdisk tool, available for windows, linux and such. See official website and sourceforge to get it. You can do it the same from ClockWorkMod Recovery but you have to mount first the /system partition since the busybox included with clockworkmod does not come with netcat and you have to use the one from the system partition.
With further linux tools you could edit or extract single partitions from the whole block.
You can use adb via wifi as well with applications like WiFi ADB.
Back up of the whole memory block (via wifi)
Original post: [Q] Nandroid directly to computer w/o sdcard
We need to install a FTP server on the computer or the other device, configure a user with a password if we want to, and set some port. It uses by default 21 but this example uses 40. We must set a home dir for the user with write permissions.
Usually is a good idea to put myfifo in /cache not in /data because we may overwrite sensitive data in case we want to use that raw image for data recovery.
Open one Cygwin terminal
Code:
adb shell
su
mkfifo /cache/myfifo
ftpput -v -u user -p pass -P 40 COMPUTER_IP block.raw /cache/myfifo
Open another Cygwin terminal
Code:
adb shell
su
dd if=/dev/block/mmcblk0p12 of=/cache/myfifo
Tips:
- Fifos only can be made on linux native filesystems, for example on a FAT partition is not possible.
- Reading from a partition does not modify it.
Now check on Filezilla Server the speed
Back up of the whole memory block (USB tethering, Wifi tethering)
To use tethering you have to disconnect the computer from all networks and connect it only to the phone with the type of connection you want.
Once you connect it, you can view the IP of the computer and the IP of the phone from connection properties. The ip is the computer ip and the gateway is the phone's ip.
Wifi Tethering: Computer Phone Internet
USB Tethering:
Computer Phone Internet
Conputer Phone Internet
This is exactly the same as via wifi, except that the transfer speed is much higher because the computer and the phone are directly connected, instead of using a router as a gateway. In this case, the gateway is the phone. USB tethering has the highest transfer rate.
Back up of a single partition (raw = every bit of the partition)
It is exactly the same as the the previous but replacing mmcblk0 by the corresponding partition. You can use in this particular case several software to read the partition from windows, depending on partition filesystem: DiskInternals Linux Reader, Ext2Read, Ext2 File System Driver for Windows, Ext4Explore, plugin for Total Commander and ImDisk Virtual Disk Driver. You can also use recovery software on individual partitions like Recuva in combination with VHD Tool or command line tools included with operating systems.
Back up of a single partition (tar = only files and folders)
In this case, you need the partition mounted. To see the list of mounted partitions type on Cygwin Terminal
Code:
adb shell mount
Now you need to know where is mounted the partition you want to backup, for example the firmware is mounted on /system, which is the ROM.
In this case you will have to open three terminals, because of android limitations:
Open one Cygwin terminal and create a fifo, in /cache, for example, and redirect the tar there
Code:
adb forward tcp:5555 tcp:5555
adb shell
su
/system/xbin/busybox mkfifo /cache/myfifo
/system/xbin/busybox tar -cvf /cache/myfifo /system
We have to do it this way because redirecting the tar to stdout (with - ) is broken on android and will corrupt the tar file.
Open a second Cygwin terminal and type:
Code:
adb forward tcp:5555 tcp:5555
adb shell
su
/system/xbin/busybox nc -l -p 5555 -e /system/xbin/busybox cat /cache/myfifo
Open a third Cygwin terminal and type:
Code:
adb forward tcp:5555 tcp:5555
cd /path/to/store/the/backup
nc 127.0.0.1 5555 | pv -i 0.5 > system.tar
You can browse the tar file with Winrar, Total Commander, PeaZip and almost any compression tool. Note that you shouldn't extract files or edit it since the tar format saves the permission and owner data for each file, that is lost when extracted to FAT / NTFS partitions and you will mess things when restoring.
LINKS
[GUIDE] Internal Memory Data Recovery - Yes We Can!
How to Create and Attach a Virtual Hard Disk in Windows 7
[Guide] Types of Android backups
Click to expand...
Click to collapse
Original Thread : http://forum.xda-developers.com/showthread.php?t=1818321
And here is the guide to make nandroid backup through terminal app in android with switching off the phone in sdcard!!!
http://forum.xda-developers.com/showthread.php?t=1620255

Question only local disk folder is available on this computer

1 month ago I was using win 11 and when I entered this computer, the images downloaded and other disks were visible, then I used linux for 1 month, 1 month later I realized that linux was not for me and went back to win 11. I installed the latest win 11 iso file, and when I go to this computer folder, only the local disk folder appears, not the folders such as downloads images. how can i solve this problem?
Delete all partitions and create only one ntfs.
I suppose the method of installation you have done was wrong, CLEAN install the W11 using NTFS, when there's question asking to select partition when installation screen, delete all drive including RESERVED bla bla bla .. make sure there's only 1 drive while installing W11 ..
the rest of the standard partition and folders will be created automatically, do post the new screenshot after you have done those .. ​
This may cause because you have not set the file permission for windows 11 and you have deleted your linux os, in this scneario you can try the attrib command for this.
Attrib -r *.* — to change file permissions on all files in folder recursively.
Attrib
Displays, sets, or removes the read-only, archive, system, and hidden attributes assigned to files or directories. Used without parameters, attrib displays attributes of all files in the current directory.
Syntax
attrib [{+r|-r}] [{+a|-a}] [{+s|-s}] [{+h|-h}] [[Drive:][Path] FileName] [/s[/d]]
Top of page
Parameters
+r : Sets the read-only file attribute.
-r : Clears the read-only file attribute.
+a : Sets the archive file attribute.
-a : Clears the archive file attribute.
+s : Sets the system file attribute.
-s : Clears the system file attribute.
+h : Sets the hidden file attribute.
-h : Clears the hidden file attribute.
You can also refer to the following article that might help you Folder Access Denied Error on Windows 11

Categories

Resources