| « Get access to the OBP prompt on a Sun T5120 / T5220 | Ubuntu 8.04 Hoary persistent on a USB stick » |
Ubuntu 8.04 Hoary USB stick persistent - Unclean casper-rw unmount
You may have been confronted to this issue: when using Ubuntu Hoary on a USB stick in persistent mode, the casper-rw partition is not cleanly unmounted.
If this happens, the default user home folder may be corrupted. Then the profile can not be loaded.
To fix this, I’ve modified the initrd.gz, by adding the e2fsck tool to it and forcing the checking of the casper-rw partition before mounting it.
0/ Some pre-requisites
The following is based on the Ubuntu wiki.
The squashfs filesystem will be modified. To do so the squashfs-tools package is to be installed on your machine.
Extract the casper/filesystem.squashfs file from the Ubuntu Hoary iso to /mnt/hoary:
root@server:~# mkdir -p /mnt/hoary root@server:~# cd /mnt/hoary root@server:/mnt/hoary# unsquashfs /media/cdrom/casper/filesystem.squashfs
1/ Adding the e2fsck tool to the initrd
Edit the following file
/mnt/hoary/squashfs-root/usr/share/initramfs-tools/hooks/casper
and add these lines
# We need fsck to check the persistent casper-rw partition copy_exec /sbin/e2fsck /sbin
Here is the patch to apply to hooks/casper.
2/ Forcing the checking of the casper-rw partition
Edit this file:
/mnt/hoary/squashfs-root/usr/share/initramfs-tools/scripts/casper
and add the following lines
log_warning_msg "Checking the casper-rw partition ${cowdevice}"
e2fsck -v -y ${cowdevice} || \\
log_warning_msg "Not able to check the ${cowdevice} partition"
log_warning_msg "Mounting the casper-rw partition"
before the
mount ${cowdevice} -t ${cow_fstype} -o rw,noatime /cow || \\
panic "Can not mount $cowdevice on /cow"line. (See also this post)
Here is the patch to apply to the casper file.
3/ Build of the initrd.gz
chroot to the extracted squashfs filesystem. Use mkinitramfs to build the modified initrd.gz.
root@server:/mnt/hoary/squashfs-root# chroot . root@server:/# mkinitramfs -o initrd.gz 2.6.24-16-generic
4/ Copy the initrd.gz to the USB stick
root@server:/# exit root@server:/mnt/hoary/squashfs-root# cp initrd.gz /media/ubuntu
5/ Build the squashfs file
root@server:/mnt/hoary/squashfs-root# mksquashfs . ../filesystem.squashfs root@server:/mnt/hoary/squashfs-root# cp ../filesystem.squashfs \\ /media/ubuntu/casper
Your USB persistent live system is now fully operational! Enjoy!
4 comments
I did have to make a slight change to get it to work for me, as I was working with the Live CD booted up.
Before step 3 (build initrd.gz) I have to bind the dev directory by:
mount --bind /dev /media/diskname/hoary/squashfs-root/dev
Otherwise the mkinitramfs doesn't work.
The only question I had was once I booted up, the persistent USB system did not have sudo rights.
I think this is a permissions thing on the /sbin directory - have to look into it.
I believe I have sorted out my permissions issue (ie. couldn't sudo).
I had unsquashed the file system onto a NTFS USB drive, and some of the permissions aren't supported out of the box.
Made a EXT2 partition on the drive and unsquashed to this and it worked better in terms of allowing the proper Linux file permissions.
By the way, glad I can help you ;-)