LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   squashfs system multiboot from sd/usb (https://www.linuxquestions.org/questions/linux-general-1/squashfs-system-multiboot-from-sd-usb-4175507104/)

karmawheel 06-05-2014 03:19 AM

squashfs system multiboot from sd/usb
 
Hello.

For a past few days I'm struggling to create sd card with few root filesystems 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?

onebuck 06-05-2014 08:20 AM

Moderator Response
 
Please post your thread in only one forum. Posting a single thread in the most relevant forum will make it easier for members to help you and will keep the discussion in one place. This thread is being closed because it is a duplicate of https://www.linuxquestions.org/quest...sb-4175507066/


All times are GMT -5. The time now is 04:20 AM.