H@L0_F00 Posted January 29, 2010 Share Posted January 29, 2010 With the release of Back|Track 4 Final, I finally got around to looking into what scripts needed to be modified and in what way they needed to be modified in order to change the casper directory. This guide, as far as I know, will work with any Ubuntu based LiveCD (BT4, SamuraiWTF, Mint, etc.) that uses the casper squashfs files. So, I will be talking about BT4, but it can be applied to any distro. NOTE: You will need some type of writable media, which means you can't do this by booting from your flash drive and then writing to that same flash drive because BT mounts it as read-only by default. You could, however, boot BT from your flash drive, unmount your hard drive, remount your hard drive as writable, and then write the modified rootfs.gz to your hard drive. The script found at the bottom of this guide assumes that you have booted into BT4 from either the CD or an ISO (if in a VM). The script is NOT by any means a "good" script, because it is the first script I've ever written, but it gets the job done. You will need to manually change the path you want BT to find the casper directory in, and you may have to change the path that points to the original initrd files. Key: commands - type this into the terminal windows and press "Enter" stuff to change - in the command, change this to your desired path To manually change the casper directory: 01. Boot into Back|Track 4 from either a VM, a CD, or a flash drive. 02. startx 03. Start a new terminal. (Black icon on the bottom left) 04. mkdir tmp 05. cp /cdrom/boot/initrd.gz ./ 06. gunzip initrd.gz 07. cd tmp 08. cpio -id < ../initrd 09. mv ../initrd ../initrd.old 10. replace '$path/casper' '$path/.multiboot/BT4-final/casper' '$path/.disk/casper-uuid' '$path/.multiboot/BT4-final/.disk/casper-uuid' '$directory/casper' '$directory/.multiboot/BT4-final/casper' -- scripts/casper 11. find . | cpio -oH newc > ../initrd 12. gzip ../initrd 13. cd .. 14. rm -rf tmp REPEAT THIS, REPLACING EVERY "initrd" WITH "inird800" AND THEN AGAIN WITH "initrdfr" Now you can copy the .gz files into your 'boot' directory for BT4 OR: Copy and paste this into a file, change where it says "PATH/TO/YOUR/BT4DIRECTORY" to wherever you have Back|Track 4, save it with a .sh file extension, open a terminal window, chmod 777 change_casper.sh, then run it with: ./change_casper.sh rm -rf /bt4-final_edit/ mkdir -p /bt4-final_edit/tmp/ echo -e "Copying...\c" cp /cdrom/boot/initrd*.gz /bt4-final_edit/ echo -e "\t\t\t\tDone!" echo -e "Decompressing (gunzip)...\c" gunzip /bt4-final_edit/initrd*.gz echo -e "\t\tDone!" cd /bt4-final_edit/tmp/ mkdir initrd initrd800 initrdfr # cpio all echo -e "Extracting (cpio)...\c" cd initrd && cpio --quiet -id < ../../initrd cd ../initrd800 && cpio --quiet -id < ../../initrd800 cd ../initrdfr && cpio --quiet -id < ../../initrdfr echo -e "\t\t\tDone!" # replace all strings cd .. && rm ../initrd* echo -e "Replacing all needed strings...\c" replace -s '$path/casper' '$path/[color="#808080"]PATH/TO/YOUR/BT4DIRECTORY[/color]/casper' '$path/.disk/casper-uuid' '$path/[color="#808080"]PATH/TO/YOUR/BT4DIRECTORY[/color]/.disk/casper-uuid' '$directory/casper' '$directory/[color="#808080"]PATH/TO/YOUR/BT4DIRECTORY[/color]/casper' -- initrd*/scripts/casper echo -e "\t\tDone!" # repack all with cpio echo -e "Repacking (cpio)...\c" find initrd/ | cpio --quiet -oH newc > ../initrd find initrd800/ | cpio --quiet -oH newc > ../initrd800 find initrdfr/ | cpio --quiet -oH newc > ../initrdfr echo -e "\t\t\tDone!" # recompress all with gzip echo -e "Recompressing (gzip)...\c" gzip ../initrd* echo -e "\t\t\tDone!" # cd, cp all to desktop, && rm tmp files cd echo -e "Copying to /root/desktop/ ...\c" cp /bt4-final_edit/init* . echo -e "\t\tDone!" rm -rf /bt4-final_edit/ echo -e "\n\n\n ************************************************* You can now copy the initrd*.gz files from the * Desktop to the 'boot' folder on your multipass! * ************************************************* \n\n\n" If anybody can code a better script where the user can input their desired path and such, please post it! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.