![]() |
defragment a SD ext3 partition with tar
Since my N800 was out of battery in a very short time and after check that It happens when I was running maemo from the SD ext3 filesystem.
I decided to backup the files, format and restore them using a linux desktop and a SD reader. I had a some errors uncompressing tar file, Steps I did: (execution commands as root (sudo) 1. image backup of partition dd -if .... -of ....img 2 tar -cf backup.tar /media/myN800 3 format ext3 partition with Qparteditor 4 uncompress tar file from desktop to SD ext3 partition (after some hours I received errors in some files) 5 Try N800 without success :( I think I can use the dd command to restore my backup image and return to the previous state, however, dd will place the content with the same initial fragmentation and I would like to avoid that file fragmentation. What do you think about? What about pipe the output of dd with the input of tar and create new tar file? is ext3 a good filesystem for flash memory? |
Re: defragment a SD ext3 partition with tar
You should have made a blank ext3 disk image and
Code:
cp -a /media/N800 /mnt/diskimage Code:
cp -a /mnt/diskimage /media/N800 |
Re: defragment a SD ext3 partition with tar
dd copy the partition to a real hard disk partition. Then do a simple cp -r from hard disk to a new sd card.
|
Re: defragment a SD ext3 partition with tar
You can mount the image and redo the tar file or "cp -a" the files from the image to the partition
mount -o loop backup.img /mnt About ext3, it is the recommended filesystem for SD cards, that assertion about the journal wearing out the card is incorrect (my own system is on ext3 and it is 3 years old, the card is fine) |
Re: defragment a SD ext3 partition with tar
Quote:
The archive streaming (tar operation) was done on the N800, booted from internal flash. It requires GNUtar or some other advanced version of tar. GNUtar is available from the Diablo repositories and should be installed through App Manager in the internal OS. I believe that this procedure will only work if the SD partition containing the OS still has a fair amount of empty space. If it does not, you might have to combine the formatting with an increase in size of the ext3 partition (perhaps by shrinking the FAT partition). AFAIU, cloning of partitions must be done from a smaller partition to a larger one. The idea here is to clone from your SD partition to a larger one on another device, and then shrink the recipient partition before cloning back to the reformatted original one. You will need a USB drive larger than the ext3 partition on your SD card. (You could use another SD card in a USB card reader for this purpose - whatever you have at hand.) You must also be able to use your N8x0 as USB host. PROCEDURE 1. Format the USB drive so that it has an ext3 partition larger than the SD partition that you want to reformat. 2. Boot your N8x0 from the internal flash. List the modules currently in the kernel: Code:
sudo gainroot Code:
insmod /mnt/initfs/lib/modules/2.6.21-omap1/mbcache.ko 3. Check that top-level directories /opt and /floppy exist and are empty. Attach the USB drive to N8x0. Run dmesg to see how the drive has been recognised. In my case, it was recognised as sda, and the ext3 partition was /dev/sda2. The annoying automounting on N8x0 will mount the ext3 partition in a way that you don't want it. So, following the Maemo tradition of cloning from /floppy to /opt, you need to remount it on /opt. Still as root: Code:
umount /dev/sda2 4. Remove the USB drive, attach it to Ubuntu PC, open GParted. In the graphic representation of the USB drive's ext3 partition, there is a yellow bar indicating the space used, and the rest of the space is white. Shrink the ext3 partition until there is just a small amount of white. The resulting partition should be smaller than the ext3 partition on your SD card. (If not, you will have to increase the size of the SD card's ext3 partition in the next step.) Close GParted. 5. Safely remove the USB drive from the PC. Attach the SD card (in card reader). Open GParted again. Reformat the SD card's ext3 partition, increasing its size if necessary (see above). Close GParted. Safely remove the card reader. Replace the SD card in N8x0. 6. If you have done anything else on the N8x0 in the meantime, make sure that it is now running from internal flash, with XTerm open and root, and the mbcache, jbd and ext3 modules in the kernel. 7. (Reverse of Step 3.) Attach USB drive to N8x0. Run dmesg to see how it is recognised (assumed to be sdb in the following). Code:
umount /dev/sdb2 9. Reboot to use your reformatted ext3 partition. Before 9. In my case, the reformatting involved a change from ext2 to ext3. It was therefore necessary to edit bootmenu.conf and run initfs_flash, so that the mbcache, jbd and ext3 modules would be inserted at boot time. FOOTNOTES. Sorry, this has already been a long post, but there are a few things to add. (1) The reason for running the tar operation on N8x0 rather than PC is that you can have conflicts of file ownership when an archive is extracted on one machine and the resulting files are run on another. It should be possible to avoid such problems by adding a "-p" option to both extractions (the "xvf" parts). I have not tried that and therefore can not say for sure that it will work. In any case, the N8x0 does a good job of running this operation. (2) [EDIT: I previously reported that Opera browser had difficulty loading images after the procedure described above. It now appears that this must have been either a problem on my network (now cleared up), or a self-correcting result of the change from ext2 to ext3 file system (e.g. maybe it took a period of journalling before Opera interacted efficiently with the ext3 journal). I had copied the rootfs back to two newly reformatted cards (one SDHC, one MMC-mobile). Both initially had the problem with images in Opera. On one, the problem disappeared after I re-installed Opera, and I therefore reported here that it was fixed by the re-installation. However, the problem also disappeared from the other card, without re-installation of Opera or any other "fix". No fix is needed.] (3) From time to time, forum members ask how they can back up and restore an entire operating system, fully loaded with apps and settings. The usual answer is to make a jffs2 image, which can be restored by nandwrite or by a flasher. The problem with that answer is that the restoration must be made to the internal flash, which might already contain something that you want to leave undisturbed. Furthermore, your fully loaded system might be too big to fit back into the internal flash. (That was the whole point of installing it on the SD card, remember?) The procedure described above would allow restoration to any sufficiently large linux-formatted partition of your choice. |
All times are GMT. The time now is 07:52. |
vBulletin® Version 3.8.8