LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat
User Name
Password
Red Hat This forum is for the discussion of Red Hat Linux.

Notices


Reply
  Search this Thread
Old 03-02-2010, 06:54 PM   #1
shylock_1
LQ Newbie
 
Registered: Oct 2009
Posts: 25

Rep: Reputation: 0
Moving var to hard disk on embedded Linux....


Hi Forum,

Is any body know how to move var which is on the 8MB ROM to Hard disk????

I have following scenario:

1/ On IBM powerPC with 8MB ROM and 64MB RAM
2/ Entire Linux 2.6.9 OS with application the image size is 5.1MB
3/ The image get flashed in to ROM and creates var directory on ROM area
4/ Recent upgrade with Hard drive for 60GB gave more storage power
5/ Hence, moving var on to hard disk IS first priority, so var store larger size of data and log, following is snapshot of content on ROM
Code:
bin       etc       lib       proc      sbin      sys       var
dev       hdd       mnt       root      share     tmp       var_init
My goal is ....

1/ Move var to hard disk with all its contents
2/ the IDE hard disk recognised by OS as hdd and mounted in ROM as directory
3/ Once var is moved on the hard disk then OS should look for all setting and data, log etc on hard drive based var directory hence kernel must look for all necessary files on hdd/var directory
4/ The original var could be remain on ROM but made empty and not to be used by OS.
5/ The entire OS on ROM area is READ only and cannot be deleted i.e. var directory hence only var contents moved to hdd/var directory.
6/ The file /etc/fstab is completely blank with zero size.

I appreciate some body knows how to move var from readonly (squashfs) file system to hard disk.
Thanks in advance.
 
Old 03-02-2010, 07:54 PM   #2
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
Create a partition on you hard disk to hold /var. Format it with your favorite file system. Let's say this partition is /dev/sdb3.

With your squashed installation started up & running, copy the contents of you current var into an aribtrary place. Issue this command:
Code:
mount /dev/sdb3 /var
Copy the copied contents of the original /var to the new /var.

To do this mounting automatically you'd need to change the fstab and resquash the file system. The line in the fstabe must become:
Code:
/dev/sdb3 /var   ext3  defaults   0   2
Check the file system type.

However, these ROM installations often have an unsquashed part on the ROM device where you can easily add additional configuration. Being this either your own fstab, or a script which does the mount for you.

jlinkels
 
Old 03-03-2010, 08:17 AM   #3
shylock_1
LQ Newbie
 
Registered: Oct 2009
Posts: 25

Original Poster
Rep: Reputation: 0
Thanks jlinkels

Currently the hard drive already mounted on OS as a hdd directory if I issue:

Code:
~ > ls
bin       etc       lib       proc      sbin      sys       var
dev       hdd       mnt       root      share     tmp       var_init

~ > cd hdd
/mnt/hdd1 > ls
download      log           movie         pictures      swapswapfile
epg           lost+found    photos        swapfile      tmp
/mnt/hdd1 >
The above is snapshot from device /mnt/hdd1 mounted in mnt directory. If I check cd hdd I can view all the contents of hdd and subsequently create directory and copy contents of var but making kernel to read from the /mnt.hdd1/var is tricky cause currently fstab file is completely blank and READ ONLY. When I try to edit using vi the message pops up readonly cannot write.

CAUSE file system squashFS applies on /etc/ file system too.

the question is how to make /etc/fstab? Although I tried to
Code:
/etc > chmod +x fstab
chmod: fstab: Read-only file system
 
Old 03-03-2010, 08:54 AM   #4
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
Squashfs is a compressed file system, which is uncompressed at the time of booting. It can safely be mounted as RO because it is not to be expected that someone has to make changes.

In order to access fstab in a squashfs file system, you'd have to UNsquash the squash file, make you changes and squash it back again.

jlinkels
 
Old 03-03-2010, 10:13 AM   #5
shylock_1
LQ Newbie
 
Registered: Oct 2009
Posts: 25

Original Poster
Rep: Reputation: 0
Right... if Understood correctly? I am using telnet to communicate STBox running Linux Kernel 2.6.9

Preliminaries...
1/ The Hard disk is already formated and MOUNTED as /mnt/hdd1 with smylink as hdd at the / directory
2/ Therefore, no need to format or mount hard disk?

Secondary

3/ Copy the contents of /var directory to else where ... say /hdd/tmp/var (/mnt/hdd1/tmp/var)
4/ Once the content of var copied else where then issue command
Code:
mount /dev/hdd1 /var
5/ Above command will mount the var on hdd (/mnt/hdd1/var) for only current SESSION?
6/ Once mounted var restore all its contents from (/mnt/hdd1/tmp/var) to hdd/var (mnt/hdd1/var)

Hay presto... this will work for current session?

Automatic mount of above procedure every after reset needs require to modify fstab with provided entry? So moving of var on hdd will occur automatically.

But I do not have unsquashFS utility on this system and I cannot find one that can go on to fit within less than 1mb ROM free space left of this ppc device.
By the way where I can find the unsquashfs utility?

Thanks once again for your valuable guidance.
 
Old 03-03-2010, 12:19 PM   #6
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
Quote:
Originally Posted by shylock_1 View Post
Right... if Understood correctly? I am using telnet to communicate STBox running Linux Kernel 2.6.9

Preliminaries...
1/ The Hard disk is already formated and MOUNTED as /mnt/hdd1 with smylink as hdd at the / directory
2/ Therefore, no need to format or mount hard disk?
Well... yes and no.
You hard disk partition is mounted as /mnt/hdd1. That is something different than /var. You want it mounted on /var. If you mount /dev/hdd1 on /var, your entire /dev/hdd1 would become /var. I am not sure you want that. You might want to create a hdd2 partition and mount /dev/hdd2 as /var.

Quote:
Originally Posted by shylock_1 View Post
Secondary
3/ Copy the contents of /var directory to else where ... say /hdd/tmp/var (/mnt/hdd1/tmp/var)
No, you must copy the contents in the root of the partition you will mount on /var, hence /dev/hdd1/ or /dev/hdd2 if you follow my advice.
Quote:
Originally Posted by shylock_1 View Post
4/ Once the content of var copied else where then issue command
Code:
mount /dev/hdd1 /var
See comments above, the entire /dev/hdd1 will become /var

Quote:
Originally Posted by shylock_1 View Post
5/ Above command will mount the var on hdd (/mnt/hdd1/var) for only current SESSION?
Yes. If you don't mount it, your system will use the original /var on ROM

Quote:
Originally Posted by shylock_1 View Post
6/ Once mounted var restore all its contents from (/mnt/hdd1/tmp/var) to hdd/var (mnt/hdd1/var)
The previous contents of /var on you hard disk remained the same of course as just before you last shutdown.

Hay presto... this will work for current session?

Quote:
Originally Posted by shylock_1 View Post
Automatic mount of above procedure every after reset needs require to modify fstab with provided entry? So moving of var on hdd will occur automatically.
Only the mounting will be automatic. You don't have to move anything. What was on your hard disk last time will there be again. Just like mounting /var on an ordinary computer. After copying /var the first time you never have to copy anything. Just mount /var from within fstab.

Quote:
Originally Posted by shylock_1 View Post
But I do not have unsquashFS utility on this system and I cannot find one that can go on to fit within less than 1mb ROM free space left of this ppc device.
By the way where I can find the unsquashfs utility?
You don't have to unsquash on your embedded system. I expect you find somewhere the file user.sqf or system.sqf on you ROM. You can download that to your normal computer. Unsquash, edit, resquash and upload back to your embedded system.

There is a Linux package called squashfs-tools. You should install that on your desktop computer in order to be able to squash.

jlinkels
 
Old 03-03-2010, 06:54 PM   #7
shylock_1
LQ Newbie
 
Registered: Oct 2009
Posts: 25

Original Poster
Rep: Reputation: 0
Thank you for the detail explanation step by step,which gave only choice to create an extra partition on the drive. That take back to square one...

1/ How to check that how many partition exists on the drive. (sfdisk -l /dev/hdd seems to be not working)
2/ After discovering number of partition on disk; adding an extra partition which exclusively for var

On embedded linux BusyBox utilities are limited and I have sfdisk as follow:
Code:
/bin > sfdisk
sfdisk version 3.08 (aeb@cwi.nl, 040824) from util-linux-2.12r
Usage: sfdisk [options] device ...
device: something like /dev/hda or /dev/sda
useful options:
    -s [or --show-size]: list size of a partition
    -c [or --id]:        print or change partition Id
    -l [or --list]:      list partitions of each device
    -d [or --dump]:      idem, but in a format suitable for later input
    -i [or --increment]: number cylinders etc. from 1 instead of from 0
    -uS, -uB, -uC, -uM:  accept/report in units of sectors/blocks/cylinders/MB
    -T [or --list-types]:list the known partition types
    -D [or --DOS]:       for DOS-compatibility: waste a little space
    -R [or --re-read]:   make kernel reread partition table
    -N# :                change only the partition with number #
    -n :                 do not actually write to disk
    -O file :            save the sectors that will be overwritten to file
    -I file :            restore these sectors again
    -v [or --version]:   print version
    -? [or --help]:      print this message
dangerous options:
    -g [or --show-geometry]: print the kernel's idea of the geometry
    -G [or --show-pt-geometry]: print geometry guessed from the partition table
    -x [or --show-extended]: also list extended partitions on output
                             or expect descriptors for them on input
    -L  [or --Linux]:      do not complain about things irrelevant for Linux
    -q  [or --quiet]:      suppress warning messages
    You can override the detected geometry using:
    -C# [or --cylinders #]:set the number of cylinders to use
    -H# [or --heads #]:    set the number of heads to use
    -S# [or --sectors #]:  set the number of sectors to use
You can disable all consistency checking with:
    -f  [or --force]:      do what I say, even if it is stupid
The arguments to the sfdisk seems to different rather than /dev/hdd or /dev/hda or /dev/sda, I tried almost everything but incorrect argument to sfdisk.

The dmesg content as follow:
Code:
eth0: SMC91C11xFD (rev 1) at 0xc305e300 IRQ 28 [nowait]
eth0: Ethernet addr: 00:09:34:10:29:c5
eth0: PHY LAN83C183 (LAN91C111 Internal)
Uniform Multi-Platform E-IDE driver Revision: 7.00alpha2
ide: Assuming 50MHz system bus speed for PIO modes; override with idebus=xx
IBM STB04xxx OCP IDE driver version 2.3
Probing IDE interface ide0...
hda: IC35L040AVVN07-0, ATA DISK drive
Unhandled interrupt 19, disabled
Using deadline io scheduler
ide0 at 0xc30601f8-0xc30601ff,0xc30601f6 on irq 25
hda: max request size: 128KiB
hda: 80418240 sectors (41174 MB) w/1863KiB Cache, CHS=65535/16/63, UDMA(33)
hda: cache flushes supported

 /dev/ide/host0/bus0/target0/lun0: p1
Any comment; analysing the above dmsg text?
 
Old 03-03-2010, 06:59 PM   #8
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
sfdisk -l /dev/hda.
I take it cfdisk is not available?

jlinkels
 
Old 03-04-2010, 05:18 AM   #9
shylock_1
LQ Newbie
 
Registered: Oct 2009
Posts: 25

Original Poster
Rep: Reputation: 0
Yes; you are right the cfdisk utility is not available on BusyBox; the amalgamation of many bash, sh utilities into single source-of-point for ELDK (Embedded Linux Deve. Kit) from Denx predominantly used for developing Set Top Boxes STB.

Code:
~ > sfdisk -l /dev/hda
/dev/hda: No such file or directory

sfdisk: cannot open /dev/hda for reading
The sfdisk parameters return above result. In my despair I tried almost every known parameter values but no avail.
Have you come across to cvs.tuxbox.org?

Thank you.
 
  


Reply



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
Boot embedded PC from a USB hard disk using grub zvivered Linux - Embedded & Single-board computer 3 07-29-2009 02:32 PM
Reconfiguring a network card after moving hard disk hansalfredche Linux - Hardware 1 12-10-2006 01:05 PM
Moving /var/adm and /var/lib - why does it hurt? J_Szucs Linux - General 1 09-15-2004 06:46 PM
Moving data to another hard disk. wenberg Slackware 10 06-20-2004 11:17 PM
moving hard disk with fedora2 to another computer?? new22linux Fedora - Installation 1 06-05-2004 11:45 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat

All times are GMT -5. The time now is 12:18 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration