LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 06-04-2014, 04:50 PM   #1
karmawheel
LQ Newbie
 
Registered: Jun 2014
Posts: 5

Rep: Reputation: Disabled
squashfs system multiboot from sd/usb


Hello.

For a past few days I'm struggling to create sd card with few root filestystems to choose from on boot. The idea is to convert running system to squashfs file and put it on sd card. Systems should be readonly and any additional files added later should be kept on rw partition mounted on start. Any other files should be kept in RAM and lost after reboot. So partitions should be like this:

1st - vmlinuz, kernel, grub files, os1.squash, os2.squash and so on
2nd - mounted to, for instance to /mnt/ after boot with extra files available across systems (after succeeding booting OS at all )

For testing purposes I'm using vmware, with one HDD with centos 6.5 installed and run from it, and second HDD simulating SD card which is plugged to base OS, then unplugged and run by its own on another virtual machine.

So what I do is:

Rsync running system to /root/sqfs/
Code:
sudo rsync -av --one-file-system --exclude=/proc/* --exclude=/dev/* --exclude=/sys/* --exclude=/tmp/* --exclude=/home/* --exclude=/lost+found --exclude=/var/tmp/* --exclude=/boot/grub/* --exclude=/root/* --exclude=/var/mail/* --exclude=/var/spool/* --exclude=/media/* --exclude=/etc/fstab --exclude=/etc/mtab --exclude=/etc/hosts --exclude=/etc/shadow* --exclude=/etc/gshadow* --exclude=/root/sqfs/ --exclude=/etc/resolv.conf --exclude=/etc/hostname / sqfs/
creating squashfs file from it
Code:
sudo mksquashfs /root/sqfs/ /root/os1.squash -noappend
using fdisk on second HDD to create two primary partitions and make 1st bootable

creating filesystems on them
Code:
mkfs.ext2 /dev/sdb1
mkfs.ext3 /dev/sdb2
mounting partitions and moving squash fs there
Code:
mkdir /mnt/sq1
mkdir /mnt/sq2

mount /dev/sdb1 /mnt/sq1
mount /dev/sdb2 /mnt/sq2

cp /root/os1.squash /mnt/sq1/
copy kernel
Code:
cp /boot/vmlinuz-2.6.32-431.el6.x86_64 /mnt/sq1/vmlinuz
cp /boot/initramfs-2.6.32-431.el6.x86_64.img /mnt/sq1/initrd.img
instaling grub
Code:
grub-install --no-floppy --root-directory=/mnt/sq1/ /dev/sdb1
and editing grub in /mnt/sq1/boot/grub/grub.cfg
Code:
default=0
timeout=5
hiddenmenu
title os1
        kernel /vmlinuz root=live:LABEL=os1.squash rootfstype=auto live_dir=/ ro liveimg nodiskmount nolvmmount rd.luks=0 rd.lvm=0 rd.md=0 rd.dm=0
        initrd /initrd.img
So I end up with structure like this:
Code:
/mnt/sq1
├── boot
│** └── grub
│**     ├── device.map
│**     ├── e2fs_stage1_5
│**     ├── fat_stage1_5
│**     ├── ffs_stage1_5
│**     ├── grub.conf
│**     ├── iso9660_stage1_5
│**     ├── jfs_stage1_5
│**     ├── minix_stage1_5
│**     ├── reiserfs_stage1_5
│**     ├── stage1
│**     ├── stage2
│**     ├── ufs2_stage1_5
│**     ├── vstafs_stage1_5
│**     └── xfs_stage1_5
├── initrd.img
├── os1.squash
└── vmlinuz
Then after boot an choosing os1 dracut throws warning
Code:
dracut Warning: No root device "block:/dev/mapper/live-rw" found
Most probably I don't use kernel parameters right, can u please give me hint how it supposed be done?
 
Old 06-05-2014, 03:45 PM   #2
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,976

Rep: Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623
All the web pages suggest you are running centos and not a live version.

I'd suggest that you look at puppy and LPS distro's for examples on squashfs live versions. Might have to use puppy to even view LPS but it is easy enough.

And it may be that the way you created the filesystem based on mounts may be wrong. Someone may need to double check that.

Last edited by jefro; 06-05-2014 at 03:47 PM.
 
Old 06-06-2014, 03:42 AM   #3
karmawheel
LQ Newbie
 
Registered: Jun 2014
Posts: 5

Original Poster
Rep: Reputation: Disabled
OK. Got it!

The main problem was wrong structure in squashfs file. File system need to be in file formatted as ext3 then in folder THEN squashed. This link was a big help: https://lists.fedoraproject.org/pipe...ly/004523.html

so:

Code:
	dd if=/dev/zero of=/home/images/ext3fs.img bs=1MB count=4096
	mkfs.ext3 /home/images/ext3fs.img
	mount -o loop /home/images/ext3fs.img /mnt/next3fs
	cp -dpR ${dir_w_filesys}/* /mnt/next3fs/
Also when formatting first partition I use label
Code:
	mkfs.ext3 -L part1 /dev/sdb1
And then in grub you can use:
Code:
root=live:LABEL=part1
 
Old 06-06-2014, 03:41 PM   #4
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,976

Rep: Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623
Thanks for the update and solution and links.
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
squashfs system multiboot from sd/usb karmawheel Linux - General 1 06-05-2014 08:20 AM
Grub in USB Flash(Squashfs) raj010 Linux - Newbie 1 12-09-2010 11:11 PM
How to update squashfs on embedded system? MrUmunhum Linux - General 1 09-12-2010 05:32 PM
How to update squashfs on embedded system? MrUmunhum Linux - Embedded & Single-board computer 0 09-12-2010 02:28 PM
Regarding squashfs file system and encryption ashok kumar reddy Linux - General 0 11-19-2009 11:41 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

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

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