LinuxQuestions.org
Register a domain and help support LQ
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
 
Search this Thread
Old 02-25-2013, 08:06 AM   #1
madosaif
LQ Newbie
 
Registered: Dec 2012
Posts: 3

Rep: Reputation: Disabled
build read-only system ?


i got system like that : -
Filesystem 1K-blocks Used Available Use% Mounted on
tmpfs 127428 0 127428 0% /lib/init/rw
udev 122976 96 122880 1% /dev
tmpfs 127428 0 127428 0% /dev/shm
rootfs 127428 11008 116420 9% /
/dev/sda1 1827534 933144 800029 54% /ro
rootfs.tmpfs 127428 11008 116420 9% /rw
rootfs.aufs 127428 11008 116420 9% /

so i want to make another one exactly like that or even close the other df look like that :
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/hda3 678551 594050 84501 88% /
tmpfs 124004 0 124004 0% /lib/init/rw
udev 10240 520 9720 6% /dev
tmpfs 124004 4 124000 1% /dev/shm
/dev/hda1 19515 15940 3575 82% /boot
/dev/hda2 253807 7002 246805 3% /var/log_compressed
tmpfs 124004 0 124004 0% /tmp
tmpfs 124004 3552 120452 3% /var/log
tmpfs 124004 0 124004 0% /var/tmp
tmpfs 124004 20 123984 1% /var/run
tmpfs 124004 0 124004 0% /var/lock
tmpfs 124004 0 124004 0% /var/spool

i will really appreciate help and explain i did read alot and but i dont get how to do it by unoinfs or initramfs .

thanks in advance
 
Old 02-25-2013, 01:04 PM   #2
rtmistler
Senior Member
 
Registered: Mar 2011
Location: Milford, MA. USA
Distribution: MontaVista, Ubuntu, MINT
Posts: 1,026
Blog Entries: 7

Rep: Reputation: 447Reputation: 447Reputation: 447Reputation: 447Reputation: 447
Are you trying to make a complete duplicate of a Linux operating system, or just data from a drive?

To copy data only, you can use the dd command:


http://linux.die.net/man/1/dd


However you need to be careful about a few things:

1.) Using dd, "if" means "input file" and "of" means "output file", hence if you want to copy from say hda to sda your command "might" look something like:

Code:
dd if=/dev/hda of=/dev/sda
2.) You need to know that the available size of the output file destination exceeds the size of the input file source.

3.) You have to be root, or use sudo to accomplish this.

4.) Whatever is on /dev/sda will be erased in lieu of the newly copied file system from /dev/hda.

Another warning tip is long ago I made the choice to build a kernel and file system and then use dd to create exact copies of it, where I used the total amount of space on a compact flash card. Well it turns out that not all compact flash cards are the same even though they say they're 8 G, they're not, there are inconsistencies in the amount of data they can store, some can store more than others, and when I sourced my copy from a higher capacity flash and tried to copy to one that was within the 8G spec, but below the source, the copy failed and I didn't find that out until 10 minutes later when the dd was almost done, but failed. Since then I've done this via other means, not using dd at all.

If copying data, then use dd and follow the "make sure" tips above

If copying a Linux system, then it's a lot more involved, however repeatable and safer to develop a script to prepare your system copy.

Stated in steps, but not fully described, it would be like the following:

a. Partition your target drive - which also means removing any unwanted partitions.
b. Create file system(s) for each partition.
c. Install grub
d. Install your kernel
e. Copy over the RFS to your target drive

I can copy over a script I use, fairly large so I'll wait and see if the dd suggestion is best for your case.
 
Old 02-25-2013, 02:05 PM   #3
TKH
Member
 
Registered: Jul 2011
Location: Milky Way
Distribution: Ubuntu, LFS, Slackware, Fedora
Posts: 205

Rep: Reputation: 20
if you wanna make initramfs, you wanna have 'cpio' and 'gzip' in your system

to make an image, prepare all your files in one directory
(it is necessary make sure you add -a to your 'cp' command so the symlinks won't get referenced)

make sure that the 'init' is in the root of that directory (either a script or a symlink to /sbin/init)
also, the root directory (/) in fstab needs to be mounted as a tmpfs

then run in your prepared directory
Code:
find . | cpio -o format=newc > filename.img
gzip filename.img
now you will have an initrd image named 'filename.img.gz'
 
Old 02-26-2013, 07:50 AM   #4
madosaif
LQ Newbie
 
Registered: Dec 2012
Posts: 3

Original Poster
Rep: Reputation: Disabled
unfortunately dd command i cant do it because of the difference between the size of two compact flashes one is 2G the other is 1G , the first output of df command for read-only system i got so i want to make the other one like that . thats fstab for this read only system :
Quote:
# RootAufs has mounted the root file system in ram
#
# This fstab is in ram and the real fstab can be found /ro/etc/fstab
# the root file system ' / ' has been removed.
# All Swap files have been removed.
#

# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
proc /proc proc defaults 0 0
/dev/disk/by-uuid/ba2f02a1-636a-458c-8ad0-9543f489d5c0 /ro ext2 ro,relatime,err$

this is the real fstab /ro/etc/fstab


# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
proc /proc proc defaults 0 0
# / was on /dev/sda1 during installation
UUID=ba2f02a1-636a-458c-8ad0-9543f489d5c0 / ext2 noatime,error$ .

and thats fdisk for read only system :

*
Quote:
Device Boot * * *Start * * * * End * * *Blocks * Id *System
/dev/sda1 * * * * * * * 3 * * * *4721 * * 1887232 * 83 *Linux


about the second solution im realy confused and dont get it if you could explain more and i have cpio and gzip on my system

thats my system that i want to make it read only : df output


Quote:
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/hda3 678551 272785 405766 41% /
tmpfs 124004 0 124004 0% /lib/init/rw
udev 10240 556 9684 6% /dev
tmpfs 124004 4 124000 1% /dev/shm
/dev/hda1 19515 9881 9634 51% /boot
/dev/hda2 253807 6220 247587 3% /var/log_compressed
tmpfs 124004 0 124004 0% /tmp
tmpfs 124004 428 123576 1% /var/log
tmpfs 124004 0 124004 0% /var/tmp
tmpfs 124004 24 123980 1% /var/run
tmpfs 124004 0 124004 0% /var/lock
tmpfs 124004 0 124004 0% /var/spool

fdisk -l output :
Quote:
Device Boot Start End Blocks Id System
/dev/hda1 * 1 40 20159+ 83 Linux
/dev/hda2 41 560 262080 83 Linux
/dev/hda3 561 1928 689472 83 Linux

Last edited by madosaif; 02-26-2013 at 07:53 AM.
 
Old 02-26-2013, 08:14 AM   #5
rtmistler
Senior Member
 
Registered: Mar 2011
Location: Milford, MA. USA
Distribution: MontaVista, Ubuntu, MINT
Posts: 1,026
Blog Entries: 7

Rep: Reputation: 447Reputation: 447Reputation: 447Reputation: 447Reputation: 447
If you want to copy files to backup, then do the following on your target drive, and note that it will format the entire drive doing it this way:

Example is if you have a drive which is labeled /dev/sda1, # prepends comments for clarity

Code:
# in case the drive happens to be mounted, for instance a fresh thumbstick out of the box
sudo umount /dev/sda1;

# In fdisk, use 'p to print the partition table, then use 'd' followed by partition number to delete
# each partition, and use 'w' to write and exit.  This clears the disk of everything.
sudo fdisk /dev/sda1

# In fdisk, use 'n' to create a new partition, then 'p' for primary partition, then '1' for number of partition
# followed <RET> twice to accept defaults to use all of the disk for this partition, finally 'w' to write and exit
# You will now have re-partitioned your entire thumbstick and now you need to create a file system for it.
sudo fdisk /dev/sda1

# In mkfs you will be creating a file system, there are several, a recommended one is ext2, but you could use xfs,
# these are my recommendations, there can be others, in this example I suggest it to be ext2.
sudo mkfs.ext2 -F/dev/sda1

# Now the disk is empty and ready for copying and should also be mounted.

# Use cp -rf to copy a directory tree, for instance if the home location of your source is /media/<something> and you wish to copy that entire tree, then issue:

cp -rf /media/<something> /dev/sda1

# Note that you should try that not as root or sudo so that all the files end up being owned as you.  If that doesn't work, then fine, do:

sudo cp -rf /media/<something> /dev/sda1

# And to change the files owned as well as group, use:

sudo chown <your-username> -R /dev/sda1
sudo chgrp <your-groupname> -R /dev/sda1
 
Old 02-27-2013, 02:44 AM   #6
TKH
Member
 
Registered: Jul 2011
Location: Milky Way
Distribution: Ubuntu, LFS, Slackware, Fedora
Posts: 205

Rep: Reputation: 20
you can make a root fs with inited
 
  


Reply

Tags
embedded, initramfs, unionfs


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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Read System Call is getting blocked when tried to read the data from CDC device sanju.lnt Linux - Embedded & Single-board computer 0 09-11-2011 11:48 PM
Build system priyadarshan Linux - Newbie 3 08-03-2010 05:51 AM
Fooling The System That A Read-Only Device Is Read-Write Woodsman Slackware 34 08-26-2009 07:45 PM
Read Only File System? Can't read superblock! haughjd Linux - Software 4 01-15-2008 08:27 AM
Change from Read only to Read Write File System? justiceisblind Linux - Newbie 3 03-03-2002 07:23 PM


All times are GMT -5. The time now is 11:43 AM.

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