Linux - NewbieThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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?
Distribution: Cinnamon Mint 20.1 (Laptop) and 20.2 (Desktop)
Posts: 1,672
Rep:
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.
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
Distribution: Ubuntu 11.4,DD-WRT micro plus ssh,lfs-6.6,Fedora 15,Fedora 16
Posts: 3,233
Rep:
Quote:
Originally Posted by littlebigman
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
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.