LinuxQuestions.org
Review your favorite Linux distribution.
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
 
LinkBack Search this Thread
Old 06-07-2011, 06:26 AM   #1
littlebigman
Member
 
Registered: Aug 2008
Posts: 443

Rep: Reputation: 32
Question Copy root filesystem from RAM to flash?


Hello,

I boot up a Linux appliance entirely in RAM, ie. the image has a Linux kernel and an attached ext2 root filesystem.

Now that it's working, I would like to copy the root filesystem from RAM to a NAND flash memory.

Can I just mount the NAND, run "cp -a /* /mnt/nand", reboot with the kernel command line "root=/dev/mtdblock2 rw", and expect Linux to be happy... or is it more involved than this?

Thank you.
 
Old 06-08-2011, 02:24 AM   #2
John VV
Guru
 
Registered: Aug 2005
Posts: 12,156

Rep: Reputation: 1597Reputation: 1597Reputation: 1597Reputation: 1597Reputation: 1597Reputation: 1597Reputation: 1597Reputation: 1597Reputation: 1597Reputation: 1597Reputation: 1597
edited
 
Old 06-08-2011, 08:07 AM   #3
Soadyheid
Member
 
Registered: Aug 2010
Location: Near Edinburgh, Scotland
Posts: 667

Rep: Reputation: 114Reputation: 114
You can't copy a "live" running OS be it Linux, Windows, Unix, OSx or whatever as there are dynamic files which would fail to be copied correctly. This is assuming you could actually get the OS to copy! It would try to copy the process which is copying itself and would probably disappear up its own a....h Well, you get my drift?
That's why you would normally use a live CD to copy a HDD resident OS to another HDD. The source data is stable in this case.

Play Bonny!
 
Old 06-08-2011, 03:09 PM   #4
jefro
Guru
 
Registered: Mar 2008
Posts: 10,276

Rep: Reputation: 1258Reputation: 1258Reputation: 1258Reputation: 1258Reputation: 1258Reputation: 1258Reputation: 1258Reputation: 1258Reputation: 1258
I posed this question about that on a gentoo live dvd. One suggestion was to rsync it and exclude a few folders.

Kind of wonder if it wouldn't be easier to use the original image.
 
Old 06-09-2011, 02:54 AM   #5
littlebigman
Member
 
Registered: Aug 2008
Posts: 443

Original Poster
Rep: Reputation: 32
It might not be recommended, but the appliance comes with a shell script that does just this, ie. copy the whole directory tree from RAM to the NAND memory, excluding useless directories:

Code:
mount /dev/mtdblock2 /mnt

cp -a /etc /mnt
cp -a /bin /mnt
cp -a /lib /mnt
cp -a /tmp /mnt
cp -a /home /mnt
cp -a /root /mnt
cp -a /usr /mnt
cp -a /sbin /mnt
cp -a /var /mnt
cp -a /dev /mnt
mkdir /mnt/mnt
mkdir /mnt/proc
mkdir /mnt/sys

sync
cd /
umount /mnt
 
Old 06-09-2011, 03:35 AM   #6
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 11,824

Rep: Reputation: 926Reputation: 926Reputation: 926Reputation: 926Reputation: 926Reputation: 926Reputation: 926Reputation: 926
"s /useless/troublesome/"
There are (potentially) issues with this, but done carefully is quite well understood.
 
Old 06-09-2011, 11:28 AM   #7
frieza
Senior Member
 
Registered: Feb 2002
Location: harvard, il
Distribution: Ubuntu 11.4,DD-WRT micro plus ssh,lfs-6.6,Fedora 15,Fedora 16
Posts: 3,010

Rep: Reputation: 352Reputation: 352Reputation: 352Reputation: 352
Quote:
Originally Posted by littlebigman View Post
It might not be recommended, but the appliance comes with a shell script that does just this, ie. copy the whole directory tree from RAM to the NAND memory, excluding useless directories:

Code:
mount /dev/mtdblock2 /mnt

cp -a /etc /mnt
cp -a /bin /mnt
cp -a /lib /mnt
cp -a /tmp /mnt
cp -a /home /mnt
cp -a /root /mnt
cp -a /usr /mnt
cp -a /sbin /mnt
cp -a /var /mnt
cp -a /dev /mnt
mkdir /mnt/mnt
mkdir /mnt/proc
mkdir /mnt/sys

sync
cd /
umount /mnt
a quicker way would be to copy this little script into a file and execute it
Code:
!#/bin/bash
for dirtocopy in {etc,bin,lib,tmp,home,root,usr,sbin,var,dev}
do
cp -a /$dirtocopy /mnt
done
for dirtocreate in {mnt,proc,sys}
do
mkdir /mnt/$dirtocreate
done
sync
cd /
umount /mnt

Last edited by frieza; 06-09-2011 at 11:29 AM.
 
Old 06-10-2011, 04:10 AM   #8
littlebigman
Member
 
Registered: Aug 2008
Posts: 443

Original Poster
Rep: Reputation: 32
Thanks Frieza for the script.

Quote:
Originally Posted by syg00 View Post
There are (potentially) issues with this, but done carefully is quite well understood.
I'm curious about potential issues: Could you elaborate a bit?
 
Old 06-10-2011, 05:18 AM   #9
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 11,824

Rep: Reputation: 926Reputation: 926Reputation: 926Reputation: 926Reputation: 926Reputation: 926Reputation: 926Reputation: 926
See post #3 - you need to stay away from the pseudo filesystems.
 
Old 06-14-2011, 04:55 AM   #10
littlebigman
Member
 
Registered: Aug 2008
Posts: 443

Original Poster
Rep: Reputation: 32
Thanks for the tip. It's just a small root fs on an embedded Linux, but I'll update the root partition from Uboot + rootfs file.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need to know how to copy a root file from non corrupted filesystem to another amsweitzer General 4 04-20-2011 10:42 PM
How do I copy /dev/* from filesystem to filesystem Ulysses_ Linux - Desktop 12 03-09-2011 09:53 PM
root filesystem on RAM bluepenguine Linux - General 3 06-10-2009 03:42 AM
mount root fs from compact flash into ram Mr.J Linux - Embedded & Single-board computer 0 07-31-2008 07:22 AM


All times are GMT -5. The time now is 03:25 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration