
I found myself struggling with SD card corruption this week.
I think it was due to a combination of overclocking and an old SD card. Although I use svn or git with most of my code, occasionally I do a lot of work in a day and forget to add a file. After this last time, I decided to move my home directory to a partition on an external HDD just in case.
I will be posting some file recovery methods later in case you have also lost data.
Start by making sure your external drive is connected and open a terminal.
First of all you need to have root privileges to do all this (or use sudo privileges)
Make sure your drive is not mounted. To unmount it:
umount /mntpointIf you already have your external drive partitioned, skip to Step 4.
Step 1: Partition External Drive
The fdisk command with the -l flag can list all of your drives and partitions. So start by running that:
fdisk -l
Pick the HDD you want to use (mine was /dev/sdb but Ill put sdx and you can fill in appropriately) and run fdisk again to see partition information
fdisk /dev/sdx
You should be in an interactive prompt. Type p to see the partitions. There should be none. If there arent any, skip to Step 3.
Step 2: Deleting or resizing
If you need the old partitions and want to shrink them, type q to exit the fdisk prompt, otherwise skip to Step 3.
If you are using the partitions and just want to resize them, then there are various commands to do that (also its a good idea to have a back up).
For ext3/ext4, just use: resize2fs /dev/sdx #size
Or use parted
parted /dev/sdx (opens interactive prompt)
resize #size
For ntfs:
ntfsresize --size #sizeM /dev/sdx
Then open back up the fdisk prompt, you need to make new partitions that match.
Step 3: Writing partition changes
(Open fdisk back open if you closed it)
Now just use d #partition to delete any old partitions.
Then type n to make a new partition followed by p to make it a primary partition. If this is the only partition you need, you can make it the whole disk size. If you shrank a partition, you need to make two new partitions, with the first one having a size that matches your resize options.
Now type w to write changes to disk then q to quit. It will probably give you some warnings, it almost always does. Pay attention to them but dont freak out.
Now format the new partition (If you only made one partition #=1):
mkfs.ext4 /dev/sdx#
Step 4: Copying over your home directory files
Mount your new partition:
sudo mkdir /media/tmp
sudo mount -t ext4 /media/tmp
Navigate to your root folder
cd /home
Copy all your data recursively (this option seems to have worked the best for me to get all of the files including .bashrc and .vimrc files)
sudo cp -rp ./ /media/tmp
Step 5: Mounting your new home directory
Once that is finished, you can move the home directory and mount the new one (make sure no program is currently using the home directory or you will get errors).
sudo umount /media/tmp
sudo rm -rf /media/tmp (get rid of the tmp folder)
sudo mv /home /old_home
sudo mkdir /home
sudo echo "/dev/sdx# /home ext4 defaults,noatime,nodiratime 0 0" >> /etc/fstab
Again replacing x# with your drive number (mine was b2).
Now we can test it by mounting home. If this doesnt work, somewhere you messed up
sudo mount /home
After you have confirmed everything is working and copied over and you dont need your old home directory, you can delete it.
sudo rm -fr /old_home
Now you dont need to worry about SD Corruption.
References for help:
http://joshua14.homelinux.org/blog/?p=660
http://linuxtechres.blogspot.com/2007/08/how-to-use-ntfsresize-from-command-line.html
Consider donating to further my tinkering.
Places you can find me
Related Post:
a
- Take a better selfie with Lily
- Calculating Ada The Countess of Computing
- Creating a templated Binary Search Tree Class in C
- Projecting without a projector sharing your smartphone content onto an arbitrary display
- Will a robot take your job
- Hacker Tricks from Insiders A Threat to ERP Systems
- Forget Turing the Lovelace Test Has a Better Shot at Spotting AI
- A Billion Words Because todays language modeling standard should be higher
- Apple is building a car
- A step closer to quantum computation with Quantum Error Correction
- Could you fly a fighter jet with your mind
- How Google Translate squeezes deep learning onto a phone
- The Plan to Build a Massive Online Brain for All the World’s Robots
- A Beginner’s Guide to Deep Neural Networks
- How to Copy or Hide a File inside an Image
- The life of a software engineer
- A Farewell to Orkut
- A Project on Windows NT
- Building A Visual Planetary Time Machine
- 10 awesome internet hacks to make your life better
- Google Databoard A new way to explore industry research
- How to put a flash mp3 player in blogger post
- A year and a bit with Inbox Zero
- Map of Life A preview of how to evaluate species conservation with Google Earth Engine
computer
- Take a better selfie with Lily
- Free Lecture The Psychology of Computer Insecurity
- MOOC Research and Innovation
- Calculating Ada The Countess of Computing
- When can Quantum Annealing win
- Creating a templated Binary Search Tree Class in C
- Projecting without a projector sharing your smartphone content onto an arbitrary display
- Will a robot take your job
- Facebook Introduces ‘Hack ’ the programming language of the future
- High Resolution Scary Haunted House Wallpapers for Desktop
- TYBSC IT Sem V Question Papers 2009 Mumbai University
- Home automation update
- Very easy to download youtube videos audio mp3 format
- HD Dark Desktop Background Wallpapers Download
- Launching the Quantum Artificial Intelligence Lab
- Syrias children learn to code with the Raspberry Pi
- Running omxplayer from the command line easily using alias
- Largest collection of Google Logos on the web Set 7
- Collection of SQL queries with Answer and Output Set 2
- Prevent access to specific partition or drive
- Summer Games Learn to Program
- PiAUISuite Update and Voicecommand v3 1
- Sign in to edx org with Google and Facebook and
- Large Scale Machine Learning for Drug Discovery
- Hacker Tricks from Insiders A Threat to ERP Systems
different
0 comments:
Post a Comment