Debian LiveCD: Difference between revisions

From PS3 Developer wiki
Jump to navigation Jump to search
 
(38 intermediate revisions by 7 users not shown)
Line 1: Line 1:
[[Category:Linux]]
[[Category:OtherOS]]


=Introduction=
=Introduction=
Line 65: Line 65:


tasksel install standard
tasksel install standard
aptitude install binutils gcc make git vim openssh-server sudo wireless-tools wpasupplicant libssl-dev
aptitude install binutils gcc make git vim openssh-server sudo wireless-tools wpasupplicant libssl-dev libncurses5-dev
aptitude  install gcc-spu g++-spu newlib-spu spu-tools
aptitude  install gcc-spu g++-spu newlib-spu spu-tools
aptitude  install parted kpartx cryptsetup libreadline-dev libaio-dev libdevmapper-dev libudev-dev


# Make SSH server start at boot so we could ssh to our LiveCD
# Make SSH server start at boot so we could ssh to our LiveCD
Line 75: Line 76:


rm -f /etc/udev/rules.d/70-persistent-net.rules
rm -f /etc/udev/rules.d/70-persistent-net.rules
# exit chroot environment
exit
# Unmount dev and proc
umount /root/livecd/dev/shm
umount /root/livecd/dev/pts
umount /root/livecd/dev
umount /root/livecd/proc
</syntaxhighlight>}}
</syntaxhighlight>}}
<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />


=Creating Root Filesystem=
=Creating Root Filesystem=
Line 82: Line 93:
cd /root/livecd
cd /root/livecd
mksquashfs * ../root.sfs
mksquashfs * ../root.sfs
</syntaxhighlight>}}<br /><br /><br /><br /><br />
</syntaxhighlight>}}


=Modifying Root Filesystem=
=Modifying Root Filesystem=
Line 93: Line 104:


mksquashfs * ../root-changed.sfs
mksquashfs * ../root-changed.sfs
</syntaxhighlight>}}<br /><br /><br /><br /><br /><br /><br /><br /><br />
</syntaxhighlight>}}


=Linux 3 Kernel=
=Linux 3 Kernel=


* We need a Linux 3 kernel with overlayfs support so we could create a tmpfs over our read-only base filesystem.
* We need a Linux 3 kernel with overlayfs support so we could create a tmpfs over our read-only base filesystem.
* At the moment overlayfs is not supported on Linux 3.5 so it leaves us with Linux 3.4 which doesn't really matter because all my Linux 3 drivers are supported on Linux 3.4 just fine.
* Furthermore, we want to compile PS3 HDD driver as module because in this case we can easily change HDD region flags.
* Furthermore, we want to compile PS3 HDD driver as module because in this case we can easily change HDD region flags.


Line 104: Line 114:
* http://gitorious.ps3dev.net/ps3linux/kernel-configs
* http://gitorious.ps3dev.net/ps3linux/kernel-configs
* http://gitorious.ps3dev.net/ps3linux/kernel-patches-34
* http://gitorious.ps3dev.net/ps3linux/kernel-patches-34
* http://gitorious.ps3dev.net/ps3linux/kernel-patches-35
* http://gitorious.ps3dev.net/ps3linux/kernel-patches-36
* http://gitorious.ps3dev.net/ps3linux/livecd
* http://gitorious.ps3dev.net/ps3linux/livecd


Line 133: Line 145:
mkdir initramfs
mkdir initramfs
cd initramfs
cd initramfs
mkdir -p bin dev etc lib/modules/3.4.10 mnt proc sbin sys usr/bin usr/sbin
mkdir -p bin dev etc lib/modules/3.6.4 mnt proc sbin sys usr/bin usr/sbin


cp ~/busybox-1.20.1/busybox bin/
cp ~/busybox-1.20.1/busybox bin/
Line 166: Line 178:
for mod in fat vfat isofs crc-ccitt crc-itu-t lzo_compress udf squashfs overlayfs \
for mod in fat vfat isofs crc-ccitt crc-itu-t lzo_compress udf squashfs overlayfs \
           ps3_gelic ps3stor_lib sg ps3rom usb-common usbcore ehci-hcd ohci-hcd usb-storage; do
           ps3_gelic ps3stor_lib sg ps3rom usb-common usbcore ehci-hcd ohci-hcd usb-storage; do
     path=`find  /home/glevand/linux-3.4.10-build/lib/modules/3.4.10 -name $mod.ko`
     path=`find  /home/glevand/linux-3.6.4-build/lib/modules/3.6.4 -name $mod.ko`
     cp $path lib/modules/3.4.9/
     cp $path lib/modules/3.6.4/
done
done


Line 175: Line 187:
cd ..
cd ..
cat initramfs.cpio | gzip > initramfs.cpio.gz
cat initramfs.cpio | gzip > initramfs.cpio.gz
</syntaxhighlight>}}<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />
<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />
<br /><br /><br /><br /><br /<br /><br /><br />><br />


# Make changes to initramfs
gunzip initramfs.cpio.gz
mkdir initramfs
cd initramfs
cpio -i -d -H newc --no-absolute-filenames < ../initramfs.cpio
</syntaxhighlight>}}
=Images=
=Images=


* vmlinux-3.4.10.xz: http://www.multiupload.nl/L69J301LKO (MD5 d2b90a7a40bb8b6e03d2b5fdb8d5270b)
* vmlinux-3.6.4.xz: http://www.multiupload.nl/D0PYT6HGC0 (MD5 4b5fdb2995fde82e0f6817a7a86fca2c)
* root.sfs: http://www.multiupload.nl/BYTNSLYT23 (MD5 4e9a46715b41a9ae01101051550b9efd)
* root.sfs: http://www.multiupload.nl/MWDSBR4OJZ (MD5 3ee12e2d351e0bbe1cd7818be23d8973)
* Tools available on the root filesystem: gcc, spu-gcc, spuisofs, spuldrfs, ps3vuart-tools, ps3sed and all my other PS3 Linux drivers. Everything you need to compile and test various PS3 stuff.
* Tools available on the root filesystem: gcc, spu-gcc, spuisofs, spuldrfs, ps3vuart-tools, ps3sed and all my other PS3 Linux drivers. Everything you need to compile and test various PS3 stuff.
* In case someone still hasn't figured it out yet, password for root is root and password for glevand is glevand :)
* In case someone still hasn't figured it out yet, password for root is root and password for glevand is glevand :)
Line 191: Line 207:


* Your USB drive should be formatted with FAT32 filesystem.
* Your USB drive should be formatted with FAT32 filesystem.
* initramfs.cpio.gz: http://www.multiupload.nl/8AVFVVACTM (MD5 48e5c3a5f0320248c474017e6d8b40f0)
* initramfs-usb.cpio.gz: http://www.multiupload.nl/Y084SCQBL3 (MD5 f94b6aec2e5fbbb26f7d466165071469)
* Create '''debianlive''' directory on your USB drive.
* Create '''debianlive''' directory on your USB drive.
* Put vmlinux-3.4.10 (extract xz archive), initramfs.cpio.gz and root.sfs into this directory.
* Put vmlinux-3.6.4 (extract xz archive), initramfs.cpio.gz and root.sfs into this directory.


{{Keyboard|content=<syntaxhighlight lang="bash">
{{Keyboard|content=<syntaxhighlight lang="bash">
Line 200: Line 216:
-rwxr-xr-x 1 root root  6746154 Aug 18 17:44 initramfs.cpio.gz
-rwxr-xr-x 1 root root  6746154 Aug 18 17:44 initramfs.cpio.gz
-rwxr-xr-x 1 root root 249835520 Aug 18 17:15 root.sfs
-rwxr-xr-x 1 root root 249835520 Aug 18 17:15 root.sfs
-rwxr-xr-x 1 root root  7288832 Aug 18 17:31 vmlinux-3.4.10
-rwxr-xr-x 1 root root  7288832 Aug 18 17:31 vmlinux-3.6.4
$ ls -l /mnt/usb/
$ ls -l /mnt/usb/
-rwxr-xr-x  1 root root      188 Aug 18 17:30 kboot.conf
-rwxr-xr-x  1 root root      188 Aug 18 17:30 kboot.conf
Line 208: Line 224:


<pre>
<pre>
debianlive=/debianlive/vmlinux-3.4.9 initrd=/debianlive/initramfs.cpio.gz
debianlive=/debianlive/vmlinux-3.6.4 initrd=/debianlive/initramfs.cpio.gz
</pre>
</pre>


==CDROM==
==CDROM==


* initramfs.cpio.gz: http://www.multiupload.nl/60CNXOU5U0 (MD5 8aa930e1e2e8b99ed223ad1df02ba54e)
(files seem missing)
* debianlive.iso.xz: http://www.multiupload.nl/HRJFPL38W8 (MD5 f6c9fa8d179f8da6ee196943a841efe9)
 
* initramfs-cdrom.cpio.gz: http://www.multiupload.nl/SA9YK1HFK0 (MD5 f71f8667dc52540136f90a95d7111efc)
* debianlive.iso: http://www.multiupload.nl/TW41UIVAGV (MD5 eeba4fa3428c5d687bada3fd975ea9dd)
* https://www.sendspace.com/file/2negnt (added missing link to debianlive)
* https://mega.nz/#!k1sTXI4a!ANmRDBVYmEdaToauoePNSKvoDl7GXGw0ORNN9ZM0Tfo
* https://www.sendspace.com/file/f8wnpe
* http://uploaded.net/file/vdxmzopu
<!-- https://www.sendspace.com/file/a3bsty -->


{{Keyboard|content=<syntaxhighlight lang="bash">
{{Keyboard|content=<syntaxhighlight lang="bash">
mkdir -p iso/debianlive
mkdir -p iso/debianlive
cp root.sfs initramfs.cpio.gz vmlinux-3.4.9 iso/debianlive
cp root.sfs initramfs.cpio.gz vmlinux-3.6.4 iso/debianlive
echo "debianlive=/debianlive/vmlinux-3.4.9 initrd=/debianlive/initramfs.cpio.gz" > iso/kboot.conf
echo "debianlive=/debianlive/vmlinux-3.6.4 initrd=/debianlive/initramfs.cpio.gz" > iso/kboot.conf
cd iso
cd iso
mkisofs -R -J -l -o ../debianlive.iso .
mkisofs -R -J -l -o ../debianlive.iso .
Line 226: Line 249:
sudo cdrecord -v dev=/dev/sr0 blank=fast
sudo cdrecord -v dev=/dev/sr0 blank=fast
sudo cdrecord -v dev=/dev/sr0 debianlive.iso
sudo cdrecord -v dev=/dev/sr0 debianlive.iso
</syntaxhighlight>}}<br /><br /><br /><br /><br /><br /><br /><br /><br /><br />
</syntaxhighlight>}}


=Links=
=Links=


* http://securityfocus.eu/?p=149
* http://securityfocus.eu/?p=149
{{Linux}}<noinclude>[[Category:Main]]</noinclude>

Latest revision as of 19:00, 2 December 2017


Introduction[edit | edit source]

  • Sometimes we need to boot Linux without HDD e.g. if you want to experiment with HDD encryption, enable/disable it without causing damage to your data. For such cases we need a LiveCD which doesn't mount HDD at boot.

Creating Initial System with debootstrap[edit | edit source]

Type This
apt-get install debootstrap

mkdir livecd

debootstrap --arch powerpc squeeze /root/livecd http://ftp.us.debian.org/debian

# Grab a beer and reverse some PS3 stuff in the meantime :)

# Enter chroot environment

mount -t proc none /root/livecd/proc
mount --rbind /dev /root/livecd/dev
LANG=C chroot /root/livecd /bin/bash

export TERM=xterm-color

echo "debian" > /etc/hostname

dpkg-reconfigure tzdata

# Configure network interfaces

cat /etc/network/interfaces
---
auto lo
iface lo inet loopback

allow-hotplug eth0
iface eth0 inet dhcp

allow-hotplug wlan0
iface wlan0 inet dhcp
    wpa-ssid ssid
    wpa-psk psk
-EOF-

# Configure APT

cat /etc/apt/sources.list
---

deb http://ftp.us.debian.org/debian squeeze main
deb-src http://ftp.us.debian.org/debian squeeze main

deb http://security.debian.org squeeze/updates main
deb-src http://security.debian.org squeeze/updates main
-EOF-

aptitude update

aptitude install locales
dpkg-reconfigure locales
aptitude install console-data
dpkg-reconfigure console-data

tasksel install standard
aptitude install binutils gcc make git vim openssh-server sudo wireless-tools wpasupplicant libssl-dev libncurses5-dev
aptitude  install gcc-spu g++-spu newlib-spu spu-tools
aptitude  install parted kpartx cryptsetup libreadline-dev libaio-dev libdevmapper-dev libudev-dev

# Make SSH server start at boot so we could ssh to our LiveCD

update-rc.d ssh defaults

aptitude clean

rm -f /etc/udev/rules.d/70-persistent-net.rules

# exit chroot environment

exit

# Unmount dev and proc

umount /root/livecd/dev/shm
umount /root/livecd/dev/pts
umount /root/livecd/dev
umount /root/livecd/proc

Creating Root Filesystem[edit | edit source]

Type This
cd /root/livecd
mksquashfs * ../root.sfs

Modifying Root Filesystem[edit | edit source]

Type This
cd /root
unsquashfs root.sfs
cd squashfs-root

# Make your changes

mksquashfs * ../root-changed.sfs

Linux 3 Kernel[edit | edit source]

  • We need a Linux 3 kernel with overlayfs support so we could create a tmpfs over our read-only base filesystem.
  • Furthermore, we want to compile PS3 HDD driver as module because in this case we can easily change HDD region flags.

See my GIT repos:

Initramfs[edit | edit source]

See my GIT repo: http://gitorious.ps3dev.net/ps3linux/livecd

BusyBox[edit | edit source]

  • We need a couple of user-space applications to mount filesystems, load kernel modules and so on.
  • And make sure you compile BusyBox without any library dependencies.
  • I compiled my BusyBox executable on PS3 Linux but you could cross-compile it too but then you need a complete PowerPC toolchain with libc.
http://busybox.net/downloads/busybox-1.20.1.tar.bz2

tar xvjf busybox-1.20.1.tar.bz2
cd busybox-1.20.1
make menuconfig
make

Creating Image[edit | edit source]

Type This
# Populate initramfs

mkdir initramfs
cd initramfs
mkdir -p bin dev etc lib/modules/3.6.4 mnt proc sbin sys usr/bin usr/sbin

cp ~/busybox-1.20.1/busybox bin/
cd bin
ln -sf busybox sh
cd ..

echo 'sda.*	0:6	0660' >> etc/mdev.conf
echo 'sr[0-9]	0:6	0660	@ln -sf $MDEV cdrom' >> etc/mdev.conf

cat >etc/modules <<EOF
> fat
> vfat
> isofs
> crc-ccitt
> crc-itu-t
> lzo_compress
> udf
> squashfs
> overlayfs
> ps3_gelic
> ps3stor_lib
> sg
> ps3rom
> usb-common
> usbcore
> ehci-hcd
> ohci-hcd
> usb-storage
> EOF

for mod in fat vfat isofs crc-ccitt crc-itu-t lzo_compress udf squashfs overlayfs \
           ps3_gelic ps3stor_lib sg ps3rom usb-common usbcore ehci-hcd ohci-hcd usb-storage; do
    path=`find  /home/glevand/linux-3.6.4-build/lib/modules/3.6.4 -name $mod.ko`
    cp $path lib/modules/3.6.4/
done

# Create initramfs

find . | cpio -H newc -o > ../initramfs.cpio
cd ..
cat initramfs.cpio | gzip > initramfs.cpio.gz

# Make changes to initramfs

gunzip initramfs.cpio.gz
mkdir initramfs
cd initramfs
cpio -i -d -H newc --no-absolute-filenames < ../initramfs.cpio

Images[edit | edit source]

  • vmlinux-3.6.4.xz: http://www.multiupload.nl/D0PYT6HGC0 (MD5 4b5fdb2995fde82e0f6817a7a86fca2c)
  • root.sfs: http://www.multiupload.nl/MWDSBR4OJZ (MD5 3ee12e2d351e0bbe1cd7818be23d8973)
  • Tools available on the root filesystem: gcc, spu-gcc, spuisofs, spuldrfs, ps3vuart-tools, ps3sed and all my other PS3 Linux drivers. Everything you need to compile and test various PS3 stuff.
  • In case someone still hasn't figured it out yet, password for root is root and password for glevand is glevand :)
  • I enabled DHCP on Ethernet.
  • You could use WLAN too but for that you have to modify the root filesystem and configure your SSID and PSK in /etc/network/interfaces.

USB[edit | edit source]

  • Your USB drive should be formatted with FAT32 filesystem.
  • initramfs-usb.cpio.gz: http://www.multiupload.nl/Y084SCQBL3 (MD5 f94b6aec2e5fbbb26f7d466165071469)
  • Create debianlive directory on your USB drive.
  • Put vmlinux-3.6.4 (extract xz archive), initramfs.cpio.gz and root.sfs into this directory.
Type This
$ ls -l /mnt/usb/debianlive/
total 257696
-rwxr-xr-x 1 root root   6746154 Aug 18 17:44 initramfs.cpio.gz
-rwxr-xr-x 1 root root 249835520 Aug 18 17:15 root.sfs
-rwxr-xr-x 1 root root   7288832 Aug 18 17:31 vmlinux-3.6.4
$ ls -l /mnt/usb/
-rwxr-xr-x  1 root root      188 Aug 18 17:30 kboot.conf
  • And create kboot.conf in the root directory of your USB drive with this content:
debianlive=/debianlive/vmlinux-3.6.4 initrd=/debianlive/initramfs.cpio.gz

CDROM[edit | edit source]

(files seem missing)

Type This
mkdir -p iso/debianlive
cp root.sfs initramfs.cpio.gz vmlinux-3.6.4 iso/debianlive
echo "debianlive=/debianlive/vmlinux-3.6.4 initrd=/debianlive/initramfs.cpio.gz" > iso/kboot.conf
cd iso
mkisofs -R -J -l -o ../debianlive.iso .
cd ..

sudo cdrecord -v dev=/dev/sr0 blank=fast
sudo cdrecord -v dev=/dev/sr0 debianlive.iso

Links[edit | edit source]